You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Cyber.Zombie" <Cy...@comcast.net> on 2003/07/21 23:27:10 UTC

Validator problem?

While I'm waiting for an answer to my OT: ?, I figured I'd come out and 
ask the question that's been bothering me for a few days.  First, the setup:

Form:  Contains a number of fields.  Indirectly extends ValidatorForm.  
There are some processes in place not necessary for this discussion, but 
cool enough for me to talk about.  I use EJBGen to take the Entity bean 
and produce a ValueObject.  I then use a custom generator that works off 
of the *VO to produce a *FormBase that decorates the VO (composition, 
not inheritance) and allows full Struts integration (handles 
Date->StringDate conversions).  The end Form extends the FormBase and 
adds any requirements needed by the JSP (like readonly lists for 
dropdowns, boolean-String converters for Y/N database columns, etc.)

For the purposes of this discussion, there are 36 attributes.

JSP:  Contains a block of the common fields, followed by some 
<nested:equals> tags to add type-specific information.  NOTE:  This is 
*not* a wizard -- there is no page-by-page progression.  Only one page 
(as the user requires).  The <nested:equals> tag relies on one of the 
form attributes.

Struts:  validation.xml contains one <form> with a number of <field> 
definitions.  Some of these are required.  Some are 'at least one of 2 
checked' required (for which I added a custom Validator method and 
associated <validator> JavaScript).

Problem:  When I submit, Struts returns an error on the server side 
because fields that aren't included in the JSP are marked as required.

The solution I'd like to see is a Validator that only validates on 
fields that are included in the Submit.

A solution that I'm trying to avoid (and may fail) is to duplicate all 
of the common validation rules in validation.xml for each 'type' of 
form.  In struts-config, I'd just add more actions with the same form 
base.  Though I don't know if that would be enough.  I really don't want 
to move away from the single DispatchAction tied to a single Form with 
only 2 struts action defs (w/ and wo/ validation).

Any suggestions?



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