Thanks, Joe and Erik.

I got it to work using the following code:

<html:messages property="userName" id="error" message="false">
   <bean:write name="error" filter="false"/>
</html:messages>

Struts validator returns error object instead of message object.

Thanks!
Lee


On Mon, 8 Nov 2004 16:08:26 -0600, Joe Germuska <[EMAIL PROTECTED]> wrote:
> At 3:49 PM -0600 11/8/04, Struts User wrote:
> 
> 
> >Hello,
> >
> >Currently, I am using struts validator to validate the fields in my
> >ActionForm.
> >
> >Before I updated to struts 1.2.4, I could add an error this way - errors.add(
> >"username", new ActionError("error.username.required"));
> >
> >If the validation failed, the error message for username will be
> >displayed right beside the user name text field if I use <P>Username:
> ><html:text property="username"/></P>.
> >
> >Can someone tell me how to display error message beside an input field
> >using struts validator?
> 
> I've never seen any automatic message placement.  You can access
> messages like this:
> 
> <html:messages property="username" id="msg"></html:messages>
> 
> html:messages is effectively a combination logic/iterator tag.  If
> there are any "username" messages in the ActionMessages object saved
> as the "errors" messages, the body of html:messages will be evaluated
> once for each, with a scripting variable of type String defined with
> the name specified in the "id" attribute.  You can use c:out or
> bean:write to display this value, wrapped with span, div, or other
> tags which format your messages correctly.
> 
> I kind of think someone talked on the list once about making
> something which rendered an HTML "label" tag and which was also
> "smart" about the presence of errors.  I like the idea of something
> like that in general, but wonder if you'd be able to specify
> something suitably general for inclusion in Struts.  Seems like it
> might be better left for local development.
> 
> Joe
> 
> --
> Joe Germuska
> [EMAIL PROTECTED]
> http://blog.germuska.com
> "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn
> back; I'll know I'm in the wrong place."
>    - Carlos Santana
>

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

Reply via email to