You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Calfo <fr...@csgpro.com> on 2003/12/06 03:18:13 UTC

messages tag not displaying messages

The messages tag supposed to display all the messages automatically ?

When I place this on the JSP, the messages do not display:

     <%@taglib prefix="html" uri="/struts-html"%>

     <html:messages id="resultMsg" name="ATTR_ACTION_MESSAGES"/>

I know that the message key is correct, the message resource file can be 
found, and the messages collection has been properly placed in the request, 
etc. etc. because if I add (below that line) this tag:

     <bean:write name="resultMsg"/>

to the page, then the message does display.  But I shouldn't have to do 
that, right ?

Since adding the bean:write tag does display a message from the collection, 
this does not appear to be a basic setup issue.  It's more a question about 
the intended behavior of the messages tag.

Why doesn't this usage of the messages tag <html:messages id="resultMsg" 
name="ATTR_ACTION_MESSAGES"/> automatically display all messages in the 
collection ?


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: messages tag not displaying messages

Posted by Richard Yee <ry...@cruzio.com>.
Frank,
I believe you want to use the <bean:messages ...../> tag.  There isn't an 
<html:messages> tag.

-Richard

At 06:18 PM 12/5/2003, you wrote:

>The messages tag supposed to display all the messages automatically ?
>
>When I place this on the JSP, the messages do not display:
>
>     <%@taglib prefix="html" uri="/struts-html"%>
>
>     <html:messages id="resultMsg" name="ATTR_ACTION_MESSAGES"/>
>
>I know that the message key is correct, the message resource file can be 
>found, and the messages collection has been properly placed in the 
>request, etc. etc. because if I add (below that line) this tag:
>
>     <bean:write name="resultMsg"/>
>
>to the page, then the message does display.  But I shouldn't have to do 
>that, right ?
>
>Since adding the bean:write tag does display a message from the 
>collection, this does not appear to be a basic setup issue.  It's more a 
>question about the intended behavior of the messages tag.
>
>Why doesn't this usage of the messages tag <html:messages id="resultMsg" 
>name="ATTR_ACTION_MESSAGES"/> automatically display all messages in the 
>collection ?
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: messages tag not displaying messages

Posted by Richard Yee <ry...@cruzio.com>.
Frank,
Please disregard the last message. I wasn't paying attention and was 
looking at the Struts 1.0 docs instead of Struts 1.1.

If you are using ActionMessages, then in your action, you'd have something 
like this:

ActionMessages messages = new ActionMessages();
ActionMessage msg = new ActionMessage("data.ok");
messages.add("message1", msg);

msg = new ActionMessage("data.continue");
messages.add("message2", msg);

saveMessages(request, messages);

and in your JSP, to print out all of the messages, you would use this:

<html:messages id="msg" message="true">
<bean:write name="msg"/><br>
</html:messages>

The id param sets up the bean for the bean:write
The message param = true indicates that the bean will be obtained using 
Globals.MESSAGE_KEY instead of Globals.ERROR_KEY

To find out more, check out this article:
http://javaboutique.internet.com/tutorials/excep_struts/index-2.html

Regards,

Richard
At 06:18 PM 12/5/2003, you wrote:

>The messages tag supposed to display all the messages automatically ?
>
>When I place this on the JSP, the messages do not display:
>
>     <%@taglib prefix="html" uri="/struts-html"%>
>
>     <html:messages id="resultMsg" name="ATTR_ACTION_MESSAGES"/>
>
>I know that the message key is correct, the message resource file can be 
>found, and the messages collection has been properly placed in the 
>request, etc. etc. because if I add (below that line) this tag:
>
>     <bean:write name="resultMsg"/>
>
>to the page, then the message does display.  But I shouldn't have to do 
>that, right ?
>
>Since adding the bean:write tag does display a message from the 
>collection, this does not appear to be a basic setup issue.  It's more a 
>question about the intended behavior of the messages tag.
>
>Why doesn't this usage of the messages tag <html:messages id="resultMsg" 
>name="ATTR_ACTION_MESSAGES"/> automatically display all messages in the 
>collection ?
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org