public class BaseFacesBean extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
DATA_BINDING_CLIENTS
The
String key for storing the map of data binding clients. |
protected static String |
OUTCOME_ERROR
Deprecated.
With JSF2, the outcome of an action is generally expected to be null or the name of the page to redirect to.
|
protected static String |
OUTCOME_OK
Deprecated.
With JSF2, the outcome of an action is generally expected to be null or the name of the page to redirect to.
|
protected Map |
resourcesProviders
Map of resource providers with Locale as the keys. |
Constructor and Description |
---|
BaseFacesBean()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
protected MethodBinding |
createMethodBinding(String expression,
Class[] args)
Shortcut method for
getFacesContext().getApplication().createMethodBinding(expression, args) |
protected ValueBinding |
createValueBinding(String expression)
Shortcut method for
getFacesContext().getApplication().createValueBinding(expression) |
protected void |
error(FacesMessage.Severity severity,
String message,
String details)
Adds an error message to the faces context.
|
protected void |
error(String message)
Adds an error message to the faces context.
|
protected void |
error(String message,
String details)
Adds an error message to the faces context.
|
protected void |
error(String message,
Throwable throwable)
Adds an error message to the faces context.
|
protected void |
error(Throwable throwable)
Adds an error message to the faces context.
|
protected Object |
getBean(String beanName)
Returns reference to the managed bean with the given name
|
protected FacesContext |
getFacesContext()
Returns current faces context
|
protected Locale |
getLocale()
Returns locale for the current request/response.
|
protected static InputStream |
getResourceInputStream(String relPath)
Returns an InputStream for a resource at the given path
|
protected IContentProvider |
getResources(String baseName)
Deprecated.
|
protected ResourceBundleContentProvider |
getResourcesProvider(String baseName)
Returns
ResourceBundleContentProvider for the current locale and baseName. |
Throwable |
getRootCause(Throwable ex)
Returns root expception for the given exception
|
protected String |
getStackTrace(Throwable t)
Returns stack trace of the given exception
|
protected Object |
getTreeAttribute(String key)
Retrieves an Object from the tree's attribute map.
|
protected boolean |
isUserInRole(String roleName)
Checks if the current user is in specified local/logical role.
|
protected void |
log(String message)
Logs a message
|
protected void |
log(String message,
Throwable throwable)
Logs an exception
|
protected void |
log(Throwable throwable)
Logs an exception
|
protected void |
putTreeAttribute(String key,
Object value)
Places an Object on the tree's attribute map.
|
protected void |
resetDataBindingClients()
Resets data binding flags for the current request.
|
protected boolean |
resolveDataBinding(String[][] bindingExpressions,
Object bean,
String varName)
Shortcut method
|
protected boolean |
resolveDataBinding(String[][] bindingExpressions,
Object bean,
String varName,
boolean forceResolve,
boolean cacheRightValues)
Data Flow execution.
|
protected Object |
resolveExpression(String expression)
Return the result of the resolved value binding expression.
|
protected boolean |
setValue(String expression,
Object value)
Sets value using given JSF value binding expression.
|
@Deprecated protected static final String OUTCOME_OK
@Deprecated protected static final String OUTCOME_ERROR
protected Map resourcesProviders
Map
of resource providers with Locale
as the keys.protected static final String DATA_BINDING_CLIENTS
String
key for storing the map of data binding clients.protected ValueBinding createValueBinding(String expression)
getFacesContext().getApplication().createValueBinding(expression)
expression
- value binding expressionprotected MethodBinding createMethodBinding(String expression, Class[] args)
getFacesContext().getApplication().createMethodBinding(expression, args)
expression
- method binding expressionargs
- method argument typesprotected Object resolveExpression(String expression)
BaseFacesBean.getFacesContext()
must return a valid context for the
current thread.expression
- JSF value binding expressionprotected boolean setValue(String expression, Object value)
expression
- JSF value binding expressionvalue
- new value to assignprotected void putTreeAttribute(String key, Object value)
key
- attribute keyvalue
- attribute valueprotected Object getTreeAttribute(String key)
key
- the attribute keyprotected boolean resolveDataBinding(String[][] bindingExpressions, Object bean, String varName)
protected boolean resolveDataBinding(String[][] bindingExpressions, Object bean, String varName, boolean forceResolve, boolean cacheRightValues)
Data Flow execution. The flow is a set of data assigments and action calls.
The varName
parameter can be used to access java bean specified as bean
parameter.
For example, if varName=this, then
binding expression can use "#{this.myproperty}" to access myproperty on the bean
instance.
If the bean implements IRefreshableContentProvider
and IRefreshable.isAutoRefresh()
is true
then it automatically calls IRefreshable.refresh()
method if any of the right expressions differ from the values previously set on the bean.
By default bindings are evaluted once per request (action or render). Specifying forceResolve
parameters
as true will force the resolution.
If right expression returns null
the previously cached value of that expression will be used,
if cacheRightValues
parameter is true. If null is a valid value, then use false for cacheRightValues
bindingExpressions
- two dimentional array of left expression=right expression, or method expression.bean
- java bean instance, can be a managed bean instance, can be null.varName
- optional variable name that will point to the bean instance. Can be null.forceResolve
- set to true to force the resolution. If false it only happens once per request (action or render)cacheRightValues
- set to true if want cache non-null right expressions values and use them whenever right expression returns null. Set
to false, if null is a valid value.protected void resetDataBindingClients()
protected Object getBean(String beanName)
beanName
- the name of the managed beanprotected static InputStream getResourceInputStream(String relPath)
relPath
- relative to the web application root path to the resourceprotected void log(Throwable throwable)
throwable
- the exceptionprotected void log(String message, Throwable throwable)
message
- the messagethrowable
- the exceptionprotected void log(String message)
message
- the messageprotected String getStackTrace(Throwable t)
t
- the exceptionprotected void error(FacesMessage.Severity severity, String message, String details)
severity
- severity of the messagemessage
- the messagedetails
- the details for the messageprotected void error(String message, String details)
message
- the messagedetails
- the details for the messageprotected void error(String message)
message
- the messageprotected void error(Throwable throwable)
throwable
- the error exceptionprotected void error(String message, Throwable throwable)
message
- the messagethrowable
- the error exceptionpublic Throwable getRootCause(Throwable ex)
ex
- the exceptionprotected FacesContext getFacesContext()
protected boolean isUserInRole(String roleName)
roleName
- local/logical role name defined in this web or portlet applicationprotected IContentProvider getResources(String baseName)
protected ResourceBundleContentProvider getResourcesProvider(String baseName)
ResourceBundleContentProvider
for the current locale and baseName.
The locale is specified by UIViewRoot.getLocale()
.
If message bundle is not specified or cannot be loaded the returned provider is empty.baseName
- resource bundle base nameprotected Locale getLocale()