File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Maintaining ActionForm data between Actions" Watch "Maintaining ActionForm data between Actions" New topic

Maintaining ActionForm data between Actions

Mario Romero

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:


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="" 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

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

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.
I agree. Here's the link:
subject: Maintaining ActionForm data between Actions
It's not a secret anymore!