public final class IlvFacesUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
APPLICATION_SESSION_SCOPE
The application scope used to store and retrieve session attributes when using portlets.
|
static int |
PORTLET_SESSION_SCOPE
The portlet scope used to store and retrieve session attributes when using portlets.
|
Modifier and Type | Method and Description |
---|---|
static String |
buildAbsoluteId(javax.faces.component.UIComponent component)
Returns the fully qualified id of the component.
|
static String |
encodeJavaScriptVariables(String jsAction)
This method allows you to namespace encode the marked IDs of component in
the JavaScript string passed as parameter.
|
static String |
getAbsoluteId(javax.faces.component.UIComponent refComponent,
String id)
Returns the absolute ID of a component with a reference component and a
relative ID.
|
static Locale |
getFacesLocale()
Returns the
Locale of the current JSF request,
or null if not currently executing in JSF context. |
static org.slf4j.Logger |
getLogger()
Returns the logger registered on this package.
|
static Object |
getPrimitivePropertyValue(javax.faces.component.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(javax.faces.component.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(javax.faces.component.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 |
isAdfPartial(javax.faces.context.FacesContext context)
Returns whether the current request is a PPR request in an ADF context.
|
static boolean |
isPartialRequest(javax.faces.context.FacesContext context)
Returns whether the current request is a PPR request or a regular one (full page refresh).
|
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 |
processValueChange(javax.faces.context.FacesContext context,
javax.faces.event.ValueChangeListener[] listeners,
javax.faces.el.MethodBinding method,
javax.faces.event.ValueChangeEvent valueChangeEvent)
Process value change event according to different JSF runtime.
|
static void |
setPrimitiveLocalValueSet(javax.faces.component.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(javax.faces.context.FacesContext context)
Stores the portlet namespace in the session with the
IlvFacesConstants.PORTLET_NAMESPACE key. |
static void |
updateModelFromPrimitiveValue(javax.faces.context.FacesContext context,
javax.faces.component.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(javax.faces.context.FacesContext context,
javax.faces.component.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.
|
public static final int APPLICATION_SESSION_SCOPE
setSessionAttribute(String, Object, int, boolean)
,
getSessionAttribute(String, int)
,
Constant Field Valuespublic static final int PORTLET_SESSION_SCOPE
setSessionAttribute(String, Object, int, boolean)
,
getSessionAttribute(String, int)
,
Constant Field Valuespublic static Locale getFacesLocale()
Locale
of the current JSF request,
or null
if not currently executing in JSF context.
Note: The result of this method depends on the current thread.
If the result is non-null, it should be assigned to the current
locale, using the method
IlvLocaleUtil.setThreadULocale(com.ibm.icu.util.ULocale)
before IlvLocaleUtil.getCurrentLocale()
or IlvLocaleUtil.getCurrentULocale()
is accessed.
The result of this method can be influenced
<locale-config>
element in the
<application>
element in the Faces configuration
file faces-config.xml
,locale
attribute in the f:view
tag,<view-handler>
element in the
<application>
element in the Faces configuration
file faces-config.xml
that points to a class that
overrides the
calculateLocale
method.IlvLocaleUtil.setThreadULocale(com.ibm.icu.util.ULocale)
public static String encodeJavaScriptVariables(String jsAction)
${}
pattern.
For example if the current portlet namespace is _ns_
,
the string ${view}.setInteractor(${interactor})
will be converted into _ns_view.setInteractor(_ns_interactor)
.
jsAction
- The JavaScript action whose IDs must be namespace encoded.IllegalArgumentException
- This exception is thrown if an ID is
empty or no correct pattern has been found.public static String getAbsoluteId(javax.faces.component.UIComponent refComponent, String id)
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.refComponent
- The base component whose id is to be resolved.id
- The identity (relative or absolute) of the componentpublic static String buildAbsoluteId(javax.faces.component.UIComponent component)
component
- The component.public static void updateModelFromValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String property, Object localValue)
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.public static void updateModelFromPrimitiveValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String property, Object localValue)
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.public static org.slf4j.Logger getLogger()
public static void log(Object o, String message)
o
- The object to which the message relates.message
- The message to log.public static void log(String message)
message
- The message to log.public static void log(String message, Level level)
message
- The message to log.level
- the level to log the message.public static void logAnyway(String message)
message
- The message to log.public static void logAnyway(String message, Level level)
message
- The message to log.level
- the level to log the message.public static void log(Throwable e)
e
- The exception to log.public static void log(Throwable e, Level level)
e
- The exception to log.level
- the level to log the message.public static void logAnyway(Throwable e)
e
- The exception to log.public static void logAnyway(Throwable e, Level level)
e
- The exception to log.level
- The level to log the exception.public static Object getPropertyValue(javax.faces.component.UIComponent component, String property, Object localValue)
component
- The component processed.property
- The property processed.localValue
- The local value to return if not null
.@Deprecated public static Object getPropertyValue(javax.faces.component.UIComponent component, String property, Object localValue, boolean valueSet)
getPrimitivePropertyValue(UIComponent, String, Object)
} instead.null
otherwise.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.public static void setPrimitiveLocalValueSet(javax.faces.component.UIComponent component, String property)
This flag is used in:
getPrimitivePropertyValue(UIComponent, String, Object)
method to determine whether
returning the local object or the model one.updateModelFromPrimitiveValue(FacesContext, UIComponent, String, Object)
method to determine
if the model object should be updated by the local value in th update model value phase of the JSF lifecycle.component
- The component.property
- The propertypublic static Object getPrimitivePropertyValue(javax.faces.component.UIComponent component, String property, Object localValue)
null
otherwise.
This method determines if the local values has changed if the setPrimitiveLocalValueSet(UIComponent, String)
method has been called with this component and property.
component
- The component processed.property
- The property processed.localValue
- The local value to return if the value set flag is set to
true
.public static void setRequestAttribute(String name, Object value)
name
- The name to which the object is bound; cannot be null.value
- The object to be bound.public static Object getRequestAttribute(String name)
name
- A string specifying the name of the object.public static void setSessionAttribute(String name, Object value, int scope, boolean create)
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 sessionpublic static void setSessionAttribute(String name, Object value)
name
- The name to which the object is bound; cannot be null.value
- The object to be bound.public static Object getSessionAttribute(String name)
name
- A string specifying the name of the object.IllegalStateException
- if this method is called on an invalidated
session.public static Object getSessionAttribute(String name, int scope) throws IllegalStateException
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
.IllegalStateException
- if this method is called on an invalidated
session.public static void storeNamespaceInSession(javax.faces.context.FacesContext context)
IlvFacesConstants.PORTLET_NAMESPACE
key.context
- The current faces context.public static boolean isValueBinding(String expr)
true
if the expression is a value binding expression.expr.startsWith("#{") && expr.endsWith("}")
.
If the expr
parameter is null
returns false
.expr
- The expression to test.true
if the expression is a value binding or false
otherwise.public static String getRequestHeader(String name)
null
if not found.name
- The name of the headerpublic static boolean isAdfPartial(javax.faces.context.FacesContext context)
context
- The faces context.true
if the current request is a PPR requestin an ADF context.public static boolean isPartialRequest(javax.faces.context.FacesContext context)
context
- The faces context.true
if the current request is a PPR request.public static void processValueChange(javax.faces.context.FacesContext context, javax.faces.event.ValueChangeListener[] listeners, javax.faces.el.MethodBinding method, javax.faces.event.ValueChangeEvent valueChangeEvent)
context
- FacesContext
object.listeners
- the value change listener array object.method
- the method binding object.valueChangeEvent
- the value change event object.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.