Skip to main content

Liferay DWR Integration issues and solution

DWR classes doesn't have access to Liferay request and session attributes.

i.e. inside dwr classes this won't work
PortalUtil.getUser(req) --- return null

Also sharing themeDisplay object using post login hook won't work.. since postlogin-hook's session data is not shared with other portlet applications

One way to access themeDisplay object inside DWR classes is do this..
Add these lines to doView()..

ThemeDisplay themeDisplay = (ThemeDisplay)
request.getAttribute(WebKeys.THEME_DISPLAY);
request.getPortletSession().setAttribute("themeDisplay", themeDisplay, PortletSession.APPLICATION_SCOPE);

and inside DWR class access like this

public void test(HttpSession session) {
ThemeDisplay themeDisplay = (ThemeDisplay) session.getAttribute("themeDisplay");
logger.trace(" community name :" + themeDisplay.getScopeGroupName());
}

Comments

Solsticiu said…
Thank you very much. That was what I was searching.
Anonymous said…
Hello, How do I get in touch with you? There is no email or contact info listed .. please advise .. thanks .. Mary. Please contact me maryregency at gmail dot com
Anonymous said…
This comment has been removed by the author.
You can reach me at mdshannan@gmail.com