public final class PortletUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addErrorMessageToContext(java.lang.String errorId,
java.lang.Object... params)
Adds the error message to context.
|
static void |
addErrorMessageToContext(java.lang.String id,
java.lang.String errorId,
java.lang.Object... params)
Adds the error message to context.
|
static <A extends javax.faces.component.UIComponent> |
findUIComponent(javax.faces.component.UIComponent rootComponent,
java.lang.Class<A> clazz)
Get a specific UIComponent.
|
static <A extends javax.faces.component.UIComponent> |
findUIComponent(javax.faces.component.UIComponent rootComponent,
java.lang.Class<A> clazz,
java.lang.String id)
Get a specific UIComponent.
|
static void |
forward(java.lang.String jspx)
Forward to a jspx page.
|
static javax.faces.application.Application |
getApplication()
Gets the context of the Liferay FacesContext.
|
static long |
getCompanyId()
Gets the company id.
|
static org.tencompetence.generated.model.CompetenceMap |
getCompetenceMapByCurrentCommunity()
Gets the competence map by current community.
|
static javax.faces.context.FacesContext |
getContext()
Gets the context of the Liferay FacesContext.
|
static long |
getCurrentUserId()
Returns the userid of the user that is currently loggedIn.
|
static long |
getGroupId()
Gets the group id of the Liferay ThemeDisplay.
|
static java.lang.String |
getLiferayPortletId()
Gets the liferay portlet id.
|
static <T> T |
getManagedBean(java.lang.String managedBeanName,
java.lang.Class<T> clazz)
Returns a managed bean of the specified type and the specified name.
|
static java.lang.Object |
getObjectFromSession(java.lang.String key)
Gets the object from session.
|
static <T> T |
getObjectFromSession(java.lang.String key,
T defaultValue)
Gets the object from session.
|
static javax.portlet.PortletConfig |
getPortletConfig()
Gets the portlet config.
|
static java.lang.String |
getPortletId()
Gets the portlet id.
|
static javax.portlet.PortletRequest |
getPortletRequest()
Gets the portlet request.
|
static javax.portlet.RenderRequest |
getRenderRequest()
Get the RenderRequest from context.
|
static javax.portlet.RenderResponse |
getRenderResponse()
Get the RenderResponse from context.
|
static com.liferay.portal.service.ServiceContext |
getServiceContext()
Get the ServiceContext from the portletRequest.
|
static <T> com.liferay.portal.service.ServiceContext |
getServiceContext(com.liferay.portal.model.BaseModel<T> entity)
Get the ServiceContext from the portletRequest for a specific entity.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getSessionMap()
Gets the request map of Liferay.
|
static com.liferay.portal.theme.ThemeDisplay |
getThemeDisplay()
Gets the Liferay theme display.
|
static java.lang.String |
getViewId()
Get the current viewId.
|
static void |
handleError(com.liferay.portal.kernel.log.Log log,
java.lang.Exception e)
Handle an error.
|
static void |
handleNavigation(java.lang.String outcome)
navigate to other view.
|
static java.lang.String |
normalizeLineBreak(java.lang.String input)
Normalize line break.
|
static void |
redirect(java.lang.String url)
Let the page redirect to the url.
|
static void |
resetObjectOnSession(java.lang.String key)
Sets the object to session.
|
static void |
setObjectToSession(java.lang.String key,
java.lang.Object value)
Sets the object to session.
|
static void |
setOwnership(com.liferay.portal.model.BaseModel<?> entity,
com.liferay.portal.service.ServiceContext ctx)
SetOwnership.
|
static long[] |
toLongArray(java.util.List<java.lang.Long> listIn)
Converts an List <Long> to an array of long[].
|
public static long getGroupId()
public static javax.faces.context.FacesContext getContext()
public static javax.faces.application.Application getApplication()
public static void handleNavigation(java.lang.String outcome)
outcome
- the url to navigate topublic static com.liferay.portal.theme.ThemeDisplay getThemeDisplay()
public static java.util.Map<java.lang.String,java.lang.Object> getSessionMap()
public static <T> T getObjectFromSession(java.lang.String key, T defaultValue)
T
- Generickey
- the keydefaultValue
- the default valuepublic static java.lang.Object getObjectFromSession(java.lang.String key)
key
- the keypublic static void setObjectToSession(java.lang.String key, java.lang.Object value)
key
- the keyvalue
- the valuepublic static void resetObjectOnSession(java.lang.String key)
key
- the keypublic static javax.portlet.PortletConfig getPortletConfig()
public static javax.portlet.PortletRequest getPortletRequest()
public static java.lang.String getPortletId()
public static java.lang.String getLiferayPortletId()
public static long getCompanyId()
public static void addErrorMessageToContext(java.lang.String id, java.lang.String errorId, java.lang.Object... params)
id
- the id of the errormessage, the portletId and form etc should be included. e.g. private String
CompetenceLevelsWarningId = PortletUtils.getPortletId()+
":form:levelValuesTab:0:competencelevelEditButton";errorId
- id of the errormessage defined in the Language.propertiesparams
- params used in the error message defined as {0}. {1} etcpublic static void addErrorMessageToContext(java.lang.String errorId, java.lang.Object... params)
errorId
- id of the errormessage defined in the Language.propertiesparams
- params used in the error message defined as {0}. {1} etcpublic static void handleError(com.liferay.portal.kernel.log.Log log, java.lang.Exception e)
log
- the liferay log that should be used to handle the errore
- the error e which should be handledpublic static <T> T getManagedBean(java.lang.String managedBeanName, java.lang.Class<T> clazz)
T
- generic parammanagedBeanName
- the name of the managed bean to look upclazz
- expected type of the managed beanpublic static long[] toLongArray(java.util.List<java.lang.Long> listIn)
listIn
- the list inpublic static java.lang.String normalizeLineBreak(java.lang.String input)
input
- the inputpublic static javax.portlet.RenderResponse getRenderResponse()
public static javax.portlet.RenderRequest getRenderRequest()
public static <A extends javax.faces.component.UIComponent> A findUIComponent(javax.faces.component.UIComponent rootComponent, java.lang.Class<A> clazz)
public static <A extends javax.faces.component.UIComponent> A findUIComponent(javax.faces.component.UIComponent rootComponent, java.lang.Class<A> clazz, java.lang.String id)
A
- Generic return typerootComponent
- the root componentclazz
- the class to findid
- the id of the componentpublic static org.tencompetence.generated.model.CompetenceMap getCompetenceMapByCurrentCommunity()
public static java.lang.String getViewId()
public static void redirect(java.lang.String url)
url
- the url to redirect topublic static void setOwnership(com.liferay.portal.model.BaseModel<?> entity, com.liferay.portal.service.ServiceContext ctx) throws com.liferay.portal.kernel.exception.SystemException
entity
- BaseModel> Entityctx
- ServiceContextcom.liferay.portal.kernel.exception.SystemException
- SystemExceptionpublic static com.liferay.portal.service.ServiceContext getServiceContext() throws com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException
com.liferay.portal.kernel.exception.SystemException
- SystemExceptioncom.liferay.portal.kernel.exception.PortalException
- PortalExceptionpublic static <T> com.liferay.portal.service.ServiceContext getServiceContext(com.liferay.portal.model.BaseModel<T> entity) throws com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException
T
- Generic typeentity
- The entitycom.liferay.portal.kernel.exception.SystemException
- SystemExceptioncom.liferay.portal.kernel.exception.PortalException
- PortalExceptionpublic static long getCurrentUserId()
public static void forward(java.lang.String jspx)
jspx
- the jspx