
PortletDisplay.java
Table of Contents [-]
Introduction #
If you ever wanted to get a portlet's information from within a portlet, the class com.liferay.portal.theme.PortletDisplay can help out. This becomes a nifty tool for debugging, testing, or configuring portlet settings for a particular portlet.
Sample Methods#
setTitle(String title) //sets the portlet's title setShowCloseIcon(boolean showCloseIcon) //hides and displays the close button getId() //get portlet's id (includes instance Id if portlet is "instanceable") getRootPortletId() //gets portlet id only (does not include instance Id)
Usage#
PortletDisplay is used extensively in render_portlet.jsp, which is the template jsp for all out of the box Liferay portlets. You can extend the settings in render_portlet.jsp by using render_portlet.jsp. Alternatively, you could also use PortletDisplay directly in your portlet jsps.
For example, to change the URL to a portlet's "Return to Full Page" (when a portlet is in maximized windows state, there is a link on the upper right hand corner that takes you back) you can do this in your portlet's view.jsp:
<% portletDisplay.setURLBack("http://www.liferay.com"); %>
Now that specific portlet's "Return to Full Page" link is clicked, it will forward you to liferay.com. This is particularly useful when you are linking portlets between pages. For example you have Journal Content on Page ABC which has a link to a maximized state WebForm portlet on Page 123. By default, the WebForm portlet's "Return to Full Page" link will return you to a normal state Web Form portlet on Page 123. If I wanted the link to return you to Page ABC, I would utilize the getURLBack method.
Note: The above example will work if you've included <portlet:defineObjects />.