Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
David Haber
DefaultLandingPage.java - null value
July 4, 2010 9:22 AM
Answer

David Haber

Rank: New Member

Posts: 5

Join Date: July 4, 2010

Recent Posts

Hi,

I am trying to redirect the user to his own public/private pages upon login.

I added the following to LoginAction.java:

1       
2User user = themeDisplay.getUser();
3            
4session.setAttribute("j_userscreenname", user.getScreenName());
5
6return null;


And this to DefaultLandingPageAction.java:

1       
2// Get user screenname
3String userscreenName = (String)ses.getAttribute("j_userscreenname");
4
5LastPath lastPath = new LastPath("/web/", userscreenName+"/home/");
6
7ses.setAttribute(WebKeys.LAST_PATH, lastPath);


I added everything at the end of the classes.

Unfortunately the variable userscreenName contains always a null value.

I would appreciate any effort to help.
Thank you very much.
Sandeep Nair
RE: DefaultLandingPage.java - null value
July 4, 2010 8:43 PM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1721

Join Date: November 5, 2008

Recent Posts

Hi,

No need to add anything in LoginAction. You can get screen name anywhere using this

PortalUtil.getUser(request).getScreenName()

Regards,
Sandeep
sridhar iyer
RE: DefaultLandingPage.java - null value
July 14, 2010 3:54 AM
Answer

sridhar iyer

Rank: Junior Member

Posts: 57

Join Date: February 27, 2009

Recent Posts

You can use this code in your loginpostaction.java

String userPageURL = PortalUtil.getPathFriendlyURLPublic();
userPageURL = userPageURL + "/" + user.getScreenName();

try {
response.sendRedirect(userPageURL );
} catch (IOException e) {}