Forum

Accueil » Liferay Portal » English » 3. Development

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Advait Trivedi
Conditionally redirecting to a Liferay Page
6 septembre 2011 02:37
Réponse

Advait Trivedi

Rang: Junior Member

Publications: 55

Date d'inscription: 30 mars 2010

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
Jelmer Kuperus
RE: Conditionally redirecting to a Liferay Page
6 septembre 2011 02:57
Réponse

Jelmer Kuperus

Rang: Liferay Legend

Publications: 1192

Date d'inscription: 10 mars 2010

Publications Récentes

You can create a service pre action in a hook plugin for that. Eg.
1
2public class MyAction extends Action {
3
4    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
5                ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
6                if (!themeDisplay.isSignedIn() && "/yourpath".equals(themeDisplay.getLayout().getFriendlyURL()) {
7                    response.sendRedirect(..)
Advait Trivedi
RE: Conditionally redirecting to a Liferay Page
6 septembre 2011 04:28
Réponse

Advait Trivedi

Rang: Junior Member

Publications: 55

Date d'inscription: 30 mars 2010

Publications Récentes

Hi Jelmer,

thanks a ton.. this helped.

- Advait
Siby Mathew
RE: Conditionally redirecting to a Liferay Page
18 octobre 2012 08:23
Réponse

Siby Mathew

Rang: Expert

Publications: 261

Date d'inscription: 4 mars 2011

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
Denis Signoretto
RE: Conditionally redirecting to a Liferay Page
27 mars 2013 04:48
Réponse

Denis Signoretto

Rang: Regular Member

Publications: 214

Date d'inscription: 21 avril 2009

Publications Récentes

Did you solve it?
Siby Mathew
RE: Conditionally redirecting to a Liferay Page
3 avril 2013 04:59
Réponse

Siby Mathew

Rang: Expert

Publications: 261

Date d'inscription: 4 mars 2011

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 :
1req.setAttribute(AutoLogin.AUTO_LOGIN_REDIRECT,sapLoginPage);


Hope that helps.

Thanks,
Siby