0%

liferay-theme defineObjects

在jsp中添加<liferay-theme:defineObjects />之后,可以使用的对象。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ThemeDisplay themeDisplay
Company company
Account account
User user
User realUser
Contact contact
Layout layout
List<Layout> layouts
long plid
LayoutTypePortlet layoutTypePortlet
long scopeGroupId
PermissionChecker permissionChecker
Locale locale
TimeZone timeZone
Theme theme
ColorScheme colorScheme
PortletDisplay portletDisplay
long portletGroupId

其核心就只有themeDisplay,其余都是通过themeDisplay获得的。以下为DefineObjectsTag.java部分源码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@Override
public int doStartTag() {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

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

if (themeDisplay != null) {
pageContext.setAttribute("themeDisplay", themeDisplay);
pageContext.setAttribute("company", themeDisplay.getCompany());
pageContext.setAttribute("account", themeDisplay.getAccount());
pageContext.setAttribute("user", themeDisplay.getUser());
pageContext.setAttribute("realUser", themeDisplay.getRealUser());
pageContext.setAttribute("contact", themeDisplay.getContact());

if (themeDisplay.getLayout() != null) {
pageContext.setAttribute("layout", themeDisplay.getLayout());
}

if (themeDisplay.getLayouts() != null) {
pageContext.setAttribute("layouts", themeDisplay.getLayouts());
}

pageContext.setAttribute("plid", new Long(themeDisplay.getPlid()));

if (themeDisplay.getLayoutTypePortlet() != null) {
pageContext.setAttribute("layoutTypePortlet", themeDisplay.getLayoutTypePortlet());
}

pageContext.setAttribute("scopeGroupId", new Long(themeDisplay.getScopeGroupId()));
pageContext.setAttribute("permissionChecker", themeDisplay.getPermissionChecker());
pageContext.setAttribute("locale", themeDisplay.getLocale());
pageContext.setAttribute("timeZone", themeDisplay.getTimeZone());
pageContext.setAttribute("theme", themeDisplay.getTheme());
pageContext.setAttribute("colorScheme", themeDisplay.getColorScheme());
pageContext.setAttribute("portletDisplay", themeDisplay.getPortletDisplay());

// Deprecated

pageContext.setAttribute("portletGroupId", new Long(themeDisplay.getScopeGroupId()));
}

return SKIP_BODY;
}

参考文献

  1. Portlet:DefineObjects tag in jsp
  2. liferay 在jsp中直接使用的对象

EOF