Class BaseFacesBean

java.lang.Object
com.webmethods.caf.faces.bean.BaseFacesBean
Direct Known Subclasses:
BaseApplicationBean, BaseEventHandlerBean, BaseFacesSessionBean, BaseMaintenancePage, BaseTaskRuleContext, EncodersBean

public class BaseFacesBean extends Object
Base class for all faces managed beans. Can be used as a parent class for client managed beans.
  • Field Details

    • OUTCOME_OK

      @Deprecated protected static final 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.
      Outcome for successful action
      See Also:
    • OUTCOME_ERROR

      @Deprecated protected static final 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.
      Outcome for failed action
      See Also:
    • resourcesProviders

      protected Map<Locale,ResourceBundleContentProvider> resourcesProviders
      Map of resource providers with Locale as the keys.
    • DATA_BINDING_CLIENTS

      protected static final String DATA_BINDING_CLIENTS
      The String key for storing the map of data binding clients.
      See Also:
    • EMPTY_RESOURCES

      public static final com.webmethods.caf.faces.bean.BaseFacesBean.EmptyResourceBundleContentProvider EMPTY_RESOURCES
  • Constructor Details

    • BaseFacesBean

      public BaseFacesBean()
      Default constructor
  • Method Details

    • createValueExpression

      protected ValueExpression createValueExpression(String expression)
      Shortcut method for creating a value expression
      Parameters:
      expression - value binding expression
      Returns:
      value binding for the given expression
    • createValueExpression

      protected ValueExpression createValueExpression(String expression, Class<?> expectedType)
      Shortcut method for creating a value expression
      Parameters:
      expression - value binding expression
      expectedType - the expected valye type
      Returns:
      value binding for the given expression
    • createMethodExpression

      protected MethodExpression createMethodExpression(String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes)
      Shortcut method for creating a method expression
      Parameters:
      expression - method binding expression
      expectedReturnType - the expected type to be returned by the method
      expectedParamTypes - method argument types
      Returns:
      MethodExpression for the given expression
    • createValueBinding

      @Deprecated protected ValueBinding createValueBinding(String expression)
      Deprecated.
      Shortcut method for getFacesContext().getApplication().createValueBinding(expression)
      Parameters:
      expression - value binding expression
      Returns:
      value binding for the given expression
    • createMethodBinding

      @Deprecated protected MethodBinding createMethodBinding(String expression, Class<?>[] args)
      Deprecated.
      Shortcut method for getFacesContext().getApplication().createMethodBinding(expression, args)
      Parameters:
      expression - method binding expression
      args - method argument types
      Returns:
      method binding for the given expression
    • resolveExpression

      protected Object resolveExpression(String expression)
      Return the result of the resolved value binding expression. getFacesContext() must return a valid context for the current thread.
      Parameters:
      expression - JSF value binding expression
      Returns:
      result of the expression, can be null
    • setValue

      protected boolean setValue(String expression, Object value)
      Sets value using given JSF value binding expression. Tries to convert the given value parameter to the target type of the value binding expression.
      Parameters:
      expression - JSF value binding expression
      value - new value to assign
      Returns:
      true if the new value is different from the previous value
    • putTreeAttribute

      protected void putTreeAttribute(String key, Object value)
      Places an Object on the tree's attribute map. The values persisted as long as the tree is persisted.
      Parameters:
      key - attribute key
      value - attribute value
    • getTreeAttribute

      protected Object getTreeAttribute(String key)
      Retrieves an Object from the tree's attribute map.
      Parameters:
      key - the attribute key
      Returns:
      previously set attribute value or null if not found
    • resolveDataBinding

      protected boolean resolveDataBinding(String[][] bindingExpressions, Object bean, String varName)
      Shortcut method
      See Also:
    • resolveDataBinding

      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.

      • #{left expression} = #{right expression}
      • #{method expression}

      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

      Parameters:
      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.
      Returns:
      true if data bindings have changed and the provider have not been auto-refreshed, i.e. it should be refreshed manually.
    • resetDataBindingClients

      protected void resetDataBindingClients()
      Resets data binding flags for the current request.
    • getBean

      protected Object getBean(String beanName)
      Returns reference to the managed bean with the given name
      Parameters:
      beanName - the name of the managed bean
      Returns:
      null if the bean cannot be found
    • getResourceInputStream

      protected static InputStream getResourceInputStream(String relPath)
      Returns an InputStream for a resource at the given path
      Parameters:
      relPath - relative to the web application root path to the resource
      Returns:
      input stream opened for this resource or null if resource is not found
    • log

      protected void log(Throwable throwable)
      Logs an exception
      Parameters:
      throwable - the exception
    • log

      protected void log(String message, Throwable throwable)
      Logs an exception
      Parameters:
      message - the message
      throwable - the exception
    • log

      protected void log(String message)
      Logs a message
      Parameters:
      message - the message
    • getStackTrace

      protected String getStackTrace(Throwable t)
      Returns stack trace of the given exception
      Parameters:
      t - the exception
      Returns:
      its stack trace
    • error

      protected void error(FacesMessage.Severity severity, String message, String details)
      Adds an error message to the faces context. This message can be display using Message control.
      Parameters:
      severity - severity of the message
      message - the message
      details - the details for the message
    • error

      protected void error(String message, String details)
      Adds an error message to the faces context. This message can be display using Message control.
      Parameters:
      message - the message
      details - the details for the message
    • error

      protected void error(String message)
      Adds an error message to the faces context. This message can be display using Message control.
      Parameters:
      message - the message
    • error

      protected void error(Throwable throwable)
      Adds an error message to the faces context. This message can be display using Message control.
      Parameters:
      throwable - the error exception
    • error

      protected void error(String message, Throwable throwable)
      Adds an error message to the faces context. This message can be display using Message control.
      Parameters:
      message - the message
      throwable - the error exception
    • getRootCause

      public Throwable getRootCause(Throwable ex)
      Returns root expception for the given exception
      Parameters:
      ex - the exception
      Returns:
      root exception or the exception itself
    • getFacesContext

      protected FacesContext getFacesContext()
      Returns current faces context
      Returns:
      null if faces context is not available for the current thread
    • isUserInRole

      protected boolean isUserInRole(String roleName)
      Checks if the current user is in specified local/logical role.
      Parameters:
      roleName - local/logical role name defined in this web or portlet application
      Returns:
      true if the current user belongs to this role.
    • getResources

      protected IContentProvider getResources(String baseName)
      Deprecated.
    • getResourcesProvider

      protected ResourceBundleContentProvider getResourcesProvider(String baseName)
      Returns 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.
      Parameters:
      baseName - resource bundle base name
      Returns:
      instance of ResourceBundleContentProvider for application resource bundle.
    • getLocale

      protected Locale getLocale()
      Returns locale for the current request/response.
      Returns:
      locale