aspose file tools*
The moose likes Struts and the fly likes validate() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate()" Watch "validate()" New topic
Author

validate()

Julia Collins
Greenhorn

Joined: Nov 08, 2002
Posts: 7
Hi,
I am using struts and validating my form using the validate method in the form bean.
Whenever an error is found the error messages are correctly displayed on the form - but all the fields are emptied.
How do I make the fields redisplay the information entered so that the user does not need to reenter every time validation fails
Thanks
Julia
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
You already have a form bean, so the hard part is already done. All you need to do is change your form in your jsp to use the struts-html taglib. For example, instead of using
<input type="text" ... >
you will use
<html:text ... >
Struts will figure out from your action which form to use, how they tie together, and which getters to use automagically. Pretty sweet, huh?
You should already have everything you need from your struts download/template/whatever, but
for reference on the HTML taglib, you can find it here: http://jakarta.apache.org/struts/struts-html.html


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Julia Collins
Greenhorn

Joined: Nov 08, 2002
Posts: 7
I already am using <html:text> but have now discovered the problem. I was replacing the form bean with an empty one in my initial action.
Now I have added an if statement to check whether ActionErrors is empty or not.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validate()
 
Similar Threads
DynaValidatorForm not allowing insert.
validation in struts
Validation in Struts 2
Validation
Struts - validate()