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 Struts: ActionForm does not contain user data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts: ActionForm does not contain user data" Watch "Struts: ActionForm does not contain user data" New topic
Author

Struts: ActionForm does not contain user data

Matt Connors
Greenhorn

Joined: Sep 08, 2004
Posts: 23
The problem I have is that some screen data is not reflected in the ActionForm once the jsp page has been submitted.

My ActionForm contains a vector of objects called DPTasks. I use the <html:iterate ../> tag to display the property DPTask.plannedHours. The data is displayed without a problem.

The user can change the value of plannedHours and my Action object needw to store the new value in the DB.

The problem I have is when my Action object's execute() method is called the Vector of DPTasks has a size of zero. Other attributes like ints, Strings, and floats reflect what the user entered and therefore seem to be working fine

I checked and my ActionForm's reset() method does not do anything with the DPTasks Vector.

Why did I loose the data in my Vector? How can I get the DPTasks vector to reflect what the user entered?

Thanks in advance,

Matt
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Try putting a System.out line in the Vector's setter method of your ActionForm to verify that the value was ever set to begin with.
You can't lose something that was never there in the first place.


A good workman is known by his tools.
Matt Connors
Greenhorn

Joined: Sep 08, 2004
Posts: 23
I know the vector was set correctly because I use it to populate a table in the jsp page.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

If your form is request scope you will have a new instance upon submission of the jsp.

In other words the form that populated your jsp is not the same object that your jsp submits to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts: ActionForm does not contain user data