RE: Forwarding Data For A Form
Jake, Thanks for the tip. I hadn't thought of prepopulating a form and pushing onto the request object before returning the ActionForward. Is the form name (i.e. key) you store the form under in the request object the same as that set in the name property of the action tag in the action mapping? I'll give this a try as nothing else has worked like I want. Jack -Original Message- From: Jake Thompson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 10:07 PM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form I think this sounds like what I am doing. I have a form that performs an action, the goes to another form, either the same or different but a new form needs to be set. Pseudo code: Form formObject = new Form(); formObject.setId(1); formObject.setName(NEW); Request.setAttribute(formName, formObject); Return(new ActionForward(somewhere); Is this what you are trying to do? I use this because I get a form object that is partially populated and use it to look up and return a fully poplated form, I then just overwrite the request attribute with this new form. Or a form may have multiple possible actions some going to new forms of a different type, so I lookup and set some initial info and set that into the request. Hope this helps, Jake T. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 6:09 PM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form James, Isn't the Action's perform() called as a result of the Form's action being invoked and after the form's validate() method succeeds? What I'm wanting is the form input fields to be prepopulated with data sent by another Action so when the JSP form is displayed the fields are all filled in. I thought the jsp:useBean tag would work, but it didn't. (I didn't want to expose the class name of the bean to the JSP page anyway. I was hoping to stay in the Struts Model 2 framework to keep all the Java details abstracted away from the JSP developers.) Jack -Original Message- From: James Dasher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:15 PM To: 'Struts Users Mailing List' Subject: RE: Forwarding Data For A Form If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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] -- 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]
RE: Forwarding Data For A Form
Jake, Just to follow-up, this worked exactly as I would have hoped. For anyone interested, this approach is useful to handle situations where information is accumulating across multiple forms and beans each subsequent form needs some of the data from earlier forms. Off the top of my head, it seems like it would be useful to be able to stuff Objects into an ActionForward that are then made available to ActionForms for just this purpose. I don't mind using the request/session objects, but since an ActionForm will be instantiated anyway as part of the forward, it would seem to be more direct just to make Objects available at the time the ActionForward is created. Thanks a lot for the help. Jack -Original Message- From: Jack Frosch [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 10:45 AM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form Jake, Thanks for the tip. I hadn't thought of prepopulating a form and pushing onto the request object before returning the ActionForward. Is the form name (i.e. key) you store the form under in the request object the same as that set in the name property of the action tag in the action mapping? I'll give this a try as nothing else has worked like I want. Jack -Original Message- From: Jake Thompson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 10:07 PM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form I think this sounds like what I am doing. I have a form that performs an action, the goes to another form, either the same or different but a new form needs to be set. Pseudo code: Form formObject = new Form(); formObject.setId(1); formObject.setName(NEW); Request.setAttribute(formName, formObject); Return(new ActionForward(somewhere); Is this what you are trying to do? I use this because I get a form object that is partially populated and use it to look up and return a fully poplated form, I then just overwrite the request attribute with this new form. Or a form may have multiple possible actions some going to new forms of a different type, so I lookup and set some initial info and set that into the request. Hope this helps, Jake T. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 6:09 PM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form James, Isn't the Action's perform() called as a result of the Form's action being invoked and after the form's validate() method succeeds? What I'm wanting is the form input fields to be prepopulated with data sent by another Action so when the JSP form is displayed the fields are all filled in. I thought the jsp:useBean tag would work, but it didn't. (I didn't want to expose the class name of the bean to the JSP page anyway. I was hoping to stay in the Struts Model 2 framework to keep all the Java details abstracted away from the JSP developers.) Jack -Original Message- From: James Dasher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:15 PM To: 'Struts Users Mailing List' Subject: RE: Forwarding Data For A Form If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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] -- 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]
RE: Forwarding Data For A Form
Let's assume your jsp is named login.jsp and that it has a corresponding form bean named LogonForm. In the forwarding Action instantiate an instance of Logon Form and then put it on the request (using setAttribute). i.e. LogonForm logonForm = new LogonForm(); logonForm.setUserName(milton); ... request.setAttribute(logonForm, logonForm); If your struts-config.xml has an action mapping with the bean name defined as logonForm and the form in your login.jsp forwards to this action mapping, then the fields will be prefilled using the form bean created in your calling action.
Re: Forwarding Data For A Form
According to my understanding of the problem, this is really a very typical requirement that the Action class needs to pass some information to its view (jsps). All you have to do is to set the userid as an attribute of request(or session) scope. And then in the login.jsp, you can use bean:write tag to pick up its value. Further, in your case, you may want to use this tag for both displaying and setting the value of a hidden element. Hope this helps, - Original Message - From: James Dasher [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, January 03, 2002 7:15 AM Subject: RE: Forwarding Data For A Form If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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]
RE: Forwarding Data For A Form
James, Isn't the Action's perform() called as a result of the Form's action being invoked and after the form's validate() method succeeds? What I'm wanting is the form input fields to be prepopulated with data sent by another Action so when the JSP form is displayed the fields are all filled in. I thought the jsp:useBean tag would work, but it didn't. (I didn't want to expose the class name of the bean to the JSP page anyway. I was hoping to stay in the Struts Model 2 framework to keep all the Java details abstracted away from the JSP developers.) Jack -Original Message- From: James Dasher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:15 PM To: 'Struts Users Mailing List' Subject: RE: Forwarding Data For A Form If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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]
RE: Forwarding Data For A Form
I think this sounds like what I am doing. I have a form that performs an action, the goes to another form, either the same or different but a new form needs to be set. Pseudo code: Form formObject = new Form(); formObject.setId(1); formObject.setName(NEW); Request.setAttribute(formName, formObject); Return(new ActionForward(somewhere); Is this what you are trying to do? I use this because I get a form object that is partially populated and use it to look up and return a fully poplated form, I then just overwrite the request attribute with this new form. Or a form may have multiple possible actions some going to new forms of a different type, so I lookup and set some initial info and set that into the request. Hope this helps, Jake T. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 03, 2002 6:09 PM To: Struts Users Mailing List Subject: RE: Forwarding Data For A Form James, Isn't the Action's perform() called as a result of the Form's action being invoked and after the form's validate() method succeeds? What I'm wanting is the form input fields to be prepopulated with data sent by another Action so when the JSP form is displayed the fields are all filled in. I thought the jsp:useBean tag would work, but it didn't. (I didn't want to expose the class name of the bean to the JSP page anyway. I was hoping to stay in the Struts Model 2 framework to keep all the Java details abstracted away from the JSP developers.) Jack -Original Message- From: James Dasher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:15 PM To: 'Struts Users Mailing List' Subject: RE: Forwarding Data For A Form If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Forwarding Data For A Form
How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Forwarding Data For A Form
If I am not mistaken, the form is passed into the action.perform() as a parameter. You should be able to get/set your bean properties there. -Original Message- From: Jack [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 5:51 PM To: Struts Users Mailing List Subject: Forwarding Data For A Form How can I get an action form to display data generated by an action? I have a Registration action that updates a database and generates a user id. The perform() method of that action forwards an ActionForward object mapped to a Login form. I want the Login form to display the generated user ID from the Registration action. I'm not sure how to pass along the user ID so it will automatically be picked up by the Login form and displayed in the proper input field. Thanks. Jack -- 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]