Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 1.0 errors - need quick help

 
Matt Sloan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


My jsp:


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 />

#-- WebRoads --

errors.duplicate.closedDay= Closed Day{0} already exists

and my web.xml:


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.

Please help!!!

TIA
 
Matt Sloan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 />
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
msloan

Welcome to Javaranch!

We don't have too many rules around here but we do have a Naming Policy. Please read this and adjust your display name accordingly.

Thanks.
 
Matt Sloan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David, thanks for the advice - switched everything over to ActionErrors and ActionError - used the <html:errors/> tag - works perfect!

Gregg - changed the name - Sorry about that.

Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic