Fóruns

Início » Liferay Portal » English » 2. Using Liferay » General

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Mitko Zafirovski
Hook on LayoutAction
29 de Maio de 2012 22:27
Resposta

Mitko Zafirovski

Ranking: Junior Member

Mensagens: 27

Data de entrada: 1 de Março de 2012

Mensagens recentes

For couple of days now i was trying to get the redirect on liferay wroking. Usually when u access a page that requires the user to log in it redirect you to the login page by passing its own querry parameter "http://localhost:8080/web/guest/login?_58_redirect=%2Fnewpage" . How ever this doesn't seem to function. At the begining i have hooked the login.event.post action where i override the response to for it to send me to a default page of my choosing. I though this was causing problems so i removed this action. Now after login, liferay remains on the login page. I was reading a post that was saying that liferay forgets to append the querry string. So i tried hooking the actual LayoutAction in my hook as folowing:

1<struts-action>
2        <struts-action-path>/portal/layout/LayoutAction</struts-action-path>
3        <struts-action-impl>com.hooks.myhook.actions.HookedLayoutAction</struts-action-impl>
4       
5    </struts-action>


Than i create my class that extends the LayoutAction:

 1
 2public class HookedLayoutAction extends LayoutAction{
 3    @Override
 4    public ActionForward execute(
 5            ActionMapping mapping, ActionForm form, HttpServletRequest request,
 6            HttpServletResponse response)
 7        throws Exception {
 8// i copied the entier method from the layout class and made needed changes as suggested in the article above. 
 9}
10}


How ever when i load the hook. Liferay does not go in throw my hooked action. Any sugestion of what am i doing wrong. I'm using Liferay 6.0.5 Comunity Edition

David H Nebinger
RE: Hook on LayoutAction
30 de Maio de 2012 06:02
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 8440

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

You have to go to 'newpage' and remove guest access.

After that if you navigate to 'newpage' as an unauthenticated user, Liferay will redirect to the login page and then redirect you back to 'newpage' after you've successfully authenticated.
Nagendra Kumar Busam
RE: Hook on LayoutAction
30 de Maio de 2012 07:03
Resposta

Nagendra Kumar Busam

Ranking: Liferay Master

Mensagens: 638

Data de entrada: 7 de Julho de 2009

Mensagens recentes

I am not quite sure customization of struts action works for Liferay 6.0.5. According to link @ http://www.liferay.com/web/mika.koivisto/blog/-/blogs/overriding-and-adding-struts-actions-from-hook-plugins, we have support for this from Liferay 6.1.0 CE and backported to 6.0 EE SP2 so not available in 6.0.6 CE
Mitko Zafirovski
RE: Hook on LayoutAction
31 de Maio de 2012 22:20
Resposta

Mitko Zafirovski

Ranking: Junior Member

Mensagens: 27

Data de entrada: 1 de Março de 2012

Mensagens recentes

@David H Nebinger
Yes the new page does not have the guest view permission. The page only has a power user view perrmision and owner full permissions. Half of the scenraio is there. If i am not logged in and try to access the page i get redirected to the login screen and in the url i can see that liferay by it self adds the redirect parmetar.
http://localhost:8080/login?_58_redirect=%2Fweb%2Fguest%2Fnewpage

Then i login once i log in i stay at the login page with the same url as above in the browser. So basically liferay does not do the redirection after the login. I was trying to do the redirect manualy by hooking the login.event.post action and trying to get the parameter from the http request, but the parameter is not there. I was think it might be some of the configuration i added in the portal.ext.properties. From the default once i have the following overreeten:
auth.login.url
redirect.url.security.mode=domain
redirect.url.domains.allowed=
default.logout.page.path=
company.default.home.url

Is it possible one of these properties make stop liferay from redirecting? And if it is how do i go around that because these properties have to be overridden in my case. As i mentioned above i read that liferay forgets to append the querry string that is passes to it when its in the LayoutAction Automatic redirect to login forgets URL parameters.
Suyash Bhalekar
RE: Hook on LayoutAction
18 de Abril de 2013 23:08
Resposta

Suyash Bhalekar

Ranking: New Member

Mensagens: 18

Data de entrada: 4 de Setembro de 2012

Mensagens recentes

Hi Mitko ,

Have you created any hook or ext or Listener to remove the view permission of page?
Or Have you manually removed the view permission of page from manage permission tab?

If you have done this case apart from manually, then kindly mention the steps to do so.

Thanks
Mitko Zafirovski
RE: Hook on LayoutAction
23 de Abril de 2013 04:03
Resposta

Mitko Zafirovski

Ranking: Junior Member

Mensagens: 27

Data de entrada: 1 de Março de 2012

Mensagens recentes

Hello Suyash, we are manually editing the page permissions. If need to edit them programaticaly u can use:
1ResourcePermissionLocalServiceUtil.setResourcePermissions
or
1ResourcePermissionLocalServiceUtil.removeResourcePermission
Suyash Bhalekar
RE: Hook on LayoutAction
7 de Maio de 2013 22:18
Resposta

Suyash Bhalekar

Ranking: New Member

Mensagens: 18

Data de entrada: 4 de Setembro de 2012

Mensagens recentes

Thanks Mitko,
I have created a Listener for Layout and on creation of page permissions are assigned as per required.
David H Nebinger
RE: Hook on LayoutAction
10 de Maio de 2013 05:55
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 8440

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

There is, I believe, a bug in one of the 6.1 CE releases (possibly ga2, don't remember) that the redirects were not working.