Class BaseFacesPreferencesBean

All Implemented Interfaces:
IPageFlowScopeAdapter, EventListener, HttpSessionBindingListener

public class BaseFacesPreferencesBean extends BaseFacesSessionBean

Smart preferences bean. Preferences for portlets may be coming from following sources:

  • from url (request parameters) when portlet is linked from another one
  • wired to another portlet preference
  • persisted preference
  • transient value stored in the preferences bean

The preference value from the url always takes precendence over value stored on the bean or taken from wired source or persisted. Transient value, if explicitely set, should take precedence over wired or persisted value.

Client applications should subclass this base class for each portlet in a portlet application.

  • Constructor Details

    • BaseFacesPreferencesBean

      public BaseFacesPreferencesBean()
      Default constructor. Initiaizes list of preferences based on the PREFERENCES_NAMES field in this class.
    • BaseFacesPreferencesBean

      public BaseFacesPreferencesBean(String[] prefNames)
      Constrcutor that takes list of preference names.
      Parameters:
      prefNames - names of the portlet preferences
  • Method Details

    • release

      protected void release()
      Description copied from class: BaseFacesSessionBean
      Override this method to release any resources associated with this session. Please note, the FacesContext is not valid for this function
      Specified by:
      release in class BaseFacesSessionBean
    • initPreferencesForRequest

      public void initPreferencesForRequest()
      Initializes preferences from the request parameters. This method gets called by ViewHandler tag handler while building the view component tree.
    • initPreferences

      protected void initPreferences() throws Exception
      Initializes preferences from the request parameters. This method gets called by JSF phase listener before portlet rendering.
      Throws:
      Exception - if call is made outside of the PortletContext
    • getProxyThingID

      public String getProxyThingID() throws Exception
      Returns MWS proxyThingID for portlets used as 'pseudo portlet renderers'
      Returns:
      null, if the portlet is not used as pseudo portlet renderer, otherwise the proxy thing id
      Throws:
      Exception
      Since:
      8.0
    • updatePreferences

      protected void updatePreferences() throws Exception
      Copies any new preference values into the underlying PortletPreferences storage. This gets called from JSF phase listener after portlet rendering.
      Throws:
      Exception
    • getPreferenceValue

      protected Object getPreferenceValue(String preferenceName, Class<?> preferenceClass) throws Exception
      Returns portlet preference value and converts it to the target class.
      Parameters:
      preferenceName - portlet preference name
      preferenceClass - target value class
      Returns:
      the value of the portlet preference
      Throws:
      Exception
    • setPreferenceValue

      protected void setPreferenceValue(String preferenceName, Object preferenceValue) throws Exception
      Sets new value of the portlet preference.
      Parameters:
      preferenceName - portlet preference name
      preferenceValue - preference value
      Throws:
      Exception
    • getPortletResources

      public IContentProvider getPortletResources()
      Deprecated.
    • getPortletResourcesProvider

      public ResourceBundleContentProvider getPortletResourcesProvider()
      Returns ResourceBundleContentProvider for the associated portlet for the current locale. The locale is specified by UIViewRoot.getLocale(). The resource bundle base name is specified in PortletConfig.getResourceBundle(java.util.Locale). If resource bundle cannot be loaded the returned provider is empty.
      Returns:
      instance of ResourceBundleContentProvider for application resource bundle.
    • getPreferencesMap

      public Map<String,Object> getPreferencesMap()
      Returns all the preferences as modifiable map
      Returns:
      Map<String, Object> of all the preferences.
    • getPortletURI

      public String getPortletURI()
      Get the URI of the current portlet instance.
      Returns:
      URI as a String.
    • getPortletConfig

      protected javax.portlet.PortletConfig getPortletConfig()
      Returns portlet config object
      Returns:
      portlet config or null if not available
    • getPreferences

      protected javax.portlet.PortletPreferences getPreferences() throws Exception
      Returns instance of the Portlet Preferences for the current portlet
      Returns:
      PortletPreferences object
      Throws:
      Exception - if this is made outside of the PortletContext