Brian,

If you are interested, I just created my first (and VERY basic) taglib to do
this.  The syntax is:

<val:required formName="someFormName"
property="someField">SomeTextToDisplay</val:required>

If you want to lookup if the validation for the Action "/someAction" with
the field "name" is a required field and show an asterisk * next to it, your
tag would be:

<val:required formName="/someAction" property="name">*</val:required>

If you want to lookup if the validation for the ActionForm "someForm" with
the field "website" is a required field and show the words "This field is
required", your tag would be:

<val:required formName="someForm" property="website">This field is
required</val:required>

Quick notes for my tag library v0.0.0.1:

1. Tested on my validation.xml for both an Action and an ActionForm.

2. Fields tested were simple fields - no attempts were make to test it with
indexed, mapped, nested, etc. field types.

3. I have NO idea if I will expand on this as it was initially a "Can I do a
taglib" and "Can I do THAT?" test.  If I receive feedback that seems
significant to me (i.e 10+ individuals), perhaps I'll document it, expand it
appropriately, test it thoroughly, and post it on my (as yet unconstructed)
web site. :)

If you want the simple example class and tld, email directly.

Regards,
David

-----Original Message-----
From: Brian Kuhn [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 26, 2004 6:11 PM
To: [EMAIL PROTECTED]
Subject: Tag to test if a field is required?


Hi all,

I'm using struts 1.1, jstl 1.1, and commons validator 1.1.3.  I'm
trying to find a way to test (inside a jsp) if a given field is
required in the validation rules.  I thought I read about a tag that
does this, but I can't find it now.  Any ideas?

Thanks,
      Brian

Does something like this exist?

<validator:required property="user.first">(required)</validator:required>

---------------------------------------------------------------------
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