UI Taglib

The Liferay UI Taglib #

This is an unfinished attempt to document Liferay 5.2's UI taglib for JSP developers. I haven't found any current and extensive information about it, so I'm learning it the hard way. Any insight and additions from more skilled developers highly appreciated!

For introductory taglib reference, install the liferay-ui-taglib-demo-portlet from the community plugins. This provides editable examples for tags including user-display, Breadcrumb, calendar, captcha, icon and toggle-area. For complete information about taglibs, browse or search in the com.liferay.taglib.ui package under util-taglibs/src in the Liferay source code.

Developer background #

Check out Liferay Core Development Guidelines, especially Liferay UI Guidelines. Also interesting might be Introduction to Liferay for new developers, but this is mostly outdated.

UI setup #

The Liferay UI taglib contains custom user interface tags, e.g. for error reporting or i18n.

If you have the Liferay source download, the taglib definition is located in /util-taglib/src/META-INF/liferay-ui.tld. The java classes are in /util-taglib/src/com/liferay/taglib/ui, and the JSP fragments are in portal-web/docroot/html/taglib/ui

See also the Liferay wiki page "How to search for a taglib's code" for more information.

To use UI, add this import line into your JSP:

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

API reference #

error #

"error" shows user feedback if something went wrong. It is shown in the portlet, using the "portlet-msg-error" CSS class. Per default, this renders a red box with the error message.

Displaying the error requires (at least) two steps

  1. indicate that an error should be displayed using

com.liferay.portal.kernel.servlet.SessionErrors.add(PortletRequest portletRequest, String key)

  1. display a relevant message for this key on the JSP using

<liferay-ui:error message="message" key="key"/>

example

<%
	SessionErrors.add(renderRequest, "key");
%>

<liferay-ui:error message="this-is-an-error" key="key" />

key must be unique. There seem to be another way of displaying errors directly from an Exception. The syntax is

<liferay-ui:error exception="<%= Exception.class %>" message="message" />

, but I haven't gotten this to work.

message #

"message" displays a localized message for a key. The key can be one of the predefined keys from Liferay (see Language_xx.properties in /portal-impl/src/content), or a custom key introduced with a hook. The translation does not support formatting, i.e. you cannot add HTML into the Language_xx.properties file.

example

<liferay-ui:message key="no" />

will print "no" translated to your selected language. Some more information on i18n in Liferay

tags-summary #

this tag displays tag and/or category information for web content.

parameters:

  • className = name of class of resource to retrieve tags for
  • classPK = resource primary key
  • folksonomy (optional): true = show user created tags as well as categories, false = show only categories. default is false

example:

<liferay-ui:tags-summary 
   className="<%= JournalArticle.class.getName() %>" 
   classPK="<%=article.getResourcePrimKey()%>" 
   folksonomy="false" />

journal-article #

this tag displays a journal article using the template defined by the user.

parameters:

  • articleId = uniqueID of content article
  • groupId = group of user
  • showTitle = show title of article true or false
  • templateId = which of the defined templates for this journal article to use. Note that there is a bug (reported here) in liferay versions before 6.0.2 where templateId is ignored.

example:

<liferay-ui:journal-article 
  articleId="<%=menuIdString%>" 
  groupId="<%=groupId%>" />

breadcrumb #

This tag displays a series of links representing page hierarchy. It will display links or text depending on the displayStyle parameter. It does not display user navigation history. parameters:

  • displayStyle: 1 = links to pages in child-parent hierarchy. 2 = text but no links
  • portletURL:
  • selLayout:

example:

<liferay-ui:breadcrumb portletURL="<%=portletURL%>" selLayout="<%=selLayout%>" displayStyle="<%=displayStyle%>" />

tabs #

this tag displays a set of DHTML tabs.

example:

<liferay-ui:tabs 
     names="Welcome,Breadcrumb,Calendar,Captcha,Panel,Table,Icon,Input" 
     tabsValues="welcome,breadcrumb,calendar,captcha,panel,table,icon,input" 
     param="tab" 
     url="<%= portletURL %>"
/>

ratings #

see Adding Rating to a portlet

Related documents #

0 Allegati
152352 Visualizzazioni
Media (11 Voti)
La media del punteggio è 2.63636363636364 stelle su 5.
Commenti
Commenti Autore Data
It is mostly incomplete, the link to aui is... Jaber C. Mourad 20 aprile 2010 3.05
Hi, I want to set an error message in an... Puj Z 27 aprile 2010 10.03
http://issues.liferay.com/browse/LPS-12402 Denis Signoretto 22 settembre 2010 2.54
What is the way to create my own personalized... David Millán 4 maggio 2010 9.11
Hey All, I just committed (r53825) an ant task... Raymond Augé 25 maggio 2010 20.08
is there a alloy ui components for jsf(1 or 2) ... arron wu 7 luglio 2010 18.57
I means the jsf component for facletes! arron wu 7 luglio 2010 18.59
I think it is very difficult to document all... David García González 17 marzo 2011 8.13

It is mostly incomplete, the link to aui is broken...
Inviato il 20/04/10 3.05.
Hi,

I want to set an error message in an action class.
This means I have access to ActionRequest. However, I believe we need RenderRequest for SessionErrors.add(req, "errorMessage", "my error")

When I use the ActionRequest for adding the error, the tag with "errorMessage" will be activated indeed, but the message is not shown properly. It is always a general error message from Liferay. Do you know what to do?
How can I get RenderRequest from ActionRequest or somehow pass the value?
I really appreciate any helps.
Inviato il 27/04/10 10.03.
What is the way to create my own personalized ui taglib?
Inviato il 04/05/10 9.11.
Hey All, I just committed (r53825) an ant task to generate the taglib docs along with the javadoc, and although it's pretty bare right now, it's a step in the right direction. At least you get a list of available attributes and a full list of tags to at least see what's available.

And please, if you wanted to contribute to that aspect of the documentation, we'd surely appreciate it.
Inviato il 25/05/10 20.08.
is there a alloy ui components for jsf(1 or 2) plan?
I develop components suite on extjs base on jsf1.2 and 2.0!
I want to know the alloy ui can run on jsf?
Inviato il 07/07/10 18.57.
I means the jsf component for facletes!
Inviato il 07/07/10 18.59 in risposta a arron wu.
http://issues.liferay.com/browse/LPS-12402
Inviato il 22/09/10 2.54 in risposta a Puj Z.
I think it is very difficult to document all the tags. The best way to start is looking the source code, inside the project util-taglibs/src and looking the source code of the demo portlet liferay-ui-taglib-demo-portlet.
Inviato il 17/03/11 8.13.