Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Alexander Topalov
Explicit redirect to the login page
29 marzo 2013 8.05
Risposta

Alexander Topalov

Punteggio: New Member

Messaggi: 2

Data di Iscrizione: 29 marzo 2013

Messaggi recenti

Hi,
I'm developing an application with ZK 5 on top of Liferay 6.1.0.
I have a portlet that contains a couple of different tabs. The desired workflow is this:
- An anonymous user is allowed to access the 1st tab.
- When he wants to navigate to the 2nd tab, he's redirected to the login page.
- After the user logs in, he's redirected back to the 2nd tab, where he can see the data that he filled in the 1st one.

I am new to Liferay and I have no idea how to explicitly redirect to the login page from the controller (a ZK composer).
Before posting I searched a lot. The best I found is this code:
1
2ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
3LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
4liferayPortletURL.setWindowState(WindowState.MAXIMIZED);
5 liferayPortletURL.setPortletMode(PortletMode.VIEW);
6 liferayPortletURL.setParameter("saveLastPath", "0");
7 liferayPortletURL.setParameter("struts_action", "/login/login");
8 liferayPortletURL.setParameter("redirect", PortalUtil.getCurrentURL(request));

But it doesn't work, because themeDisplay is null (as far as I understand untill the user actually logs in).
It would also be nice to somehow read the login URL dynamically.
Amos Fong
RE: Explicit redirect to the login page
2 aprile 2013 12.09
Risposta

Amos Fong

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1841

Data di Iscrizione: 7 ottobre 2008

Messaggi recenti

Hi,

This code looks good. ThemeDisplay shouldn't be null even if the user isn't signed in yet. What's the error you get?
Alexander Topalov
RE: Explicit redirect to the login page
3 aprile 2013 0.04
Risposta

Alexander Topalov

Punteggio: New Member

Messaggi: 2

Data di Iscrizione: 29 marzo 2013

Messaggi recenti

Hi,
thank you for your reply. ThemeDisplay was null because I am executing this code within a ZK event handler,
i.e. after an Ajax call, that doesn't know anything about the portlet request. I solved this by extending
ZK's default Portlet, explicitly adding the themeDisplay to the session as it is shown here -
http://capitalcode.blogspot.com/2012/09/zk-liferay-integration-first-step.html

For the other part of the issue - to preserve the already entered data after the login redirect - as I can't think of a better way,
again I added it to the session and I also added this property to portal-ext.properties -
1session.enable.phishing.protection=false

so that after login the user keeps the same session.