Pages

Search This Blog

Liferay

Available implicit objects Liferay JSP page
On a normal JSP page, some objects are implicitly available. In addition, we can get several others in Liferay
 using the taglibs. But we don't know all. So, lets become a technical James Bond and investigate about it. :D

Lets see about normal JSP first:
These objects are created by the container automatically and the container makes them available to us.
 Since these objects are created automatically by the container and are accessed using standard variables;
 and that is why, they are called implicit objects. They are parsed by the container. They are available only
 within the jspService method and not in any declaration.

These are 9 objects.
1
2
3
4
5
6
7
8
9
request        (javax.servlet.ServletRequest)
response       (javax.servlet.ServletResponse)
out            (javax.servlet.jsp.JspWriter)
pageContext    (javax.servlet.jsp.PageContext)
session        (javax.servlet.http.HttpS)
application    (javax.servlet.ServletContext)
config         (javax.servlet.ServletConfig)
page           (java.lang.Object)
exception      (java.lang.Throwable)

Now, lets ebter the liferay context:

The following statements  will give 14 default objects :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
 actionRequest                 (javax.portlet.ActionRequest)
actionResponse                (javax.portlet.ActionResponse)
eventRequest                  (javax.portlet.EventRequest)
eventResponse,                (javax.portlet.EventResponse)
portletConfig,                (javax.portlet.PortletConfig)
portletName,                  (java.lang.String portletName ;
portletPreferences,           (javax.portlet.PortletPreferences)
portletPreferencesValues,     (java.util.Map)
portletSession,               (javax.portlet.PortletSession)
portletSessionScope,          (java.util.Map)
renderRequest,                (javax.portlet.RenderRequest)
renderResponse,               (javax.portlet.RenderResponse)
resourceRequest,              (javax.portlet.ResourceRequest)
resourceResponse              (javax.portlet.ResourceResponse)


And the following statements will give 18 default objects :
1
2
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"
<liferay-theme:defineObjects />


and the type of each object as follows :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
themeDisplay             (com.liferay.portal.theme.ThemeDisplay)
company                  (com.liferay.portal.model.Company)
account                  (com.liferay.portal.model.Account)
user                     (com.liferay.portal.model.User)
realUser                 (com.liferay.portal.model.User)
contact                  (com.liferay.portal.model.Contact)
layout                   (com.liferay.portal.model.Layout)
layouts                  (java.util.List)
plid                     (java.lang.Long)
layoutTypePortlet        (com.liferay.portal.model.LayoutTypePortlet)
scopeGroupId             (java.lang.Long)
permissionChecker        (com.liferay.portal.security.permission.PermissionChecker)
locale                   (java.util.Locale)
timeZone                 (java.util.TimeZone)
theme                    (com.liferay.portal.model.Theme)
colorScheme              (com.liferay.portal.model.ColorScheme)
portletDisplay           (com.liferay.portal.theme.PortletDisplay)
portletGroupId           (java.lang.Long)


These default objects can be acquired using pageContext which is an implicit object of JSP.
 Use the following code for getting default objects


No comments:

Post a Comment