You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Aladin Alaily <st...@aladin.ca> on 2005/11/18 21:03:24 UTC

Is there an easy way to print error messages

Hello,

I am using struts 1.2.7 and am having trouble outputing error messages for
specific fields.

If I have the following (in a form):

<html:input property="name" />

and in my action I do something like:

messages.add("name", new ActionMessage("error.name.required"));
super.saveErrors(request.getSession(), messages);


Now, I would expect that the error message be outputted to the right of
the textfield (<input..> Error message here), but it doesn't.

Does anyone know if things have changed in 1.2.7... or am I missing
something here?

Thanks!
Aladin


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


Re: Is there an easy way to print error messages

Posted by Martin Gainty <mg...@hotmail.com>.
*Assuming* ApplicationResources.properties contains
In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail 
address.</strong></font>

If your key value isnt pointing to errors.email then it should be pointing 
to a bundle specification for your ApplicationResources file which contains 
that key
<message-resources bundle="label.screen3.emailAddress" 
parameter="ApplicationResources"/>

/*Now specify the exact key parameter to reference in the bundle in your 
jsp*/
<bean:message bundle="label.screen3.emailAddress" key="errors.email"/>

HTH,
Martin-
----- Original Message ----- 
From: <bs...@psl.nmsu.edu>
To: <us...@struts.apache.org>
Sent: Friday, November 18, 2005 3:52 PM
Subject: RE: Is there an easy way to print error messages


Yeah, I do it this way:

In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail 
address.</strong></font>

And in the jsp:
<tr>

<td width="200" align="right"><bean:message 
key="label.screen3.emailAddress"/>:</td>

<td><html:text property="emailAddress"/></td><td><html:errors 
property="emailAddress"/></td>

</tr>

On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages 
> > for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >

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



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


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


RE: Is there an easy way to print error messages

Posted by bs...@psl.nmsu.edu.
Yeah, I do it this way:

In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail address.</strong></font>

And in the jsp:
<tr>

<td width="200" align="right"><bean:message key="label.screen3.emailAddress"/>:</td>

<td><html:text property="emailAddress"/></td><td><html:errors property="emailAddress"/></td>

</tr>

On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >

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



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


Re: Is there an easy way to print error messages

Posted by Hubert Rabago <hr...@gmail.com>.
Yes it's Friday indeed (TG).  For the benefit of you out there
searching the archives, you can accomplish this by using <html:errors
property="name" /> .  You can get more information here:
http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

Hubert

On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >

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


Re: Is there an easy way to print error messages

Posted by Aladin Alaily <st...@aladin.ca>.
Problem solved... must be Friday.

Aladin


> Hello,
>
> I am using struts 1.2.7 and am having trouble outputing error messages for
> specific fields.
>
> If I have the following (in a form):
>
> <html:input property="name" />
>
> and in my action I do something like:
>
> messages.add("name", new ActionMessage("error.name.required"));
> super.saveErrors(request.getSession(), messages);
>
>
> Now, I would expect that the error message be outputted to the right of
> the textfield (<input..> Error message here), but it doesn't.
>
> Does anyone know if things have changed in 1.2.7... or am I missing
> something here?
>
> Thanks!
> Aladin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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