struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: Validator FRamework
Date Tue, 05 Sep 2006 16:10:40 GMT
sheetal wrote:
> Hi All,
> I had problem..
> I am trying to implement client side validation  using Validator  
> FRamework.
> I have added validator-rules.xml,  and validation.xml, in my web -inf file.
> And made following entry in validation.xml
> <formset>
> 
>        <form name="runCommandForm">
> 
>            <field property="commandId"
>                    depends="required">
>             <arg0   key="cmdView.errors.required" />
>            </field>
>                         </form>
>     </formset>
> 
> i have also added added an entry in struts config.xml.
> <struts-config>
>  <data-sources />
>  <form-beans >
>    <form-bean name="selectCommandForm" 
> type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" />
>    <form-bean name="runCommandForm" 
> type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" />
>    </form-beans>
> 
>  <global-exceptions />
>  <global-forwards />
>  <action-mappings>
>    <action  path="/selectCommand"
>      
> type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction"
>      scope="request">
>      <forward name="success" path="/JSP/RunCommand.jsp" />
>      <forward name="failure" path="/JSP/Error.jsp" />
>    </action>
>      <action  path="/runCommand"
>      type="com.hns.nme.frontend.apps.cmdexecution.action.RunCommandAction"
>      input="/JSP/RunCommand.jsp"
>      attribute="runCommandForm"
>      name="runCommandForm"
>      scope="request">
>      <forward name="success" path="/selectCommand.do" />
>      <forward name="failure" path="/selectCommand.do" />
>    </action>
>     </action-mappings>
> 
>  <message-resources 
> parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" />
> 
>  <!-- Validator Configuration -->
>    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>      <set-property property="pathnames"
>               
> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
>    </plug-in>
> 
> </struts-config>
> 
> Extended my form class  from ValidatorActionForm.
> AND iN JSP PAGE i HAVE ADDED
> <html:form   action="runCommand"   onsubmit="return 
> validateRunCommandForm(this);"
> also..
> 
> Still it's not working..


Not working how? Does validation fail completely, or only on the client? 
It looks like you may have a mis-match between your form bean base class 
and the way you've specified the validation rules; ValidatorActionForm 
validates based on the action mapping path, not the form name. So, you 
either need to change your validation.xml to something like this:

   <form name="/runCommand" ...

or switch your form beans to be derived from ValidatorForm instead of 
ValidatorActionForm.

If server-side validation is working and it's just client-side 
validation that's not, do you have the html:javascript tag somewhere in 
your page?

L.


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


Mime
View raw message