Foren

ThemeDisplay in hook action class is null

Alexandra Mereuta, geändert vor 13 Jahren.

ThemeDisplay in hook action class is null

New Member Beiträge: 3 Beitrittsdatum: 08.07.10 Neueste Beiträge
Hi,
I'm using Liferay 6.0.5 and I have a hook that overrides the login.events.post portal property. In my class that extends the Action class I want to get the themeDisplay and I do this in the run(HttpServletRequest request, HttpServletResponse response) method:
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);


The problem is ThemeDisplay attribute is not among the attributes of the request so the themeDisplay object is null. So what am I doing wrong and how can I get the themeDisplay?

Thanks
thumbnail
Armaz Mellati, geändert vor 13 Jahren.

RE: ThemeDisplay in hook action class is null

Junior Member Beiträge: 96 Beitrittsdatum: 30.10.09 Neueste Beiträge
I have the same issue. I am trying to change the DefaultLandingPageAction. However I can get the User object, but I need the themeDisplay too and I have no idea how to get it.

Hope someone has any idea on this.

Regards,
Armaz
thumbnail
Kim A Kunc, geändert vor 13 Jahren.

RE: ThemeDisplay in hook action class is null

Junior Member Beiträge: 37 Beitrittsdatum: 18.02.09 Neueste Beiträge
Armaz Mellati:
I have the same issue. I am trying to change the DefaultLandingPageAction. However I can get the User object, but I need the themeDisplay too and I have no idea how to get it.

Hope someone has any idea on this.

Regards,
Armaz



Hi Amaz,
I'm not sure if ThemeDisplay is set in the HTTPServletRequest.
What values in ThemeDisplay do you need ?
Have you tried reading it from the session ?

I'm using the "last path" param for my forwarding logic in DefaultLandingPageAction...

HttpSession session = request.getSession();
LastPath currentLastPath = (LastPath) session.getAttribute(WebKeys.LAST_PATH);
thumbnail
Minhchau Dang, geändert vor 13 Jahren.

RE: ThemeDisplay in hook action class is null

Liferay Master Beiträge: 598 Beitrittsdatum: 22.10.07 Neueste Beiträge
Alexandra Mereuta:
The problem is ThemeDisplay attribute is not among the attributes of the request so the themeDisplay object is null. So what am I doing wrong and how can I get the themeDisplay?

The ThemeDisplay object is initialized during service.pre which runs after login.post. Therefore, if you need a fully-populated ThemeDisplay object before that, you won't find it in the servlet request.

If you really need it, you'll need to do something funny like set request attributes and do something after the default Liferay service.pre events are processed (like in a ServicePostAction). If you just need a generic one to pass around to different function calls and the values don't matter, you can just call [tt]ThemeDisplayFactory.create()[/tt].
thumbnail
Jitendra Rajput, geändert vor 13 Jahren.

RE: ThemeDisplay in hook action class is null

Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
I think you can not get ThemeDisplay at the time of login.even.post.
if you wish you can get important parameter like "COMPANY_ID" ,"USER_ID" ,"CURRENT_URL"
by using httprequest.getAttribute("USER_ID")..
For the list of parameter available in http request use method httprequest.getAttributeNames() it will list parameter available in http request
thumbnail
Guillaume Lhermitte, geändert vor 12 Jahren.

RE: ThemeDisplay in hook action class is null

New Member Beiträge: 13 Beitrittsdatum: 02.11.10 Neueste Beiträge
Simple, Usefull, Efficient, before I red your post I was looking far from the most obvious and elegant way to get those precious informations.

Thank you !
Harish Bhutada, geändert vor 11 Jahren.

RE: ThemeDisplay in hook action class is null

New Member Beitrag: 1 Beitrittsdatum: 09.05.13 Neueste Beiträge
Hiii Alexandra
I also face the same problem
you just go in portal.properties file and write
servlet.service.events.post=your action class
this may solve your problem
thumbnail
Tahir Noor Khaliq, geändert vor 8 Jahren.

RE: ThemeDisplay in hook action class is null

Junior Member Beiträge: 35 Beitrittsdatum: 05.02.15 Neueste Beiträge
Use this
User user=null;
try {
user = PortalUtil.getUser(request);
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
long ScopeGroupId= PortalUtil.getScopeGroupId(request);
System.out.println("ScopeGroupId : " + ScopeGroupId);
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println("user "+user.getScreenName());