commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38133] New: - [validator] [patch] Enhance form to handle nested forms (beans)
Date Thu, 05 Jan 2006 12:01:31 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38133>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38133

           Summary: [validator] [patch] Enhance form to handle nested forms
                    (beans)
           Product: Commons
           Version: 1.2 Final
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Validator
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: tomasz.bech@bull.com.pl
                CC: dev@struts.apache.org


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.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message