Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Cesar William
after create account
June 14, 2010 6:35 AM
Answer

Cesar William

Rank: Junior Member

Posts: 34

Join Date: June 7, 2010

Recent Posts

Hi,
Is there a configurable way to change the landing page after of "Create Account"? Or pass to "Create Account" page some parameter?
Jen Fong
RE: after create account
July 12, 2010 1:19 PM
Answer

Jen Fong

Rank: New Member

Posts: 10

Join Date: May 19, 2010

Recent Posts

Hi, Cesar--

Did you ever figure this out? We also would like to change the landing page after first login or after account creation, but not for all logins.

We were hoping to avoid the ext environment but what I've been reading is that we may have to end up changing the CreateAccountAction to add a redirect...
Amos Fong
RE: after create account
July 12, 2010 2:34 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1954

Join Date: October 7, 2008

Recent Posts

If you are running 6.0.x or 5.2 EE (I don't remember which service pack) you can pass in a redirect parameter. Otherwise you'll need ext to for createAccountAction to send the redirect. You may want to do it similar to trunk right now so when you upgrade you can get rid of your ext class. This is how it's done in trunk:

 1    protected void sendRedirect(
 2            ActionRequest actionRequest, ActionResponse actionResponse,
 3            ThemeDisplay themeDisplay, String login, String password)
 4        throws Exception {
 5
 6        HttpServletRequest request = PortalUtil.getHttpServletRequest(
 7            actionRequest);
 8
 9        String redirect = PortalUtil.escapeRedirect(
10            ParamUtil.getString(actionRequest, "redirect"));
11
12        if (Validator.isNotNull(redirect)) {
13            redirect = PortalUtil.escapeRedirect(redirect);
14
15            HttpServletResponse response = PortalUtil.getHttpServletResponse(
16                actionResponse);
17
18            LoginUtil.login(request, response, login, password, false, null);
19        }
20        else {
21            PortletURL loginURL = LoginUtil.getLoginURL(
22                request, themeDisplay.getPlid());
23
24            loginURL.setParameter("login", login);
25
26            redirect = loginURL.toString();
27        }
28
29        actionResponse.sendRedirect(redirect);
30    }
Jen Fong
RE: after create account
July 12, 2010 4:47 PM
Answer

Jen Fong

Rank: New Member

Posts: 10

Join Date: May 19, 2010

Recent Posts

Thanks, Amos!

We decided to not muck about with the ext environment [mostly because we dont' really know how to make use of it properly ... ] and just modify the notification e-mail to contain the information that would have been in the redierct page.

We are currently using 5.2.3 CE so we would indeed have needed EXT.

However, for future reference if we were to override the CreateAccountAction in the ext environment, I had a few ?s:
1) to override the action, would we would simply copy the same code into our own class and modify, then change struts-config.xml

1<action path="/login/create_account" [color=#F81C1C]type="my.package.NewCreateAccountAction"[/color]>
2                        <forward name="portlet.login.create_account" path="portlet.login.create_account" />
3                </action>

??

2)Currently, CreateAccountAction calls the helper addUser function and then redirects in processAction like so:

1 String redirect = PortalUtil.getLayoutURL(layout, themeDisplay);
2 sendRedirect(actionRequest, actionResponse, redirect);


Would we simply have to add a "redirect" param to the create_account.jsp and use this in our own processAction instead of the getLayoutURL in this sendRedirect line, or would we have to additionally redefine sendRedirect as you mentioned in your post? [I was confused by the extra parameters... is this sendRedirect directly in the CreateAccountAction class?]

Thank you for your helpful "minimizing the ext environment" blog, also. This helped us see that we would just extend the createaccountaction, but we are still slightly confused--would redefining sendRedirect like you mentioned be sufficient in our class or would we also need to redefine processAction?

I apologize for these simple questions; we aren't exactly sure how the ext environment works but hope we have the general gist of: create new class that extends original, modify, deploy ext-impl, modify configs to point to new ext classes.

Thanks again for your quick reply. We were on zope 2 before which has long been dead; it's so nice to have such an immediate developer and community response with liferay!
Amos Fong
RE: after create account
July 12, 2010 4:59 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1954

Join Date: October 7, 2008

Recent Posts

Hi Jen,

If you are just starting on Liferay, I suggest going with 6.0 (which should be released soon...hopefully emoticon). But If you decide to go with 5.2.3:

1) to override the action, would we would simply copy the same code into our own class and modify, then change struts-config.xml


Correct, actually it should be struts-config-ext.xml, but it doesn't work in 5.2.3 (see http://issues.liferay.com/browse/LPS-6877). So yes, overwrite struts-config.xml with your own class.

Your class should extend CreateAccountAction.java so you just overwrite the one method you need.
is this sendRedirect directly in the CreateAccountAction class?]


Yes, but I don't think it exists in 5.2.3 so you should just override AddUser().

I apologize for these simple questions; we aren't exactly sure how the ext environment works but hope we have the general gist of: copy original source, modify, deploy ext-impl, modify configs to point to new ext classes.


No problem, it's always great to see new people. And yes you got the right gist of it.

Would we simply have to add a "redirect" param to the create_account.jsp and use this instead of the getLayoutURL in this sendRedirect line


Yea that would work.

[I was confused by the extra parameters


Do you mean the parameters used for this call?

LoginUtil.login(request, response, login, password, false, null);

I assume after they create an account and you want to redirect them, they should be logged in as well. So that's what that line of code does.

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!