File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Maintaining ActionForm data between Actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Maintaining ActionForm data between Actions" Watch "Maintaining ActionForm data between Actions" New topic
Author

Maintaining ActionForm data between Actions

Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
Is there a way I can retrieve the values of a Form in a 2� Action which I set on the 1� Action?

This is my scenario:

Struts-config


1� Action


the Form


The JSP takes the Form values of "listaNoticias" correctly, and submits to another action:

2� Action


And that didn�t work because the form values are lost. Why?

I tried making the scope as session in the struts-config action-path but didn�t work.


.NET & JSP developer for <a href="http://www.grupocartuja.com" target="_blank" rel="nofollow"> Grupo Cartuja</a><br /> <br />Currently moving the webpage from ASP to Struts (mostly the Intranet)
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
The values come up as empty because you may not be sending this arrayList as a parameter during jsp form submit to Action 2 or some error in the jsp. Please post the jsp.


- Christian
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
In fact, I�m not sending the ArrayList, and dont want to do it.

From pages I found I though that Form values are maintained through JSP�s without the need of repopulating the Form again, but the ArrayList and all of the multiple fields I have in the form are reseted, or the form is created again for each request.

Is there a way to keep the data in a structs-way without resorting to public variables or whatever?

Thanks to another member I found this:
<bean:define id="name" name="MyForm" property="MyFormField" type="java.util.Collection" />

I have to try that yet, but it makes sense that since MyFormField is in the jsp, the form will take the value in the request.
I find it cumbersome and not very efficient but this monday I have to finish this so...
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
...It didn�t work. How can I submit the Arraylist then?

This is a trimmed down version of my JSP:


Sorry about the mess, I�m still learning and merging a lot of things at once.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Maintaining ActionForm data between Actions