This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Unfortunately the powers that be have determined that struts 1.0 is what is to be used. With that in mind, I am trying to implement some validation and error handling. So far, I am doing pretty good. My action class is catching the errors, creating the ActionMessages and saving them. The only problem is, my error message isn't being displayed in my jsp.
Here is what I have so far. My action class:
I have also created the following properties file: # -- standard errors -- errors.header=<br><div class="leftSt"><font color="red" id="bigerSt">Validation Error</font></div><br><span class="leftSt">The following validation error(s) occurred:</span><UL> errors.prefix=<LI><span class="leftSt"> errors.suffix=</span></LI> errors.footer=</UL><hr align="center" width="90%" noshade />
I think the problem has to do with the application.properties file not being found. I have created a directory called resource at the root of my code directory. Didn't work. I also stuck it in my web-inf directory and modified my web.xml - still didn't work.
Joined: Aug 27, 2004
well I was able to figure it out. I had to replace the <html:errors/> tag in the jsp with the following :
where "errors" is the name of my ActionMessage object defined in my Action class.
The real problem with your code is that you are saving your errors as a message -- not an error. Instead of invoking saveMessages, try saveErrors. Then you don't have to muck about with the errors tag and can simply do as you originally intended -- <html:errors />
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.