com.webmethods.caf.faces.bean
Class BaseFacesPreferencesBean

java.lang.Object
  extended by com.webmethods.caf.faces.bean.BaseFacesBean
      extended by com.webmethods.caf.faces.bean.BaseFacesSessionBean
          extended by com.webmethods.caf.faces.bean.BaseFacesPreferencesBean
All Implemented Interfaces:
IPageFlowScopeAdapter

public class BaseFacesPreferencesBean
extends BaseFacesSessionBean

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

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.


Field Summary
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
fExpireWithPageFlow
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
DATA_BINDING_CLIENTS, OUTCOME_ERROR, OUTCOME_OK, resourcesProviders
 
Constructor Summary
BaseFacesPreferencesBean()
          Default constructor.
BaseFacesPreferencesBean(String[] prefNames)
          Constrcutor that takes list of preference names.
 
Method Summary
protected  PortletConfig getPortletConfig()
          Returns portlet config object
 IContentProvider getPortletResources()
          Deprecated.  
 ResourceBundleContentProvider getPortletResourcesProvider()
          Returns ResourceBundleContentProvider for the associated portlet for the current locale.
 String getPortletURI()
          Get the URI of the current portlet instance.
protected  PortletPreferences getPreferences()
          Returns instance of the Portlet Preferences for the current portlet
 Map getPreferencesMap()
          Returns all the preferences as modifiable map
protected  Object getPreferenceValue(String preferenceName, Class preferenceClass)
          Returns portlet preference value and converts it to the target class.
 String getProxyThingID()
          Returns MWS proxyThingID for portlets used as 'pseudo portlet renderers'
protected  void initPreferences()
          Initializes preferences from the request parameters.
protected  void release()
          Override this method to release any resources associated with this session.
protected  void setPreferenceValue(String preferenceName, Object preferenceValue)
          Sets new value of the portlet preference.
protected  void updatePreferences()
          Copies any new preference values into the underlying PortletPreferences storage.
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
getExpireWithPageFlow, setExpireWithPageFlow, valueBound, valueUnbound
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
createMethodBinding, createValueBinding, error, error, error, error, error, getBean, getFacesContext, getLocale, getResourceInputStream, getResources, getResourcesProvider, getRootCause, getStackTrace, getTreeAttribute, isUserInRole, log, log, log, putTreeAttribute, resetDataBindingClients, resolveDataBinding, resolveDataBinding, resolveExpression, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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

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. 

Use BaseFacesPreferencesBean.getPortletResourcesProvider()


getPortletResourcesProvider

public ResourceBundleContentProvider getPortletResourcesProvider()
Returns ResourceBundleContentProvider for the associated portlet for the current locale. The locale is specified by UIViewRoot. 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 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 PortletConfig getPortletConfig()
Returns portlet config object

Returns:
portlet config or null if not available

getPreferences

protected PortletPreferences getPreferences()
                                     throws Exception
Returns instance of the Portlet Preferences for the current portlet

Returns:
javax.portlet.PortletPreferences object
Throws:
Exception - if this is made outside of the PortletContext