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?
Joined: May 17, 2001
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.