It's exactly what I wanted! But not only the form bean is called also the perform method of the action bean. So the order of methed calls is: reset of the form bean and then the perform method of the action bean. After these method calls the user can enter his values.
I want the perform method only to be called when the user submits his entries. thanks in advance ----- Original Message ----- From: "Robert Taylor" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, January 20, 2003 4:59 PM Subject: RE: Forwarding parameters > I'm confused now. I thought that is what you wanted. > > Is this not the user case you described originally? > > --Display login page > --User identfies himself as a new user and enters name (no password) > --Display createAccount page populated with user name > --User enters appropriate information and submits form > (subsequently invoking the CreateAccount action) > --New account is created with user name > > robert > > > -----Original Message----- > > From: Andreas Winkler [mailto:[EMAIL PROTECTED]] > > Sent: Monday, January 20, 2003 10:49 AM > > To: Struts Users Mailing List > > Subject: Re: Forwarding parameters > > > > > > Thanks for your help! It worked! > > Now I have the user on the new page, but when the createAccount is entered > > the action behind the form is also called. > > Is there a way to avoid this? > > > > Andreas > > > > ----- Original Message ----- > > From: "Robert Taylor" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Monday, January 20, 2003 3:02 PM > > Subject: RE: Forwarding parameters > > > > > > > Andreas, > > > > > > If I understand correctly, you have a LoginAction and a > > NewUserAction. If > > > the user identifies himself as a new user, you want LoginAction > > to forward > > > to a page where the user name is populated and the processing is handled > > by > > > NewUserAction. > > > > > > One approach would be to place the user name as a request parameter (not > > > attribute) in the query string > > > and forward to the new user page. The form on the new user page will > > render > > > the form with the new user > > > name populated in the appropriate field. In this fashion you > > let Struts do > > > most of the work for you. > > > > > > In order for this to work the user name field name must be identical in > > the > > > login form and the new user form. > > > You must also bind the new user form to the NewUserAction by > > assigning its > > > name to the input attribute of the form element in the > > struts-config file. > > > > > > For example you should have something like the following in your struts > > > config file: > > > > > > <form-beans> > > > <form-bean name="loginForm" type="com.mycompany.BaseForm"> > > > <form-bean name="newUserForm" type="com.mycompany.BaseForm"> > > > </form-beans> > > > > > > <action-mappings> > > > <action path="/do/login" > > > parameter="" > > > validate="true" > > > scope="request" > > > name="loginForm" > > > type="com.mycompany.BaseAction" > > > input="/login.jsp"> > > > > > > <forward name="success" path="/account/index.jsp"/> > > > <forward name="newuser" path="/createAccount.jsp"/> > > > > > > </action> > > > > > > <action path="/do/createAccount" > > > parameter="" > > > validate="true" > > > scope="request" > > > name="newUserForm" > > > type="com.mycompany.BaseAction" > > > input="/createAccount.jsp"> > > > > > > <forward name="success" path="/account/index.jsp"/> > > > > > > > > > </action> > > > > > > > > > The createAccount.jsp should have a form element which "points" to the > > > createAccount action. > > > <html:form action="createAccount" ..../> > > > > > > > > > The LoginAction code would look something like this: > > > > > > MyForm form = (MyForm)form; > > > String userName = form.getUserName(); > > > if (isNewUser(userName)) { // determine if the user is a new user > > > > > > forward = mapping.findForward("newuser"); > > > /* > > > * NOTE: > > > * There are cleaner ways to attach a parameter > > > * to the path. Search for > > > * ParameterActionForward in the mailing list archives. > > > */ > > > String path = forward.getPath() + "?userName=" + userName; > > > forward = new ActionForward(path); > > > > > > } else { > > > > > > // do something else > > > > > > } > > > > > > return forward; > > > > > > > > > One last thing. The reason your data is getting "lost" is because you > > > are redirecting instead of forwarding. When you redirect, a new request > > > is created thereby loosing all of your existing data. A quick solution > > > would be to set the redirect flag in the forward to false or just omit > > > it since forwarding is the default behavior for an ActionForward. > > > > > > HTH, > > > > > > robert > > > > > > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>