It's not a secret anymore!*
The moose likes Struts and the fly likes ActionMessages not found under  'messages' 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 "ActionMessages not found under  Watch "ActionMessages not found under  New topic
Author

ActionMessages not found under 'messages'

andrew low
Greenhorn

Joined: Mar 22, 2005
Posts: 18
Hi All,

I am creating some action errors / action messages and attempting to save them so I can access them in the JSP from which posted to the Action. I seem to be able to detect whether the errors are there or not with

<logic:messagesPresent>

but I get an exception with

<bean:write name="message"/>
javax.servlet.jsp.JspException: ServletException in '/jsp/icicle/CandidateForm.jsp': Cannot find bean message in any scope

This is really confusing - I appear to have the same setup on another form that works fine (I did a lot of trial and error to get that to work...)

Code snippets follow...

Many thanks for any pointers.

Andrew

//Makes ActionMessages from a hashmap
errors = com.xx.struts.Utils.actionMessages( cb.validate() );
if ( !errors.isEmpty() )
{
// Save my errors to make them availble upon repost.

//addMessages(servletRequest, errors);
//saveMessages(servletRequest.getSession(), errors);

addErrors(servletRequest, errors);
saveErrors(servletRequest, errors);

return actionMapping.getInputForward();
}


<logic:messagesPresent>
<html:messages id="message">
<li><bean:write name="message"/></li>
</html:messages>
</logic:messagesPresent>
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
I use these tags:



message - is whether or not they are errors or not, by the way, if your ActionForward is set to redirect, you will lose all messages.


http://www.goodercode.com
SCJP 1.4
andrew low
Greenhorn

Joined: Mar 22, 2005
Posts: 18
OK, so it transpires that I've been adding in ActionMessages as thinking of them as Simply strings that will be displayed, rather than keys to look up values from the ApplicationResources.properties file. I assume there is some way to add ActionMessages from scratch without referring to this file, but it appears to have evaded me.

Cheers

A
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionMessages not found under 'messages'
 
Similar Threads
Using ActionMessages to display Errors using errors.headers and errors.footers
Handling Messages (v1.2.9)
ActionMessages causing me great distress
Not able to display ActionMessges
Issues with <html:messages >