Hi,
Struts 1.2.7
I have existing ActionForm and Action classes, whereby validation is done via
the validate() method in the ActionForm bean. These are just basic
validations.
What I want to do is get rid of the validate() method and make use of the
validation framework ( e.g. validation.xml ) instead, and thereby allowing me
to reuse the same validation on both server-side and client-side.
What I am confused about is that validation via the validation.xml seems only
to work ( or so I believe after reading various documentations and samples )
if one uses DynaValidatorForm instead of an ActionForm.
Problem is, my Action classes relies on the ActionForm beans properties, and
having to change to ue DynaValidatorForm means I have to change my Action
classes to use:
dynaForm.get( "propertyName" )
instead of:
form.getPropertyName()
... and I would hate to change all of those Action classes to use a Map
instead of a bean.
Is there a way to use the validation provided by the validation.xml without
using a DynaValidatoForm ?
I presume I would have to use ValidatorForm instead of an ActionForm, but not
sure how to proceed further, or how to make it work.
( Yes, I have validate="true" on my action in struts-config.xml ):
===========================
<form-bean name="campaignForm"
type="com.mig.provisioning.CampaignForm"/>
< ....snip....>
<action path="/addCampaign"
type="com.mig.provisioning.AddCampaignAction"
name="campaignForm"
scope="request"
validate="true"
>
<forward name="success"
path="/viewcampaign.jsp"/>
<forward name="failure"
path="/newcampaign.jsp"/>
</action>
===========================
I also have the following in validation.xml:
===========================
<formset>
<form name="/addCampaign">
<field
property="name"
depends="required">
<arg key="campaignForm.campaignName"/>
</field>
<field
property="countryCode"
depends="required">
<arg key="campaignForm.countryCode"/>
</field>
<field
property="sourceAddress"
depends="required">
<arg key="campaignForm.sourceAddress"/>
</field>
<field
property="moRate"
depends="required,double">
<arg key="campaignForm.moRate"/>
</field>
<field
property="mtRate"
depends="required,double">
<arg key="campaignForm.mtRate"/>
</field>
</form>
===========================
I saw in this article about ValidatorServlet:
http://www.onjava.com/pub/a/onjava/2002/11/13/jsp_servlets.html
... but is was for Struts 1.1, and there is no ValidatorServlet for 1.2.7
Regards,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]