Forums de discussion

Conditionally redirecting to a Liferay Page

Advait Trivedi, modifié il y a 12 années.

Conditionally redirecting to a Liferay Page

Junior Member Publications: 56 Date d'inscription: 30/03/10 Publications récentes
Hi All,

I have a requirement - when user hit a URL of a particular Liferay page and if he is not logged in - need to redirect him to a certain page (not the login page).
Would appreciate all possible ways of implementing this.

Currently I am thinking of modifying AbsoluteRedirectsFilter and do response.sendRedirect(), because in my project I am already modifying AbsoluteRedirectsFilter using ext environment for some other purpose.

Regards,
Advait
thumbnail
jelmer kuperus, modifié il y a 12 années.

RE: Conditionally redirecting to a Liferay Page

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
You can create a service pre action in a hook plugin for that. Eg.

public class MyAction extends Action {

    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
                ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
                if (!themeDisplay.isSignedIn() && "/yourpath".equals(themeDisplay.getLayout().getFriendlyURL()) {
                    response.sendRedirect(..)
Advait Trivedi, modifié il y a 12 années.

RE: Conditionally redirecting to a Liferay Page

Junior Member Publications: 56 Date d'inscription: 30/03/10 Publications récentes
Hi Jelmer,

thanks a ton.. this helped.

- Advait
Siby Mathew, modifié il y a 11 années.

RE: Conditionally redirecting to a Liferay Page

Expert Publications: 268 Date d'inscription: 04/03/11 Publications récentes
Hi Jelmer,
The redirection doesn't work as the ServicePreAction is getting invoked recursively.
Is there any workaround for this ?

THanks,
Siby
thumbnail
Denis Signoretto, modifié il y a 11 années.

RE: Conditionally redirecting to a Liferay Page

Expert Publications: 375 Date d'inscription: 21/04/09 Publications récentes
Did you solve it?
Siby Mathew, modifié il y a 11 années.

RE: Conditionally redirecting to a Liferay Page

Expert Publications: 268 Date d'inscription: 04/03/11 Publications récentes
Hi Denis,
I dont remember exactly, but believe I was using an AutoLogin hook ...which for a particular condition...redirects him using :
req.setAttribute(AutoLogin.AUTO_LOGIN_REDIRECT,sapLoginPage);


Hope that helps.

Thanks,
Siby