[ http://issues.apache.org/jira/browse/VALIDATOR-129?page=all ]
Niall Pemberton updated VALIDATOR-129: -------------------------------------- Bugzilla Id: (was: 38133) Summary: Enhance form to handle nested forms (beans) (was: [validator] [patch] Enhance form to handle nested forms (beans)) Fix Version/s: Validator2 > Enhance form to handle nested forms (beans) > ------------------------------------------- > > Key: VALIDATOR-129 > URL: http://issues.apache.org/jira/browse/VALIDATOR-129 > Project: Commons Validator > Issue Type: Improvement > Components: Framework > Affects Versions: 1.2.0 Release > Environment: Operating System: other > Platform: Other > Reporter: Tomasz Bech > Priority: Minor > Fix For: Validator2 > > Attachments: nested-patch-v1.txt > > > It was initialy discussed in the bug > http://issues.apache.org/bugzilla/show_bug.cgi?id=16394 > but I recognized that the author wanted a little bit different feature. > Generally validator doesn't support validation of nested beans/forms. Current > IndexedListProperty implementation allows it only for one nested bean, it is > not > sufficient for complex forms/beans (many nested levels), it is rather > workaround > than full implementation. It also doesn't correspond to Struts nested tag (and > validator is mainly used by Struts). > Patch is included, it is based on latest validator1.2.0 svn. > Form tag can now include nested tag as (it is in dtd_1.2.1): > <!-- > Defines the nested beans to be validated. Two way of nested beans are > possible: > simple - accessed by property and > 'indexed'- accessed by indexed property. > Nested validation supports any level of nested beans. The idea and > usage > is similar to nested tag in Struts taglib. > The nested element accepts these attributes: > property The property on the JavaBean corresponding to this > nested element. > indexedListProperty > The "indexedListProperty" is the method name that will > return an array or a Collection used to retrieve the > list and then loop through the list performing the > validations on the bean. > type The type/name of the nested bean which will be validated. > The validation rules are described as > standard form tag with the same name > as specified for type. > One and exactly one of property and indexedListProperty can be specified > exclusively. > --> > <!ELEMENT nested (msg|arg|var)*> > <!ATTLIST nested property CDATA #IMPLIED> > <!ATTLIST nested indexedListProperty CDATA #IMPLIED> > <!ATTLIST nested type CDATA #REQUIRED> > Example usage is: > <form-validation> > <global> > <validator name="byte" > classname="org.apache.commons.validator.TestValidator" > method="validateByte" > > methodParams="java.lang.Object,org.apache.commons.validator.Field" > msg=""/> > </global> > <formset> > <form name="complexForm"> > <field property="value" depends="byte"/> > <nested property="subForm" type="subForm1"/> > <nested indexedListProperty="listSubForms" > type="subForm2"/> > <nested indexedListProperty="listComplexSubForms" > type="subFormComplex"/> > </form> > <form name="subForm1"> > <field property="value" depends="byte"/> > </form> > > <form name="subForm2" extends="subForm1"> > </form> > <form name="subFormComplex"> > <field property="value" depends="byte"/> > <nested property="subForm" type="subForm1"/> > <nested indexedListProperty="listSubForms" > type="subForm2"/> > </form> > > </formset> > </form-validation> > There is test included (NestedTest.java), see there NestedTest-config.xml and > how to use nested tag. > Currently I tested it in our STRUTS project, it works correctly for 2 level > nested beans. > Please give me any feedback, reports, bugs, etc. I hope that there is a chance > to have it merged in the source base. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]