Note: Liferay Portal has three types of resources, each having associated permissions:

  1. Portlet Resource: Permissions associated with the UI of the portlet, such as permission to VIEW the portlet.
  2. Top-Level Model Resource: Permissions associated with the database entity itself, such as permission to ADD a row.
  3. Row-Level Model Resource: Permissions associated with individual rows of the database entity, such as permission to UPDATE a row.


PermissionsURL is a UIOutput component that generates a URL pointing to the Liferay Portal Permissions UI. If the var attribute is present, the component introduces a variable into the EL. Otherwise, the URL is written to the response.

Geral Usage

Access the Portlet Resource Permissions by specifying the primary key of a portlet via the resourcePrimKey attribute, and optionally specifying roleTypes in order to control which roles are displayed in the Liferay Portal Permissions UI.

Código fonte

<ui:composition xmlns="" xmlns:h=""
	xmlns:portal="" xmlns:ui="">

	<!-- Example 1: Introducing a var into the EL with default role types (Guest, Owner, Power User, Site Member, User) -->
	<portal:permissionsURL resourcePrimKey="#{permissionsURLModelBean.portletResourcePrimaryKey}" var="permissionsURL1" />
	<h:panelGroup rendered="#{liferay.userHasPortletPermission['PERMISSIONS']}">
		<a href="#{permissionsURL1}">#{i18n['permissions']}</a>

	<!-- Example 2: Output directly to the response with specific role types (Guest, Owner, Power User, User) -->
		<portal:permissionsURL resourcePrimKey="#{permissionsURLModelBean.portletResourcePrimaryKey}"
			roleTypes="#{permissionsURLModelBean.roleConstants.TYPES_REGULAR}" />
	<portal:permissionsURL resourcePrimKey="#{permissionsURLModelBean.portletResourcePrimaryKey}"
		roleTypes="#{permissionsURLModelBean.roleConstants.TYPES_REGULAR}" var="permissionsURL2" />
	<h:panelGroup rendered="#{liferay.userHasPortletPermission['PERMISSIONS']}">
		<a href="#{permissionsURL2}">#{i18n['permissions']}</a>

public class PermissionsURLModelBean {

	// Private Data Members
	private String portletResourcePrimaryKey;
	private Map<String, Object> roleConstants;

	public String getPortletResourcePrimaryKey() {

		if (portletResourcePrimaryKey == null) {
			FacesContext facesContext = FacesContext.getCurrentInstance();
			long plid = LiferayPortletHelperUtil.getPlid(facesContext);
			Portlet portlet = LiferayPortletHelperUtil.getPortlet(facesContext);
			String portletId = portlet.getPortletId();
			portletResourcePrimaryKey = PortletPermissionUtil.getPrimaryKey(plid, portletId);

		return portletResourcePrimaryKey;

	public Map<String, Object> getRoleConstants() {

		if (roleConstants == null) {

			roleConstants = new HashMap<String, Object>();

			Field[] fields = RoleConstants.class.getFields();

			for (Field field : fields) {
				int modifiers = field.getModifiers();

				if (Modifier.isStatic(modifiers)) {

					try {
						roleConstants.put(field.getName(), field.get(null));
					catch (IllegalAccessException e) {
						// ignore


		return roleConstants;
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20