I did elaborate in a code snippets. The <html:messages> tag is designed to
have a body, and process it iteratively - in your example it will iterate
over all messages with a property "x" processing the body of the tag for
each message it finds. The reason your code works is by accident - it stores
each message under the page scope variable you specify - it just so happens
that after its finished processing its body the last one still exists -
making your code work (sort of) - but if you removed the
<logic:messagesPresent> tage you would end up with "Msg=" being displayed
when there were no messages. In your code the <html:messages> tag has no
body - in mine id does....

My suggesstion was that you should replace....

<logic:messagesPresent message="true">
     <html:messages id="msg" message="true" property="x" />
      Msg=<bean:write name="msg" />
 </logic:messagesPresent>

With the following.....

 <html:messages id="msg" message="true" property="x" >
      Msg=<bean:write name="msg" />
 </html:messages>

Niall

----- Original Message ----- 
From: "Betty Koon" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, June 17, 2004 3:19 AM
Subject: RE: Html:messages tag (Resolved)


> I am sorry but I am not clear on what suggestion?  Can you elaborate your
> suggestion in code snippnet.  Thanks.
> In my case, I am sure, I will only have 1 message set up for property x.
>
> -Betty
>
>
> -----Original Message-----
> From: Niall Pemberton [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 16, 2004 7:18 PM
> To: Struts Users Mailing List
> Subject: Re: Html:messages tag (Resolved)
>
>
> This isn't the correct way to use <html:messages>.
>
> It iterates over either all the messages (if you don't specify a property)
> or all messages for a property storing each message as a page scope
> variable. The way your using it it will only display the last message (try
> putting two messages for property "x") - you should really have a closing
> </html:messages> tag:
>
> <html:messages id="msg" message="true" property="x" >
>      Msg=<bean:write name="msg" />
> </html:messages>
>
> Also if you do it this way there's no need for the <logic:messagesPresent>
> tag, unless you want to display some other markup around your errors, such
> as
>
>  <logic:messagesPresent message="true">
>
>     The following errors have occured:</br>
>      <ul>
>
>         <html:messages id="msg" message="true" property="x" >
>             <li>Msg=<bean:write name="msg" /></li>
>        </html:messages>
>
>      </ul>
> </logic:messagesPresent>
>
> Niall
>
> ----- Original Message ----- 
> From: "Betty Koon" <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> Sent: Thursday, June 17, 2004 1:33 AM
> Subject: RE: Html:messages tag (Resolved)
>
>
> > I didn't know I have to do the following: <logic:messagesPresent
> > message="true"> <html:messages id="msg" message="true" property="x" />
> > Msg=<bean:write name="msg" />
> > </logic:messagesPresent>
> >
> > -Betty
> >
> >
> > -----Original Message-----
> > From: Betty Koon [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 16, 2004 5:31 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Html:messages tag
> >
> >
> > I did, it doesn't help.  Nothing get printed out at all.
> >
> > -Betty
> >
> > -----Original Message-----
> > From: Chris Cranford [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 16, 2004 5:27 PM
> > To: Struts Users Mailing List
> > Subject: Re: Html:messages tag
> >
> >
> > Have you tried removing "property" from the messages tag to see if the
> > message you're wanting to print out exists in the collection at all ?
> >
> > Hope this helps!
> > Chris
> >
> > ----- Original Message -----
> > From: "Betty Koon" <[EMAIL PROTECTED]>
> > To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> > Sent: Wednesday, June 16, 2004 8:19 PM
> > Subject: Html:messages tag
> >
> >
> > > Hi All,
> > >
> > > I seem not to be able to get html:message print out the message I
> > > set up
> > in
> > > the action at all.
> > > I have looked at the request attribute, it does contain the
> > > ActionMessages and I was able to retrieve the message for a
> > > particular property in my
> > JSP,
> > > but the tag just doesn't work.
> > >
> > > Here is the code snipplet in my jsp
> > >
> > > <logic:messagesPresent message="true">
> > >
> > > Msg=<html:messages id="msg" message="true" property="x" />
> > >
> > > </logic:messagesPresent>
> > >
> > > The output is always Msg=
> > >
> > > Any idea?  Thanks
> > >
> > > -Betty
> > > -----Original Message-----
> > > From: Ram Venkataswamy [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, June 16, 2004 4:50 PM
> > > To: Struts Users Mailing List
> > > Subject: RE: getInputForward() question
> > >
> > >
> > > Yep, your colleague is right - input attribute is used to re-direct
> > > the control if validation fails - not for Success / user defined
> > > forwards
> > >
> > > V.K.Ram
> > > NitroX Struts Team
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Carl Fyffe [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, June 16, 2004 4:36 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: getInputForward() question
> > >
> > > For the past year or so, I have been using getInputForward() and the
> > > input attribute in the <action> to define the "default" end point
> > > for that
> > action.
> > > I did that because normally there is only one tile for the action to
> > > go
> > to,
> > > so being lazy I wouldn't create a forward I would just use the input
> > > to
> > act
> > > as the default forward.
> > >
> > > Today a colleague informed me that was a poor strategy because the
> > > input
> > is
> > > only for when validation fails.  Am I missusing the input attribute?
> > >
> > > Carl
> > >
> > > --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > > --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > > --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to