You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by otisg <ot...@ureach.com> on 2003/12/01 16:47:29 UTC

Re: ActionMessage(s) + html:messages

Hello,

I still haven't resolved the problem described in the original
email, so here is some sample code that should illustrate the
problem with ActionMessage(s) and html:message tags futher.

The code that uses ActionError(s) works when used with
html:messages tag.
The code that uses ActionMessage(s) does _not_ work with
html:messages tag, even though it looks like it should be
equivalent to the lines that use ActionError(s).

  // ActionErrors errors = new ActionErrors();
  ActionMessages errors = new ActionMessages();
  // errors.add(ActionErrors.GLOBAL_ERROR,
             new ActionError("error.auth.failure"));
  errors.add(ActionMessages.GLOBAL_MESSAGE,
           new ActionMessage("error.auth.failure"));
  // saveErrors(request, errors);
  saveMessages(request, errors);
  return mapping.findForward("failure");


I am using html:messages like this:

          <html:messages id="msg">
            <c:out value="${msg}"/>
          </html:messages>


The above JSP snippet works fine with ActionError(s) code above,
but _not_ with ActionMessage(s) code, which is also above.

Am I doing something wrong here?

Thanks,
Otis



________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


---- On Fri, 28 Nov 2003, otisg (otisg@ureach.com) wrote:

> Hello,
> 
> I am trying to use ActioMessage(s) + html:messages to display
> error and non-error messages in the UI.
> 
> However, my html:message tag is showing only messages set by
the
> validator, and not the messages that I am trying to set
inside
> an Action, like so:
> 
>   ActionMessages errors = new ActionMessages();
>   errors.add(ActionMessages.GLOBAL_MESSAGE, new
> ActionMessage("error.auth.failure"));
>   saveMessages(request, errors);
>   return mapping.findForward("failure");
> 
> In the JSP layer I use html:messages like this:
> 
>       <logic:messagesPresent>
>         <html:messages id="error">
>           <c:out value="${error}"/>
>         </html:messages>
>       </logic:messagesPresent>
> 
> Am I using these two things incorrectly?
> 
> Any help will be appreciated.  I found example usage of
> html:messages in a few Struts-related web pages, but none
> described how it works when you set ActionMessage(s) in an
> Action class.
> 
> Thank you,
> Otis
> 
> 
> 
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
> 
>
---------------------------------------------------------------------
> 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: ActionMessage(s) + html:messages

Posted by Greg Reddin <gr...@fnf.com>.
Joe Germuska wrote:
> if you use:
> 
>>           <html:messages id="msg">
>>             <c:out value="${msg}"/>
>>           </html:messages>
> 
> 
> it will look for an ActionMessages saved with "saveErrors()", not 
> "saveMessages()"

Or change it to:

            <html:messages id="msg" message="true">
              <c:out value="${msg}"/>
            </html:messages>

and it should work.

Greg


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


Re: ActionMessage(s) + html:messages

Posted by Joe Germuska <jo...@germuska.com>.
On Dec 1, 2003, at 9:47 AM, otisg wrote:
>
> Am I doing something wrong here?
>

yes:

>   // saveErrors(request, errors);
>   saveMessages(request, errors);

You shouldn't have changed this part.  The difference between these two 
methods is the request attribute name under which the ActionMessages 
object is saved; read the JavaDoc for Action and the details for 
html:messages for the details, but if you use:
>           <html:messages id="msg">
>             <c:out value="${msg}"/>
>           </html:messages>

it will look for an ActionMessages saved with "saveErrors()", not 
"saveMessages()"

Joe

--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
  "We want beef in dessert if we can get it there."
   -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association