<plug-in className="formdef.plugin.FormDefPlugIn"> <set-property property="defnames" value="/WEB-INF/form-defs.xml"/> </plug-in>
|
FAQ
<plug-in className="formdef.plugin.FormDefPlugIn"> <set-property property="defnames" value="/WEB-INF/form-defs.xml"/> </plug-in> <form-definition> <formset> <form name="myForm" beanType="com.my.dto.MyBean"/> </formset> </form-definition>When the plugin gets executed, it will create a DynaActionForm containing the String fields for each property of MyBean. FormDefUtil.setFormValues() :
DynaActionForm dynaForm = (DynaActionForm) FormDefUtil.setFormValues("employeeForm", employee, this, mapping, request); FormDefUtil.getFormValues() (imagine that!):
Employee employee = (Employee) FormDefUtil.getFormValues(form, this, mapping, request); <form-definition> <formset> <form name="myForm" beanType="com.my.dto.MyBean"> <field property="myDouble"/> <converter param="###,###,##0.00"/> </field> </form> </formset> </form-definition>DecimalFormat format strings are used for numeric fields, and DateFormat format strings are used for java.util.Date, java.sql.Date, and java.sql.Timestamp. See the Converters section in the FormDef manual for more information. <global-converters> <global-converter for="property-type" target="java.util.Date" param="MM/dd/yyyy"/> </global-converters> If you use your form in multiple places, a better option might be to write your own Converter. It's very simple. You'll be provided a ConversionContext object which will contain the value to convert and the Class to which it should be converted to. You just return the result of the conversion. <form name="myForm" beanType="com.my.dto.MyBean"> <field name="selectedButton"/> </form>The above declaration will create the myForm form bean with all the fields of MyBean as well as a field for selectedButton .
I want to use the combined FormDef and Validator XML format, but not all of my forms need to be validated. How can I tell Validator to ignore those forms?
<form name="mySimpleForm" validate="false"> <field name="someField"/> </form>When validate="false" is specified, the formdef validator plugin extension will not pass that form definition to the Validator engine.
I have a form whose fields mostly need to be validated, but not all. How can I tell Validator to ignore those fields?
<field name="someField" validate="false"/> <form-definition> <global-converters> <!-- this would be your default format applicable to all Date fields --> <global-converter for="property-type" target="java.util.Date" param="MM/dd/yyyy"/> <!-- define other date conversion parameters and assign names to them --> <global-converter for="converter-name" target="myDateFormat2" param="MMM-yyyy"/> <global-converter for="converter-name" target="myDateFormat3" param="yyyy/MM/dd"/> </global-converters> <formset> <form name="myForm" beanType="com.my.dto.MyBean"> <!-- date2 uses the second format --> <field property="date2"/> <converter name="myDateFormat2"/> </field> <!-- date3 uses the third format --> <field property="date3"/> <converter name="myDateFormat3"/> </field> <!-- MyBean's other fields will all use the default converters and formats --> <!-- there might be a date1 which uses the first format, and that --> <!-- would already be covered by the global Date converter --> </form> <!-- myOtherForm's date fields will all use the default MM/dd/yyyy --> <form name="myOtherForm" beanType="com.my.dto.MyOtherBean"/> </formset> </form-definition> |