You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Loschen <Ch...@Siebel.com> on 2005/05/25 22:35:07 UTC

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.

RE: Populating a new form bean and passing it on to the next request

Posted by meyawn <na...@gmail.com>.
you set stuff in your request object..but for the login form another request
object is created and it has a seperate instance of loginForm..i am a bit
rusty with struts, pls correct me if i am wrong

-----Original Message-----
From: Chris Loschen [mailto:Chris.Loschen@Siebel.com]
Sent: Wednesday, May 25, 2005 11:35 PM
To: Struts Users Mailing List
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org