org.edorasframework.portletfaces.context
Class PortletFacesContext

java.lang.Object
  extended by javax.faces.context.FacesContext
      extended by org.edorasframework.extfaces.context.ExtFacesContext
          extended by org.edorasframework.portletfaces.context.PortletFacesContext
Direct Known Subclasses:
PortletFacesContextImpl

public abstract class PortletFacesContext
extends org.edorasframework.extfaces.context.ExtFacesContext

This class provides a variety of useful utility methods for use by JSF portlets.

Author:
"Joel Kozikowski", mimacom ag, "Neil Griffin", mimacom ag

Field Summary
 
Fields inherited from class org.edorasframework.extfaces.context.ExtFacesContext
JAVAX_FACES_UPLOADED_FILES_MAP
 
Constructor Summary
PortletFacesContext()
           
 
Method Summary
abstract  void addGlobalSuccessInfoMessage()
          Adds a global information message to the current FacesContext with the standard Liferay "your-request-processed-successfully" key as the messageId.
abstract  void addGlobalUnexpectedErrorMessage()
          Adds a global error message to the current FacesContext with the standard Liferay "an-unexpected-error-occurred" key as the messageId.
abstract  void checkUserPortletPermission(String actionId)
          Checks to see if the current user has permission to execute the specified actionId (which, in turn, is assumed to be an action defined for the current portlet).
abstract  javax.portlet.PortletURL createActionURL()
          Retrieves a render URL for the current facesContext.
abstract  javax.portlet.PortletURL createPopupUrl(String viewId)
          Creates a URL capable of displaying a specified view Id in "Popup" mode.
abstract  javax.portlet.PortletURL createRenderURL()
          Retrieves a render URL for the current facesContext.
abstract  javax.portlet.ActionResponse getActionResponse()
          Retrieves the javax.portlet.ActionResponse object associated with the current JSF FacesContext.
abstract  long getCompanyId()
          Returns the company Id associated with the community that is hosting the portlet associated with the current JSF FacesContext.
abstract  String getDocumentLibraryURL()
          Returns an absolute URL to the Liferay document library, which is the main part of different struts action paths.
abstract  org.edorasframework.extfaces.context.ExtFacesContext getExtFacesContext()
           
abstract  javax.faces.context.FacesContext getFacesContext()
          Returns the current facesContext.
abstract  com.liferay.portal.model.User getGroupUser()
          Returns the user associated with the group (Liferay community) associated with the layout (portal page) that the portlet resides on.
abstract  long getHostGroupId()
          Returns the "group Id" associated with the community that is hosting the portlet associated with the current JSF FacesContext.
abstract  String getImageGalleryURL()
          Returns an absolute URL to the Liferay image gallery, which is the main part of different struts action paths.
static PortletFacesContext getInstance()
          Returns the implementation singleton instance.
abstract  com.liferay.portal.model.Layout getLayout()
          Returns the layout being displayed in the current context.
abstract  org.edorasframework.liferayadapter.ServiceMap getLiferayServiceMap()
          Returns a Map of Liferay Services.
abstract  String getMessage(long companyId, Locale locale, String messageId)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified Liferay companyId and specified locale.
abstract  String getMessage(long companyId, Locale locale, String messageId, Object... arguments)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified Liferay companyId, and specified locale and arguments that are to be substituted.
abstract  org.edorasframework.liferayadapter.PermissionCheckerWrapper getPermissionChecker()
          Returns the Liferay PermissionChecker associated with the request.
abstract  long getPlid()
          Returns the "Plid" (the "portal layout id"), which is the identifier of the specific "page" the portlet exists on.
abstract  javax.portlet.PortalContext getPortalContext()
          Retrieves the javax.portlet.PortalContext object associated with the current JSF FacesContext.
abstract  String getPortalURL()
          Returns an absolute URL which is the context-path of the portal webapp.
abstract  com.liferay.portal.model.Portlet getPortlet()
          Returns the com.liferay.portal.model.Portlet object for the portlet associated with the current request.
abstract  javax.portlet.PortletConfig getPortletConfig()
          Retrieves the javax.portlet.PortletConfig object associated with the current JSF FacesContext.
abstract  javax.portlet.PortletContext getPortletContext()
          Retrieves the javax.portlet.PortletContext object associated with the current JSF FacesContext.
abstract  String getPortletContextName()
          Retrieves the name of the portlet associated with the current JSF FacesContext (usually, its the name of the portlet .war)
abstract  String getPortletInstanceId()
          Returns the "portlet instance Id" of the currently running portlet.
abstract  String getPortletName()
          Retrieves the name of the portlet associated with the current JSF FacesContext (as defined in portlet.xml's <portlet-name> tag).
abstract  String getPortletNamespace()
          Returns a namespace prefix to be used for the portlet associated with the current JSF FacesContext instance.
abstract  Object getPortletPreference(String preferenceName, Object defaultValue)
          Returns String representation of the value of the portlet preference associated with the specified name in from the javax.portlet.PortletPreferences object associated with the current JSF FacesContext.
abstract  boolean getPortletPreferenceAsBool(String preferenceName, boolean defaultValue)
          Returns boolean representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.
abstract  int getPortletPreferenceAsInt(String preferenceName, int defaultValue)
          Returns integer representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.
abstract  short getPortletPreferenceAsShort(String preferenceName, short defaultValue)
          Returns short representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.
abstract  String getPortletPreferenceAsString(String preferenceName, String defaultValue)
          Returns short representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.
abstract  PortletPreferenceMap getPortletPreferenceMap()
          Returns the PortletPreferenceMap associated with the current JSF FacesContext.
abstract  javax.portlet.PortletPreferences getPortletPreferences()
          Retrieves the javax.portlet.PortletPreferences object associated with the current JSF FacesContext.
abstract  javax.portlet.RenderRequest getPortletRenderRequest()
          Retrieves the javax.portlet.RenderRequest object associated with the current JSF FacesContext.
abstract  javax.portlet.RenderResponse getPortletRenderResponse()
          Retrieves the javax.portlet.RenderResponse object associated with the current JSF FacesContext.
abstract  javax.portlet.PortletRequest getPortletRequest()
          Retrieves the javax.portlet.PortletRequest object associated with the current JSF FacesContext.
abstract  javax.portlet.PortletResponse getPortletResponse()
          Retrieves the javax.portlet.PortletResponse object associated with the current JSF FacesContext.
abstract  String getPortletRootId()
          Returns the "portlet root Id" of the currently running portlet.
abstract  javax.portlet.PortletSession getPortletSession()
          Retrieves the javax.portlet.PortletSession object associated with the current JSF FacesContext.
abstract  String getRemoteUser()
          Returns the user name/id of the user associated with the current JSF FacesContext
abstract  org.edorasframework.liferayadapter.ServiceContext getServiceContext(String className)
          Returns an instance of a ServiceContext associated with the specified className.
abstract  Object getSessionSharedAttribute(String name)
          Returns the value of the session attribute associated with the specified name from PortletSession.APPLICATION_SCOPE
abstract  com.liferay.portal.model.Theme getTheme()
          Returns the theme being displayed in the current context.
abstract  org.edorasframework.liferayadapter.ThemeDisplayClone getThemeDisplay()
          Returns the com.liferay.portal.theme.ThemeDisplay object, which contains a variety methods for rendering theme specific look and feels.
abstract  String getThemeImagesURL()
          Returns an absolute URL which is the path to the images of the theme associated with the current Layout.
abstract  com.liferay.portal.model.User getUser()
          Returns the user record of the user associated with the current JSF FacesContext.
abstract  long getUserId()
          Returns the user Id of the user associated with the current JSF FacesContext
abstract  List<com.liferay.portal.model.Role> getUserRoles()
          Returns a list of all of the roles played by the user associated with the current JSF FacesContext.
abstract  javax.portlet.WindowState getWindowState()
          Returns the window state of the portlet associated with the current JSF FacesContext
abstract  boolean isUserInRole(String roleName)
          Returns TRUE if the current user is associated with the specified role.
abstract  boolean isWindowMaximized()
          Returns TRUE if the Window state of the current portlet is set to MAXIMIZED
abstract  boolean isWindowNormal()
          Returns TRUE if the Window state of the current portlet is set to MAXIMIZED
abstract  void postLifecycleCleanup()
          Performs cleanup operations that are intended to be performed after the JSF lifecycle executes.
static void setInstance(PortletFacesContext portletFacesContext)
          Sets the implementation singleton instance.
abstract  void setPortletMode(javax.portlet.PortletMode portletMode)
          Sets the portlet mode of the portlet associated with the current JSF FacesContext to the specified portlet mode.
abstract  void setSessionSharedAttribute(String name, Object value)
          Sets the value of the a session attribute using the specified name and value within PortletSession.APPLICATION_SCOPE
abstract  void setWindowState(javax.portlet.WindowState windowState)
          Sets the window state of the portlet associated with the current JSF FacesContext to the specified window state.
abstract  void setWindowStateToMaximized()
          A short-cut method for calling setWindowState(WindowState.MAXIMIZED)
abstract  void setWindowStateToNormal()
          A short-cut method for calling setWindowState(WindowState.NORMAL)
abstract  boolean userHasPortletPermission(String actionId)
          Returns TRUE if the current user has permission to execute the specified actionId (which, in turn, is assumed to be an action defined for the current portlet).
abstract  boolean userHasRole(String roleName)
          Returns TRUE if the current user has the specified role name.
 
Methods inherited from class org.edorasframework.extfaces.context.ExtFacesContext
addComponentErrorMessage, addComponentErrorMessage, addComponentErrorMessage, addComponentInfoMessage, addComponentInfoMessage, addComponentInfoMessage, addGlobalErrorMessage, addGlobalErrorMessage, addGlobalErrorMessage, addGlobalInfoMessage, addGlobalInfoMessage, addGlobalInfoMessage, addMessage, addMessage, addMessage, getLocale, getMessage, getMessage, getMessage, getMessage, getParentForm, getRequestAttribute, getRequestContextPath, getRequestParameter, getRequestParameterAsBool, getRequestParameterAsInt, getRequestParameterAsLong, getRequestParameterFromMap, getRequestQueryString, getRequestQueryStringParameter, getSession, getSessionAttribute, getUploadedFilesMap, matchComponentInHierarchy, matchComponentInViewRoot, navigate, navigateTo, recreateComponentTree, registerPhaseListener, removeChildrenFromComponentTree, removeMessages, removeMessagesForImmediateComponents, removeMessagesForImmediateComponents, removeParentFormFromComponentTree, resetView, resetView, resolveExpression, setInstance, setRequestAttribute, setSessionAttribute
 
Methods inherited from class javax.faces.context.FacesContext
addMessage, getApplication, getClientIdsWithMessages, getCurrentInstance, getELContext, getExternalContext, getMaximumSeverity, getMessages, getMessages, getRenderKit, getRenderResponse, getResponseComplete, getResponseStream, getResponseWriter, getViewRoot, release, renderResponse, responseComplete, setCurrentInstance, setResponseStream, setResponseWriter, setViewRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletFacesContext

public PortletFacesContext()
Method Detail

addGlobalUnexpectedErrorMessage

public abstract void addGlobalUnexpectedErrorMessage()
Adds a global error message to the current FacesContext with the standard Liferay "an-unexpected-error-occurred" key as the messageId.


addGlobalSuccessInfoMessage

public abstract void addGlobalSuccessInfoMessage()
Adds a global information message to the current FacesContext with the standard Liferay "your-request-processed-successfully" key as the messageId.


createActionURL

public abstract javax.portlet.PortletURL createActionURL()
Retrieves a render URL for the current facesContext.


createRenderURL

public abstract javax.portlet.PortletURL createRenderURL()
Retrieves a render URL for the current facesContext.


getActionResponse

public abstract javax.portlet.ActionResponse getActionResponse()
Retrieves the javax.portlet.ActionResponse object associated with the current JSF FacesContext.


getExtFacesContext

public abstract org.edorasframework.extfaces.context.ExtFacesContext getExtFacesContext()

getFacesContext

public abstract javax.faces.context.FacesContext getFacesContext()
Returns the current facesContext.

Specified by:
getFacesContext in class org.edorasframework.extfaces.context.ExtFacesContext

getMessage

public abstract String getMessage(long companyId,
                                  Locale locale,
                                  String messageId)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified Liferay companyId and specified locale.


getMessage

public abstract String getMessage(long companyId,
                                  Locale locale,
                                  String messageId,
                                  Object... arguments)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified Liferay companyId, and specified locale and arguments that are to be substituted.


getPortalContext

public abstract javax.portlet.PortalContext getPortalContext()
Retrieves the javax.portlet.PortalContext object associated with the current JSF FacesContext.


getPortletConfig

public abstract javax.portlet.PortletConfig getPortletConfig()
Retrieves the javax.portlet.PortletConfig object associated with the current JSF FacesContext.


getPortletContext

public abstract javax.portlet.PortletContext getPortletContext()
Retrieves the javax.portlet.PortletContext object associated with the current JSF FacesContext.


getPortletContextName

public abstract String getPortletContextName()
Retrieves the name of the portlet associated with the current JSF FacesContext (usually, its the name of the portlet .war)


setPortletMode

public abstract void setPortletMode(javax.portlet.PortletMode portletMode)
Sets the portlet mode of the portlet associated with the current JSF FacesContext to the specified portlet mode.


getPortletName

public abstract String getPortletName()
Retrieves the name of the portlet associated with the current JSF FacesContext (as defined in portlet.xml's <portlet-name> tag).


getPortletNamespace

public abstract String getPortletNamespace()
Returns a namespace prefix to be used for the portlet associated with the current JSF FacesContext instance. The namespace can be prefixed or suffixed to any control Id or Javascript variable to insure it is unique for the portlet instance on the page.


getPortletPreference

public abstract Object getPortletPreference(String preferenceName,
                                            Object defaultValue)
Returns String representation of the value of the portlet preference associated with the specified name in from the javax.portlet.PortletPreferences object associated with the current JSF FacesContext.


getPortletPreferenceAsBool

public abstract boolean getPortletPreferenceAsBool(String preferenceName,
                                                   boolean defaultValue)
Returns boolean representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.


getPortletPreferenceAsInt

public abstract int getPortletPreferenceAsInt(String preferenceName,
                                              int defaultValue)
Returns integer representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.


getPortletPreferenceAsShort

public abstract short getPortletPreferenceAsShort(String preferenceName,
                                                  short defaultValue)
Returns short representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.


getPortletPreferenceAsString

public abstract String getPortletPreferenceAsString(String preferenceName,
                                                    String defaultValue)
Returns short representation of the value of the portlet preference associated with the specified name in from the PortletPreferenceMap object associated with the current JSF FacesContext.


getPortletPreferenceMap

public abstract PortletPreferenceMap getPortletPreferenceMap()
Returns the PortletPreferenceMap associated with the current JSF FacesContext.


getPortletPreferences

public abstract javax.portlet.PortletPreferences getPortletPreferences()
Retrieves the javax.portlet.PortletPreferences object associated with the current JSF FacesContext.


getPortletRenderRequest

public abstract javax.portlet.RenderRequest getPortletRenderRequest()
Retrieves the javax.portlet.RenderRequest object associated with the current JSF FacesContext.


getPortletRenderResponse

public abstract javax.portlet.RenderResponse getPortletRenderResponse()
Retrieves the javax.portlet.RenderResponse object associated with the current JSF FacesContext.


getPortletRequest

public abstract javax.portlet.PortletRequest getPortletRequest()
Retrieves the javax.portlet.PortletRequest object associated with the current JSF FacesContext.


getPortletResponse

public abstract javax.portlet.PortletResponse getPortletResponse()
Retrieves the javax.portlet.PortletResponse object associated with the current JSF FacesContext.


getPortletSession

public abstract javax.portlet.PortletSession getPortletSession()
Retrieves the javax.portlet.PortletSession object associated with the current JSF FacesContext.


getRemoteUser

public abstract String getRemoteUser()
Returns the user name/id of the user associated with the current JSF FacesContext


getSessionSharedAttribute

public abstract Object getSessionSharedAttribute(String name)
Returns the value of the session attribute associated with the specified name from PortletSession.APPLICATION_SCOPE


setSessionSharedAttribute

public abstract void setSessionSharedAttribute(String name,
                                               Object value)
Sets the value of the a session attribute using the specified name and value within PortletSession.APPLICATION_SCOPE


isUserInRole

public abstract boolean isUserInRole(String roleName)
Returns TRUE if the current user is associated with the specified role.


isWindowMaximized

public abstract boolean isWindowMaximized()
Returns TRUE if the Window state of the current portlet is set to MAXIMIZED


isWindowNormal

public abstract boolean isWindowNormal()
Returns TRUE if the Window state of the current portlet is set to MAXIMIZED


getWindowState

public abstract javax.portlet.WindowState getWindowState()
Returns the window state of the portlet associated with the current JSF FacesContext


setWindowState

public abstract void setWindowState(javax.portlet.WindowState windowState)
Sets the window state of the portlet associated with the current JSF FacesContext to the specified window state.


setWindowStateToMaximized

public abstract void setWindowStateToMaximized()
A short-cut method for calling setWindowState(WindowState.MAXIMIZED)


setWindowStateToNormal

public abstract void setWindowStateToNormal()
A short-cut method for calling setWindowState(WindowState.NORMAL)


checkUserPortletPermission

public abstract void checkUserPortletPermission(String actionId)
                                         throws AuthorizationException
Checks to see if the current user has permission to execute the specified actionId (which, in turn, is assumed to be an action defined for the current portlet). If the authorization fails, a PrincipalException is thrown. Any other errors that occur will be caught and re-thrown, wrapped in a PortletRuntimeException.

Parameters:
actionId -
Throws:
AuthorizationException
See Also:
userHasPortletPermission(String)

createPopupUrl

public abstract javax.portlet.PortletURL createPopupUrl(String viewId)
Creates a URL capable of displaying a specified view Id in "Popup" mode.


userHasPortletPermission

public abstract boolean userHasPortletPermission(String actionId)
Returns TRUE if the current user has permission to execute the specified actionId (which, in turn, is assumed to be an action defined for the current portlet). Any errors that occur will be caught and re-thrown, wrapped in a PortletRuntimeException.

Parameters:
actionId -
See Also:
checkUserPortletPermission(String)

userHasRole

public abstract boolean userHasRole(String roleName)
Returns TRUE if the current user has the specified role name.


postLifecycleCleanup

public abstract void postLifecycleCleanup()
Performs cleanup operations that are intended to be performed after the JSF lifecycle executes. Meant to be called in the afterPhase method of a JSF phase listener once the RENDER_RESPONSE phase is complete.


getCompanyId

public abstract long getCompanyId()
Returns the company Id associated with the community that is hosting the portlet associated with the current JSF FacesContext.


getDocumentLibraryURL

public abstract String getDocumentLibraryURL()
Returns an absolute URL to the Liferay document library, which is the main part of different struts action paths.


getGroupUser

public abstract com.liferay.portal.model.User getGroupUser()
Returns the user associated with the group (Liferay community) associated with the layout (portal page) that the portlet resides on.


getHostGroupId

public abstract long getHostGroupId()
Returns the "group Id" associated with the community that is hosting the portlet associated with the current JSF FacesContext.


getImageGalleryURL

public abstract String getImageGalleryURL()
Returns an absolute URL to the Liferay image gallery, which is the main part of different struts action paths.


getLayout

public abstract com.liferay.portal.model.Layout getLayout()
Returns the layout being displayed in the current context.


getLiferayServiceMap

public abstract org.edorasframework.liferayadapter.ServiceMap getLiferayServiceMap()
Returns a Map of Liferay Services.


getPermissionChecker

public abstract org.edorasframework.liferayadapter.PermissionCheckerWrapper getPermissionChecker()
Returns the Liferay PermissionChecker associated with the request.


getPlid

public abstract long getPlid()
Returns the "Plid" (the "portal layout id"), which is the identifier of the specific "page" the portlet exists on. Plid is the primary key of the "Layout" table.


getPortalURL

public abstract String getPortalURL()
Returns an absolute URL which is the context-path of the portal webapp.


getPortlet

public abstract com.liferay.portal.model.Portlet getPortlet()
Returns the com.liferay.portal.model.Portlet object for the portlet associated with the current request.


getPortletInstanceId

public abstract String getPortletInstanceId()
Returns the "portlet instance Id" of the currently running portlet. This id is an internal identifier used by the Liferay API. Note that the Liferay API for getPorletId() is not exposed as getPortletId() in the PortletFaces API -- instead it is exposed as getPortletInstanceId(). This is because the Liferay API getPortletId() actually returns the "instance id" of the portlet, whereas most of the time developers really want the "root id" instead.

See Also:
getPortletName()

getPortletRootId

public abstract String getPortletRootId()
Returns the "portlet root Id" of the currently running portlet. This id is an internal identifier used by the Liferay API. Note that the Liferay API for getPorletId() is not exposed as getPortletId() in the PortletFaces API -- instead it is exposed as getPortletInstanceId(). This is because the Liferay API getPortletId() actually returns the "instance id" of the portlet, whereas most of the time developers really want the "root id" instead.

See Also:
getPortletName()

getTheme

public abstract com.liferay.portal.model.Theme getTheme()
Returns the theme being displayed in the current context.


getThemeDisplay

public abstract org.edorasframework.liferayadapter.ThemeDisplayClone getThemeDisplay()
Returns the com.liferay.portal.theme.ThemeDisplay object, which contains a variety methods for rendering theme specific look and feels.


getThemeImagesURL

public abstract String getThemeImagesURL()
Returns an absolute URL which is the path to the images of the theme associated with the current Layout.


getUser

public abstract com.liferay.portal.model.User getUser()
Returns the user record of the user associated with the current JSF FacesContext.


getUserId

public abstract long getUserId()
Returns the user Id of the user associated with the current JSF FacesContext


getServiceContext

public abstract org.edorasframework.liferayadapter.ServiceContext getServiceContext(String className)
Returns an instance of a ServiceContext associated with the specified className.


getUserRoles

public abstract List<com.liferay.portal.model.Role> getUserRoles()
Returns a list of all of the roles played by the user associated with the current JSF FacesContext.


getInstance

public static PortletFacesContext getInstance()
Returns the implementation singleton instance.


setInstance

public static void setInstance(PortletFacesContext portletFacesContext)
Sets the implementation singleton instance. Only required if an IOC container like Spring is used.



Copyright 2009, http://www.edorasframework.org