• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionMessage and showing message to jsp

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am a bit confused by the ActionMessage constructor. I have the following code, and it does work fine. The "errors.wbData" key points to an error message in my properties file, this code runs and the correct message is displayed the the screen.



My question is, should I be sending more than the generic message to the screen? I know that there is another constructor for ActionMessage that takes two strings, but I am not sure what happens to that second string. Also, I know that a struts ModuleException has a getActionMessage() method, should I be using that here instead of constructing a new ActionMessage object?

Thanks!
Kim
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if I wasted anyone's time but I just figured out the answer to my question. It did however bring up a new question. Here goes:

When my Exception is first caught, I contstruct an apache struts ModuleException and then throw that. When I construct it, I give it a key,value pair ("someString",theException.getMessage())

Then, when I catch THAT thrown exception, I can just use the ActionMessage from that exception to get the correct message from my properties file as follows:


This correctly shows the error I expect to see on the page, and it allows me to have a differant message depending on what exception was thrown.

My NEW question is, when I create the struts ModuleException, I give it the key and value, I see how the key is used to pull the message out of the properties file, but how is the value (theException.getMessage()) ever used ? Should I get to it, using Actionmessage.getValues()? I imagine I would not want to send that much info to the screen, so I am wondering is it a part of the ActionMessage object so I can log it after catching it? Just wondering what to do with the value of the key/value pair.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic