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  After page loads, clear form bean value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark " After page loads, clear form bean value" Watch " After page loads, clear form bean value" New topic
Author

After page loads, clear form bean value

roseline ruba
Greenhorn

Joined: Mar 21, 2007
Posts: 20
I have a form bean property.
I want to set empty value to the form bean after the page loads.

Any ideas?

Thanks in Advance


Roseline
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864


Merrill
Consultant, Sima Solutions
roseline ruba
Greenhorn

Joined: Mar 21, 2007
Posts: 20
Thanks for your response.
But i'm using struts v1.
And i'm using layout.
So Please let me know how to do to this?

Thanks in advance
[ October 11, 2007: Message edited by: roseline ruba ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can use the JSTL c:set tag regardless of what other framework you are using. All you have to do is include the JSTL jar files and taglib declarations. I've shown you a way to do what you asked that will work. There are undoubtedly others.
roseline ruba
Greenhorn

Joined: Mar 21, 2007
Posts: 20
What if the property is ArrayList instead of String?
[ October 12, 2007: Message edited by: roseline ruba ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you want to reinitialize the list as in:

The best place to do that is in the reset method in your ActionForm. When you override the reset method, make sure the signature matches exactly that found in the Struts Javadoc.
roseline ruba
Greenhorn

Joined: Mar 21, 2007
Posts: 20
Thanks for your suggestion.

But my requirement is ,,
I have a list.
I want to get some values in the list from Action to JSP Page.
And when submitting the JSP, I want to pass new values in the list.
So I want to clear the list in JSP.

How can I do this?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by roseline ruba:
And when submitting the JSP, I want to pass new values in the list.
So I want to clear the list in JSP.

Roseline,

Passing new values to the list is not the same as clearing it. It would have been better if you had been clear about what you wanted to do from the beginning.

In this case, you will need to use indexed properties. To find out more about how to do this and to see a working example of the same, please see question 6 of this forum's FAQ.
 
 
subject: After page loads, clear form bean value
 
Similar Threads
How can i reset the form bean data
html tag
Struts:FormBean issue with html:select tag
Question about onload
How to make it blank?