Liferay 6: Where is created ThemeDisplay?

In Liferay the object “ThemeDisplay” is kind of a god-object, it contains a lot of fields/methods that might be useful all around the portal.

All the data provided by this object is not especially related to Liferay themes, so if you are looking for a specific piece of data you should at least give a look to that object. You might find what you want in it.

Init of the ThemeDisplay instance

It could be useful to know how this god-object is generated, all the source code is available in the class com.liferay.portal.events.ServicePreAction, method initThemeDisplay.

ThemeDisplay in JSP

<liferay-theme:defineObjects />
<% 
themeDisplay.getUserId();
%>

(source of the tag: com.liferay.taglib.theme.DefineObjectsTag)

ThemeDisplay in Java controller

ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
            WebKeys.THEME_DISPLAY);

ThemeDisplay in Velocity (VM)

$themeDisplay.getUserId()

(added in Velocity context from this class: com.liferay.portal.velocity.VelocityVariablesImpl)

ThemeDisplay in Freemarker (FTL)

themeDisplay.getUserId()

(added in Freemarker context from this class: com.liferay.portal.freemarker.FreeMarkerVariablesImpl)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s