Sonali Kulkarni wrote:
Subject: Problem using ActionMessages. Please Help!
  I am in the process of upgrading Struts from 1.0 to 1.2.7 Right now I
am trying to change the error handling bit. However, I get the
following error with the code changes I have made. Please let me know
if any of you can figure out what can fix it.

MY CODE: In the Action Class
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage
("error.warning", "Some Error String"));
saveMessages(request, messages);
return (mapping.findForward("error")); //redirects to error.jsp

If that's really a redirect (redirect="true" in the forward element in struts-config.xml, the default is false), you'll need to save the messages into the session rather than the request; request data isn't preserved across a redirect.

MY CODE: error.jsp
<html:messages id="msss" message="true">
<li><bean:write name="msss" /></li>
</html:messages>

MY CODE: in ApplicationResources.properties
error.error =Error: {0}
error.warning =Warning: {0}

MY CODE: in struts-config.xml (reference to properties file)
<message-resources parameter="ApplicationResources"/>

Have you verified you have the file in the right place? Can you display messages from the resources elsewhere (e.g. using bean:message)?

ERROR I GET >>
javax.servlet.jsp.JspException: Cannot find bean msss in any scope
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:934)
at org.apache.struts.taglib.bean.WriteTag.doStartTag
WriteTag.java:225) at _web_2d_inf._error._jspService(_error.java:116)
[SRC:/WEB-INF/error.jsp:45]

I'm not sure about this; I thought the body of the html:messages tag was only meant to be evaluated if the message was not null; maybe this would happen if there's a key supplied for which no entry was found in the resources, though. Anyone?

<li><bean:write name="msss" /></li> --- Line # 45 in error.jsp

NOTE: If I dont use the Application Resources when creating the
ActionMessage, and use a string instead .. It works!
ActionMessage ae1 = new ActionMessage("This is a ERROR", false); works

That certainly seems to suggest a problem with how you've deployed your application resources. See if you can access them directly using bean:message. If that doesn't work, go through the startup logs and see what Struts says about your resource bundle when it loads it.

HTH,

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to