Thanks Erik,

Actually, my login action is rather complex, and gets called by several
other apps which I don't have control over, so I'd rather not just
duplicate the code: somebody else might change it at some point, and
then I'd be in trouble. Both the login action and my action already
extend a base class, but there again I'd be messing with code that has
implications over a very large codebase. I suppose I could have a base
class that extends that mutual base and have both of these extend that,
but instead, I tried a different approach your reply suggested to me. 

I had my newPasswordAction class extend LoginAction. That way both
classes inherited the mutual base class, and I was able to call the
login action via a call to the super like so:

                //set loginForm parameters to request to enable
bypassing login page 
                LoginForm loginForm = new LoginForm();
                loginForm.setUser(userID);
 
loginForm.setPassword(forgotPasswordForm.getNewPassword());
                request.setAttribute("loginForm", loginForm);
                
                //log the user in
                forward = super.doAction(mapping, loginForm, request,
response);

I'm testing the results now, but it seems to be working. Thanks for your
help!

Chris

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 25, 2005 4:46 PM
To: Struts Users Mailing List
Subject: Re: Populating a new form bean and passing it on to the next
request

Sorry this doesn't answer your question directly, but I would back up a
bit and question your design.

Rather than try to invoke your LoginAction manually from another action,
I would just invoke all the necessary methods in your
ForgotPasswordAction. Presumably logging on is little more than a call
to the manager layer and a session attribute setting (not counting form
validation). Actions are not really meant to be reusable components. If
you have several view-related methods you need to invoke at logon time,
put those methods in a base class that LogonAction and
ForgotPasswordAction extend. Otherwise, a small amount of redundant
logic from Action to Action is not a bad thing.

I think this would remove the problem you are describing. But of course,
I'm making a lot of assumptions.

Hope that helps,
Erik


-----Original Message-----
From: Chris Loschen <[EMAIL PROTECTED]>
Sent: May 25, 2005 4:35 PM
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Populating a new form bean and passing it on to the next
request

Hi all,

I'm using Struts 1.1. I've got some "forgot password" functionality
working, and the last piece of that is to set a new password for the
user who has successfully answered their security question. For that
action, I use a "forgotPasswordForm" form bean, which goes to my
"newPasswordAction". That's all working fine, and the new password is
getting saved to the DB as expected. Now I'd like to take that username
and new password and pass them over to my normal login action, so that
the user doesn't have to reenter their username and password again: they
just get logged in normally. The loginAction needs the loginForm, so I'm
instantiating a loginForm, populating with the new username and
password, and then saving it to the request object in my
newPasswordAction. However, I always get a validation error saying that
username and password are required, so I've got something wrong
someplace. Does anyone see it?

Here's the new code in setPasswordAction:

                LoginForm loginForm = new LoginForm();
                loginForm.setUser(userID);
 
loginForm.setPassword(forgotPasswordForm.getNewPassword());
                request.setAttribute("loginForm", loginForm);

Here are some fragments of struts-config.xml:

                <form-bean name="loginForm"
type="com.xxx.application.tbm.core.forms.LoginForm"/>

                <action path="/login/perform"
type="com.xxx.application.tsm.common.actions.LoginAction"
name="loginForm" scope="request" validate="true" input="login">
                        <forward name="success"
path="/disclaimer/show.do" redirect="true"/>
                        <forward name="error" path="/login/show.do"
redirect="true"/>
                </action>

                <action path="/forgot/setNewPwd"
type="com.xxx.application.tbm.b2b.actions.NewPasswordAction"
name="forgotPasswordNewForm" scope="request" validate="true"
input="forgot_password_setNew">
                        <forward name="success"
path="/login/perform.do"/>
                        <forward name="error"
path=".main.forgot.setNewPwd"/>
                </action>

loginForm extends ValidatorForm, and both user and password are required
in validation.xml, which is where my error messages appear to be coming
from.

I tried using a fully qualified name for loginForm (as in the form-bean
declaration), but that didn't help either. Any suggestions? Thanks!

Chris Loschen


_______________
Siebel
IT'S ALL ABOUT THE CUSTOMER
Visit www.siebel.com

This e-mail message is for the sole use of the intended recipient(s) and
contains confidential and/or privileged information belonging to Siebel
Systems, Inc. or its customers or partners. Any unauthorized review,
use, copying, disclosure or distribution of this message is strictly
prohibited. If you are not an intended recipient of this message, please
contact the sender by reply e-mail and destroy all soft and hard copies
of the message and any attachments. Thank you for your cooperation.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





_______________
Siebel
IT'S ALL ABOUT THE CUSTOMER
Visit www.siebel.com

This e-mail message is for the sole use of the intended recipient(s) and 
contains confidential and/or privileged information belonging to Siebel 
Systems, Inc. or its customers or partners. Any unauthorized review, use, 
copying, disclosure or distribution of this message is strictly prohibited. If 
you are not an intended recipient of this message, please contact the sender by 
reply e-mail and destroy all soft and hard copies of the message and any 
attachments. Thank you for your cooperation.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to