You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Petzsch, Martin" <ma...@capgemini.com> on 2007/08/07 12:50:36 UTC

[S2] Error Message display

Hi,

Short of modifying the template for s:fielderror is there a way to retrieve
just the text of the error message on a JSP?

Even with the theme set to simple I get the following on my jsp:
<ul><li><span class="errorMessage">An Error Message</span></li></ul>

What I want is just the message:
An Error Message

And then I am free to decorate it as I wish.

Equally if you think I am taking the wrong approach to this please let me
know.  The goal is to just display an error message - to the right of the
field and to decorate it with CSS classes of our choice.  Ending up with
something like this:

<input type="text" name="myBean.name" value="" id="name"/>
<span class="myErrorClass">An Error Message</span>

Many thanks!
Martin


Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. 


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


Re: [S2] Error Message display

Posted by mraible <ma...@raibledesigns.com>.
Here's what I've done:

<s:textfield name="company"/> 
<s:property value="fieldErrors['company'][0]"/>

IMO, <s:fielderror> should detect when there's only one error and emit no
<li> tags. I've entered an issue in JIRA for this:

https://issues.apache.org/struts/browse/WW-2090

On a related note, looking at the docs, it looks like you're required to use
<s:param> to specify the field name. Is this true, or can "name" be used for
that?

Thanks,

Matt


Petzsch, Martin wrote:
> 
> 
> Hi,
> 
> Short of modifying the template for s:fielderror is there a way to
> retrieve
> just the text of the error message on a JSP?
> 
> Even with the theme set to simple I get the following on my jsp:
> <ul><li>An Error Message</li></ul>
> 
> What I want is just the message:
> An Error Message
> 
> And then I am free to decorate it as I wish.
> 
> Equally if you think I am taking the wrong approach to this please let me
> know.  The goal is to just display an error message - to the right of the
> field and to decorate it with CSS classes of our choice.  Ending up with
> something like this:
> 
> <input type="text" name="myBean.name" value="" id="name"/>
> An Error Message
> 
> Many thanks!
> Martin
> 
> 
> Capgemini is a trading name used by the Capgemini Group of companies which
> includes Capgemini UK plc, a company registered in England and Wales
> (number 943935) whose registered office is at No. 1 Forge End, Woking,
> Surrey, GU21 6DB. 
> 
> 
> This message contains information that may be privileged or confidential
> and is the property of the Capgemini Group. It is intended only for the
> person to whom it is addressed. If you are not the intended recipient, 
> you are not authorized to read, print, retain, copy, disseminate, 
> distribute, or use this message or any part thereof. If you receive this 
> message in error, please notify the sender immediately and delete all 
> copies of this message.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Error-Message-display-tf4229431.html#a12038118
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: [S2] Error Message display

Posted by "Petzsch, Martin" <ma...@capgemini.com>.
Thanks for that.  This is what I have ended up doing.  It was more
straightforward than I thought it would be anyway.

Kind regards,
Martin


-----Original Message-----
From: Zoran Avtarovski [mailto:zoran@sparecreative.com] 
Sent: 08 August 2007 06:16
To: Struts Users Mailing List
Subject: Re: [S2] Error Message display

I know you mentioned it but I would suggest that the simplest method is to
override the simple theme error tag template filederror.ftl and create a
base that you're happy with. You then have something that is independent of
the core libraries and can easily modify later.

I've had to do this for a number of the simple themed templates and it works
well. 

My only issue is that I'm not a huge fan of freemarker and would prefer to
have the templates in jstl or velocity (There's only so much room in my
little skull)

Z.

> Hi,
> 
> Short of modifying the template for s:fielderror is there a way to
retrieve
> just the text of the error message on a JSP?
> 
> Even with the theme set to simple I get the following on my jsp:
> <ul><li><span class="errorMessage">An Error Message</span></li></ul>
> 
> What I want is just the message:
> An Error Message
> 
> And then I am free to decorate it as I wish.
> 
> Equally if you think I am taking the wrong approach to this please let me
> know.  The goal is to just display an error message - to the right of the
> field and to decorate it with CSS classes of our choice.  Ending up with
> something like this:
> 
> <input type="text" name="myBean.name" value="" id="name"/>
> <span class="myErrorClass">An Error Message</span>
> 
> Many thanks!
> Martin
> 
> 
> Capgemini is a trading name used by the Capgemini Group of companies which
> includes Capgemini UK plc, a company registered in England and Wales
(number
> 943935) whose registered office is at No. 1 Forge End, Woking, Surrey,
GU21
> 6DB. 
> 
> 
> This message contains information that may be privileged or confidential
and
> is the property of the Capgemini Group. It is intended only for the person
to
> whom it is addressed. If you are not the intended recipient,  you are not
> authorized to read, print, retain, copy, disseminate,  distribute, or use
this
> message or any part thereof. If you receive this  message in error, please
> notify the sender immediately and delete all  copies of this message.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


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


Re: [S2] Error Message display

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
I know you mentioned it but I would suggest that the simplest method is to
override the simple theme error tag template filederror.ftl and create a
base that you're happy with. You then have something that is independent of
the core libraries and can easily modify later.

I've had to do this for a number of the simple themed templates and it works
well. 

My only issue is that I'm not a huge fan of freemarker and would prefer to
have the templates in jstl or velocity (There's only so much room in my
little skull)

Z.

> Hi,
> 
> Short of modifying the template for s:fielderror is there a way to retrieve
> just the text of the error message on a JSP?
> 
> Even with the theme set to simple I get the following on my jsp:
> <ul><li><span class="errorMessage">An Error Message</span></li></ul>
> 
> What I want is just the message:
> An Error Message
> 
> And then I am free to decorate it as I wish.
> 
> Equally if you think I am taking the wrong approach to this please let me
> know.  The goal is to just display an error message - to the right of the
> field and to decorate it with CSS classes of our choice.  Ending up with
> something like this:
> 
> <input type="text" name="myBean.name" value="" id="name"/>
> <span class="myErrorClass">An Error Message</span>
> 
> Many thanks!
> Martin
> 
> 
> Capgemini is a trading name used by the Capgemini Group of companies which
> includes Capgemini UK plc, a company registered in England and Wales (number
> 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21
> 6DB. 
> 
> 
> This message contains information that may be privileged or confidential and
> is the property of the Capgemini Group. It is intended only for the person to
> whom it is addressed. If you are not the intended recipient,  you are not
> authorized to read, print, retain, copy, disseminate,  distribute, or use this
> message or any part thereof. If you receive this  message in error, please
> notify the sender immediately and delete all  copies of this message.
> 
> 
> ---------------------------------------------------------------------
> 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