You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Ranjangaonkar, Vaibhav (HQP)" <Va...@rhi.com> on 2003/06/24 23:52:12 UTC

A Custom tag using and validation ...

Hi all, 
 
I have written a custom tag by extending MessageTag from 
taglib.bean to display a * after a label. This * should 
be displayed after the label if the corresponding property
is specified as 'required' in validation.xml
 
Example : 
 
<valid:label key="label.firstName" 
             property="firstName" 
             formName="subscribeForm" />
 
I can post the code if needed, just wanted to know if there
is already something like this or can this tag be improved.
 
Thanks.

Re: A Custom tag using and validation ...

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
p.s. I'm presenting my <custom:label> tag at TheServerSide Symposium 
this Friday for any of you that will be there.  
http://www.theserverside.com/symposium

	Erik


On Tuesday, June 24, 2003, at 05:52  PM, Ranjangaonkar, Vaibhav (HQP) 
wrote:

> Hi all,
>
> I have written a custom tag by extending MessageTag from
> taglib.bean to display a * after a label. This * should
> be displayed after the label if the corresponding property
> is specified as 'required' in validation.xml
>
> Example :
>
> <valid:label key="label.firstName"
>              property="firstName"
>              formName="subscribeForm" />
>
> I can post the code if needed, just wanted to know if there
> is already something like this or can this tag be improved.
>
> Thanks.


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


Re: A Custom tag using and validation ...

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
I wrote a tag that will do the '*' thing, and also turn the fields a 
different color if they are in error, along with a few other goodies.

There is an open issue for something similar to be added to the Struts 
codebase here:

	http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18015

See the link to Matt's variation of what I originally wrote and see how 
it compares to what you did.  I agree that more in this area is needed. 
  Mine is a bit less verbose than yours:

	<custom:label key="FormName.fieldName"/>

Field labels are in our resources by that key, and by breaking that key 
up a little it figures out the rest from the validator metadata and 
ActionErrors collection.  Even the FormName is a bit redundant since 
its always nested in an <html:form> and thus the form name could be 
gotten from that parent tag (but would be confusing for developers 
later looking at the JSP trying to figure out which key its using since 
you'd have to look at struts-config to figure out the form name).

	Erik


On Tuesday, June 24, 2003, at 05:52  PM, Ranjangaonkar, Vaibhav (HQP) 
wrote:

> Hi all,
>
> I have written a custom tag by extending MessageTag from
> taglib.bean to display a * after a label. This * should
> be displayed after the label if the corresponding property
> is specified as 'required' in validation.xml
>
> Example :
>
> <valid:label key="label.firstName"
>              property="firstName"
>              formName="subscribeForm" />
>
> I can post the code if needed, just wanted to know if there
> is already something like this or can this tag be improved.
>
> Thanks.


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