struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Childers" <jchild...@hotels.com>
Subject RE: Initialize Struts form with request parameters
Date Tue, 01 Jul 2003 14:20:52 GMT
Well, honestly it isn't recommended that you do things this way. Struts is all about separating
your model from your view, and you are wanting to modify the model. That's smack dab in the
realm of Actions, so you should be doing it there. The Action would then forward to your JSP.
Modifying ActionForms from within a JSP flies in the face of what Struts was designed to do.

What you'll want to do is have an Action that gets called before your JSP is displayed. You're
URL would look like this:

http://localhost/test/chooseTraineePage.do?traineeId=12345

The .do is the only difference. From within the mapping defined in your struts-config for
chooseTraineePage you would have the following (in your execute/perform method):

ChooseTraineeForm ctForm = (ChooseTraineeForm) form;
ctForm.setTraineeId(request.getParameter("traineeId"));
ctForm.setName(request.getParameter("name"));
request.addParameter("chooseTrainee", ctForm);
return mapping.findForward("success");

This is off the top of my head, so the syntax may be wrong, but the flow is correct.

-= James

> -----Original Message-----
> From: Tien Nguyen [mailto:tiennguyen_it@yahoo.de]
> Sent: Tuesday, July 01, 2003 9:07 AM
> To: 'Struts Users Mailing List'; struts-user@jakarta.apache.org
> Subject: Initialize Struts form with request parameters
> 
> 
> Hi all,
> I have a problem with struts form. 
> 
> The form is:
> <html:form action="chooseTrainee">
> <html:hidden property="traineeId"/>
> <html:text property="name"/>
> <html:submit value="Submit"/>
> </html:form>
> 
> and the ActionForm has the following properties (fields and
> getters/setters):
> traineeId
> name
> 
> What I want is: the traineeId must be initialized by a value 
> passed via
> URL:
> e.g: http://localhost/test/chooseTraineePage.jsp?traineeId=12345
> 
> How can I do that?
> Your reply is highly appreciated!
> Thanks
> Tien
> 
> -----Original Message-----
> From: struts-user-digest-help@jakarta.apache.org
> [mailto:struts-user-digest-help@jakarta.apache.org] 
> Sent: Tuesday, July 01, 2003 3:08 PM
> To: struts-user@jakarta.apache.org
> Subject: struts-user Digest 1 Jul 2003 13:07:49 -0000 Issue 3513
> 
> 
> struts-user Digest 1 Jul 2003 13:07:49 -0000 Issue 3513
> 
> Topics (messages 84024 through 84051):
> 
> show selected value in html:options field
> 	84024 by: Stefan Schaebel
> 
> Re: <logic:equal> with sessionAttributes
> 	84025 by: Nicolas De Loof
> 	84026 by: Filip Polsakiewicz
> 
> Re: [ANNOUNCEMENT] Struts 1.1 Final released
> 	84027 by: Arnaud HERITIER
> 
> Re: Can I have a &nbsp; _not_ URL encoded?
> 	84028 by: Marco Maier
> 	84029 by: Samuel.Opoku-Boadu.t-systems.com
> 
> Re: setting input for action
> 	84030 by: thart.part.net
> 
> Validations in Struts 1.0
> 	84031 by: sriram
> 
> Populating select boxes dynamically
> 	84032 by: sriram
> 	84043 by: Alex Shneyderman
> 
> disabling form element
> 	84033 by: Frances Aleah Z. de Guzman
> 	84034 by: Mark Lowe
> 
> REPOST: Help! - java.security.AccessControlException
> 	84035 by: White, Joshua A (HTSC, CASD)
> 
> Problem With Struts1.1 Example
> 	84036 by: Saroj Kumar Choudhury
> 
> knowing which DispatchAction called an Action
> 	84037 by: Ionel Gardais
> 
> where does a form element get and put it's data
> 	84038 by: Heather Buch
> 	84040 by: Adam Hardy
> 
> Newbie question: DispatchAction subclassing
> 	84039 by: Paula Coll
> 
> Upgrading to Struts 1.1
> 	84041 by: Natalie D Rassmann
> 	84051 by: Hajratwala, Nayan (N.)
> 
> Display table contents
> 	84042 by: Arnost Foo
> 
> Tag to remove jsp from cache???
> 	84044 by: Prashanth.S
> 	84046 by: Alex Shneyderman
> 	84048 by: Nicolas De Loof
> 
> External style sheets and tiles.
> 	84045 by: James Watkins
> 	84047 by: Nicolas De Loof
> 
> Could not parse deployment descriptor: java.io.IOException: cannot
> resolve '/WEB-INF/struts-bean.tld' into a valid tag library
> 	84049 by: PREETAM Balijepalli
> 	84050 by: Adam Hardy
> 
> Administrivia:
> 
> To subscribe to the digest, e-mail:
> 	struts-user-digest-subscribe@jakarta.apache.org
> 
> To unsubscribe from the digest, e-mail:
> 	struts-user-digest-unsubscribe@jakarta.apache.org
> 
> To post to the list, e-mail:
> 	struts-user@jakarta.apache.org
> 
> 
> ----------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message