ilog.views.faces
Class IlvFacesUtil

java.lang.Object
  extended by ilog.views.faces.IlvFacesUtil

public final class IlvFacesUtil
extends Object

Various JViews Faces utilities.

Since:
JViews 6.0

Field Summary
static int APPLICATION_SESSION_SCOPE
          The session portlet scope.
static int PORTLET_SESSION_SCOPE
          The session portlet scope.
 
Method Summary
static String buildAbsoluteId(UIComponent component)
          Returns the fully qualified id of the component.
static String encodeJavaScriptVariables(String jsAction)
          This method allows to namespace encode the marked IDs of component in the JavaScript string passed as parameter.
static String getAbsoluteId(UIComponent refComponent, String id)
          Returns the absolute ID of a component with a reference component and a relative ID.
static Logger getLogger()
          Returns the logger registered on this package.
static Object getPrimitivePropertyValue(UIComponent component, String property, Object localValue)
          Returns the local value, if set, or the object described by the property from the model if the component has a value binding registered for this property, null otherwise.
static Object getPropertyValue(UIComponent component, String property, Object localValue)
          Returns the local value if not null or the object described by the property from the model if the component has a value binding registered for this property, null otherwise.
static Object getPropertyValue(UIComponent component, String property, Object localValue, boolean valueSet)
          Deprecated. Beginning with JViews 8.1 use getPrimitivePropertyValue(UIComponent, String, Object)} instead.
static Object getRequestAttribute(String name)
          Returns an attribute in the request.
static String getRequestHeader(String name)
          Returns the header value of the current HTTP request for the given name.
static Object getSessionAttribute(String name)
          Returns an attribute in the session.
static Object getSessionAttribute(String name, int scope)
          Returns an attribute in the session.
static boolean isValueBinding(String expr)
          Returns true if the expression is a value binding expression.
static void log(Object o, String message)
          Logs a message prefixed by the short name of the class of the object.
static void log(String message)
          Logs a message at the INFO level.
static void log(String message, Level level)
          Logs a message at the specified level.
static void log(Throwable e)
          Logs an exception at the INFO level if the 'logExceptions' flag is set in the configuration file.
static void log(Throwable e, Level level)
          Logs an exception at the specified level if the 'logExceptions' flag is set in the configuration file.
static void logAnyway(String message)
          Logs a message at the INFO level.
static void logAnyway(String message, Level level)
          Logs a message.
static void logAnyway(Throwable e)
          Logs an exception with no configuration file control at the INFO level.
static void logAnyway(Throwable e, Level level)
          Logs an exception with no configuration file control at the specified level.
static void setPrimitiveLocalValueSet(UIComponent component, String property)
          Marks the specified property as locally changed.
static void setRequestAttribute(String name, Object value)
          Binds an object to the current request, using the name specified.
static void setSessionAttribute(String name, Object value)
          Binds an object to this session, using the name specified.
static void setSessionAttribute(String name, Object value, int scope, boolean create)
          Binds an object to the current session, using the name specified.
static void storeNamespaceInSession(FacesContext context)
          Stores the portlet namespace in the session with the IlvFacesConstants.PORTLET_NAMESPACE key.
static void updateModelFromPrimitiveValue(FacesContext context, UIComponent component, String property, Object localValue)
          Updates the model with the local value if a value binding on the property is registered on the component and the local value has changed.
static void updateModelFromValue(FacesContext context, UIComponent component, String property, Object localValue)
          Updates the model with the local value if a value binding on the property is registered on the component and the local value has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_SESSION_SCOPE

public static final int APPLICATION_SESSION_SCOPE
The session portlet scope. Used to specify to store a session attribute in the application scope.

Since:
JViews 8.0
See Also:
setSessionAttribute(String, Object, int, boolean), getSessionAttribute(String, int), Constant Field Values

PORTLET_SESSION_SCOPE

public static final int PORTLET_SESSION_SCOPE
The session portlet scope. Used to specify to store a session attribute in the portlet scope.

Since:
JViews 8.0
See Also:
setSessionAttribute(String, Object, int, boolean), getSessionAttribute(String, int), Constant Field Values
Method Detail

encodeJavaScriptVariables

public static String encodeJavaScriptVariables(String jsAction)
This method allows to namespace encode the marked IDs of component in the JavaScript string passed as parameter. The IDs to encode must be enclosed in ${} pattern.

For example if the current portlet namespace is _ns_, the string ${view}.setInteractor(${interactor}) will be converted into _ns_view.setInteractor(_ns_interactor).

Parameters:
jsAction - The JavaScript action whose IDs must be namespace encoded.
Returns:
The transformed JavaScript action.
Throws:
IllegalArgumentException - This exception is thrown if an ID is empty or no correct pattern has been found.
Since:
JViews 8.0

getAbsoluteId

public static String getAbsoluteId(UIComponent refComponent,
                                   String id)
Returns the absolute ID of a component with a reference component and a relative ID. If the ID is absolute, it returns the ID without processing it. If the component exists, it returns the absolute path where componentRef is the base component of the relative path. If the component does not exist, the refComponent is considered a sibling of the the component designed by the specified id in the computing process.

Parameters:
refComponent - The base component whose id is to be resolved.
id - The identity (relative or absolute) of the component
Returns:
The fully qualified id of the component.

buildAbsoluteId

public static String buildAbsoluteId(UIComponent component)
Returns the fully qualified id of the component.

Parameters:
component - The component.
Returns:
The fully qualified id of the component.

updateModelFromValue

public static void updateModelFromValue(FacesContext context,
                                        UIComponent component,
                                        String property,
                                        Object localValue)
Updates the model with the local value if a value binding on the property is registered on the component and the local value has changed.

Parameters:
context - The current faces context.
component - The component linked to the model.
property - The property of the model to update.
localValue - The value with which to update the model.

updateModelFromPrimitiveValue

public static void updateModelFromPrimitiveValue(FacesContext context,
                                                 UIComponent component,
                                                 String property,
                                                 Object localValue)
Updates the model with the local value if a value binding on the property is registered on the component and the local value has changed.

Parameters:
context - The current faces context.
component - The component linked to the model.
property - The property of the model to update.
localValue - The value with which to update the model.
Since:
JViews 6.5

getLogger

public static Logger getLogger()
Returns the logger registered on this package.

Returns:
The logger registered on this package.
Since:
JViews 8.0

log

public static void log(Object o,
                       String message)
Logs a message prefixed by the short name of the class of the object. The message is emitted if the 'logInfo' flag is set in the configuration file.

Parameters:
o - The object to which the message relates.
message - The message to log.

log

public static void log(String message)
Logs a message at the INFO level. The message is emitted if the 'logInfo' flag is set in the configuration file.

Parameters:
message - The message to log.

log

public static void log(String message,
                       Level level)
Logs a message at the specified level. The message is emitted if the 'logInfo' flag is set in the configuration file.

Parameters:
message - The message to log.
level - the level to log the message.
Since:
JViews 8.0

logAnyway

public static void logAnyway(String message)
Logs a message at the INFO level. Emission of this message is not controlled by a configuration flag.

Parameters:
message - The message to log.

logAnyway

public static void logAnyway(String message,
                             Level level)
Logs a message. Emission of this message is not controlled by a configuration flag.

Parameters:
message - The message to log.
level - the level to log the message.
Since:
JViews 8.0

log

public static void log(Throwable e)
Logs an exception at the INFO level if the 'logExceptions' flag is set in the configuration file.

Parameters:
e - The exception to log.

log

public static void log(Throwable e,
                       Level level)
Logs an exception at the specified level if the 'logExceptions' flag is set in the configuration file.

Parameters:
e - The exception to log.
level - the level to log the message.
Since:
JViews 8.0

logAnyway

public static void logAnyway(Throwable e)
Logs an exception with no configuration file control at the INFO level.

Parameters:
e - The exception to log.

logAnyway

public static void logAnyway(Throwable e,
                             Level level)
Logs an exception with no configuration file control at the specified level.

Parameters:
e - The exception to log.
level - The level to log the exception.
Since:
JViews 8.0

getPropertyValue

public static Object getPropertyValue(UIComponent component,
                                      String property,
                                      Object localValue)
Returns the local value if not null or the object described by the property from the model if the component has a value binding registered for this property, null otherwise.

Parameters:
component - The component processed.
property - The property processed.
localValue - The local value to return if not null.
Returns:
The object from the model if a value binding is registered on the component for this property.
Since:
JViews 6.5

getPropertyValue

public static Object getPropertyValue(UIComponent component,
                                      String property,
                                      Object localValue,
                                      boolean valueSet)
Deprecated. Beginning with JViews 8.1 use getPrimitivePropertyValue(UIComponent, String, Object)} instead.

Returns the local value, if set, or the object described by the property from the model if the component has a value binding registered for this property, null otherwise.

Parameters:
component - The component processed.
property - The property processed.
localValue - The local value to return if the value set flag is set to true.
valueSet - The value set flag that indicates that the local value is valid and must be returned.
Returns:
The object from the model if a value binding is registered on the component for this property.
Since:
JViews 6.5

setPrimitiveLocalValueSet

public static void setPrimitiveLocalValueSet(UIComponent component,
                                             String property)
Marks the specified property as locally changed.

This flag is used in:

This method must be used when a primitive property of component is changed (usually in the component setter).

Parameters:
component - The component.
property - The property
Since:
JViews 8.1

getPrimitivePropertyValue

public static Object getPrimitivePropertyValue(UIComponent component,
                                               String property,
                                               Object localValue)
Returns the local value, if set, or the object described by the property from the model if the component has a value binding registered for this property, null otherwise.

This method has to be used instead of getPropertyValue(UIComponent, String) for primitive values.

This method determines if the local values has changed if the setPrimitiveLocalValueSet(UIComponent, String) method has been called with this component and property.

Parameters:
component - The component processed.
property - The property processed.
localValue - The local value to return if the value set flag is set to true.
Returns:
The object from the model if a value binding is registered on the component for this property.
Since:
JViews 8.1

setRequestAttribute

public static void setRequestAttribute(String name,
                                       Object value)
Binds an object to the current request, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
Note that this methods handles HTTP and portlet request.

Parameters:
name - The name to which the object is bound; cannot be null.
value - The object to be bound.
Since:
JViews 7.5

getRequestAttribute

public static Object getRequestAttribute(String name)
Returns an attribute in the request. This methods handles HTTP and portlet requests.

Parameters:
name - A string specifying the name of the object.
Since:
JViews 7.5

setSessionAttribute

public static void setSessionAttribute(String name,
                                       Object value,
                                       int scope,
                                       boolean create)
Binds an object to the current session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
Note that this methods handles HTTP and portlet sessions.

Parameters:
name - The name to which the object is bound; cannot be null.
value - The object to be bound.
scope - The scope of the value (used in portlets only). Valid values are IlvFacesUtil.PORTLET_SESSION_SCOPE and IlvFacesUtil.PORTLET_APPLICATION_SCOPE.
create - -True - to create a new session for this request if necessary; false to return null if there's no current session
Since:
JViews 6.5

setSessionAttribute

public static void setSessionAttribute(String name,
                                       Object value)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
If the session does not exists, a new one is created.
Note that this methods handles HTTP and portlet sessions. In the portlet case this method stored the attribute in

Parameters:
name - The name to which the object is bound; cannot be null.
value - The object to be bound.
Since:
JViews 6.5

getSessionAttribute

public static Object getSessionAttribute(String name)
Returns an attribute in the session. This methods handles HTTP and portlet sessions.

Parameters:
name - A string specifying the name of the object.
Throws:
IllegalStateException - if this method is called on an invalidated session.
Since:
JViews 6.5

getSessionAttribute

public static Object getSessionAttribute(String name,
                                         int scope)
                                  throws IllegalStateException
Returns an attribute in the session. This methods handles HTTP and portlet sessions.

Parameters:
name - A string specifying the name of the object.
scope - The scope of the stored attribute in the portlet context. Valid values are IlvFacesUtil.PORTLET_SESSION_SCOPE and IlvFacesUtil.PORTLET_APPLICATION_SCOPE.
Throws:
IllegalStateException - if this method is called on an invalidated session.
Since:
JViews 6.5

storeNamespaceInSession

public static void storeNamespaceInSession(FacesContext context)
Stores the portlet namespace in the session with the IlvFacesConstants.PORTLET_NAMESPACE key.

Parameters:
context - The current faces context.
Since:
JViews 6.5

isValueBinding

public static boolean isValueBinding(String expr)
Returns true if the expression is a value binding expression.
It's similar to call expr.startsWith("#{") && expr.endsWith("}"). If the expr parameter is null returns false.

Parameters:
expr - The expression to test.
Returns:
true if the expression is a value binding or false otherwise.
Since:
JViews 7.5

getRequestHeader

public static String getRequestHeader(String name)
Returns the header value of the current HTTP request for the given name. This methods handles HTTP and Portlet requests. The returned value is null if not found.

Parameters:
name - The name of the header
Since:
JViews 7.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.