Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Advait Trivedi
Conditionally redirecting to a Liferay Page
September 6, 2011 2:37 AM
Answer

Advait Trivedi

Rank: Junior Member

Posts: 55

Join Date: March 30, 2010

Recent Posts

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
September 6, 2011 2:57 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

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
September 6, 2011 4:28 AM
Answer

Advait Trivedi

Rank: Junior Member

Posts: 55

Join Date: March 30, 2010

Recent Posts

Hi Jelmer,

thanks a ton.. this helped.

- Advait
Siby Mathew
RE: Conditionally redirecting to a Liferay Page
October 18, 2012 8:23 AM
Answer

Siby Mathew

Rank: Expert

Posts: 261

Join Date: March 4, 2011

Recent Posts

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
March 27, 2013 4:48 AM
Answer

Denis Signoretto

Rank: Regular Member

Posts: 214

Join Date: April 21, 2009

Recent Posts

Did you solve it?
Siby Mathew
RE: Conditionally redirecting to a Liferay Page
April 3, 2013 4:59 AM
Answer

Siby Mathew

Rank: Expert

Posts: 261

Join Date: March 4, 2011

Recent Posts

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