struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hubert Rabago <>
Subject Re: [OT] Struts + AJAX Trumps JSF
Date Fri, 14 Oct 2005 15:57:15 GMT
On 10/14/05, Michael Jouravlev <> wrote:
> Some nice scripting without Ajax, just Javascript and CSS:
> I wish Struts Validator could be that cool :-)

It CAN be.  I spent some time last night figuring out the
javascript/struts tags portion of it, but now I'll have to actually
know how Validator works to hook it up with what I have so far.

The idea is you have a set of controls dedicated to a particular
field.  For starters, this is what I have:

<html:label property="firstName">First Name</html:label>
<html:text property="firstName" />
<html:error property="firstName"/><br/>

The <html:label> should be able to support getting its string from
resources of course:
<html:label property="firstName" key="personForm.firstName.label"/>
(Also shows the 'default' key I'm thinking of using if neither text
nor key is provided.)

Also, a tag to enclose related tags will make things easier:

<html:field property="firstName"
  <html:label/>  <!-- default "key" would be used -->

The resulting HTML would look like:
<label for="personForm.firstName"
id="personForm.firstName.label">First Name:</label>
<input type="text" name="firstName" id="personForm.firstName">
<span id="personForm.firstName.error" style="display:none"></span>

Now when the user submits the form, Validator will go through all
fields and figure out which ones pass and which ones are invalid.  If
a property is invalid:
* the label's class can be changed
* the span is shown and is used to show a validation error for that property

It can be done.  I think I'm halfway there, though once I get there
all I'll have is a proof-of-concept using a custom set of tags which
won't allow you to use custom "id" values.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message