You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Mitchell <Ne...@arena-online.com> on 2003/12/04 11:11:58 UTC

Clientside Javascript Validator Problem

 Hi all
 
 I am unable to get validation working in the clientside. It's fine with serverside but will not validate on the clientside.
 Here are my config files and jsp any help would be welcomed. Cheers in advance
 
 JSP
 <%@include file="includes/struts_imports.jsp" %>
 
 <html:html locale="true">
   <head><html:base />
    <title><bean:message key="atr.page.title.researchMain"/></title>
   </head>
   <body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#800000"
   alink="#ff00ff" background="foo.gif">
   <bean:message key="atr.page.title.researchMain"/>  
   <html:javascript formName="searchForm" dynamicJavascript="true" staticJavascript="true" src="staticJavascript.jsp"/>
   <ul>
     <html:messages id="message">
       <li><bean:write name="message"/></li>
     </html:messages>
   </ul>
   <html:form action="quickSearch" onsubmit="return validateSearchForm(this);">
 
   <html:text property="searchName" size="20" />
   <html:select property="searchType" size="1">
     <html:option value="Animal">
       Animal
     </html:option>
     <html:option value="Jockey">
       Jockey
     </html:option>
     <html:option value="Trainer">
       Trainer
     </html:option>
     <html:option value="Owner">
       Owner
     </html:option>
   </html:select> <html:reset property="resetSearchName" value="Clear" />
   <html:submit property="submitName" value="Submit"/>
 
  </html:form>
   </body>
 </html:html>
 
 struts-config
 
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 
 <!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
           "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
 
 <!--
      This is the Struts configuration file for the example application,
      using the proposed new syntax.
 -->
 
 
 <struts-config>
 
   <!-- ========== Form Bean Definitions =================================== -->
   <form-beans>
 
 
    <form-bean       name="searchForm"
                      dynamic="true"
                      type="org.apache.struts.validator.DynaValidatorForm">                     
       <form-property name="searchName" type="java.lang.String"/>
       <form-property name="searchType" type="java.lang.String"/>
     </form-bean>
     
     <!-- Search Results -->
     <form-bean       name="searchResultsForm"
                      dynamic="true"
                      type="org.apache.struts.action.DynaActionForm">
       <form-property name="resultType" type="java.lang.String"/>
       <form-property name="resultList" type="java.util.List"/>
     </form-bean>
         
   </form-beans>
 
   <!-- ========== Global Forward Definitions ============================== -->
   <global-forwards>
     <forward   name="error"              path="/error.jsp"/>
   </global-forwards>
 
   <!-- ========== Action Mapping Definitions ============================== -->
   <action-mappings>
 
     
   <action
     path="/quickSearch"
     type="com.arena.skylla.struts.research.actions.QuickSearchAction"
     scope="request"
     name="searchForm"
     input="/researchHome.jsp"
     validate="true">
     <forward name="Success" path="/action/quickSearchResult"  redirect="true"/>
   </action>
   
   <action
     path="/quickSearchResult"
     type="com.arena.skylla.struts.research.actions.QuickSearchResultAction"
     scope="request"
     name="searchResultsForm"
     validate="false">
     <forward name="Success" path="/quickSearchResult.jsp"/>
   </action>    
  
                     
     <!-- Display the Main Research menu page -->
    <action path="/research" forward="/researchHome.jsp"/>
 
   </action-mappings>
 
 
 
 
   <!-- ========== Message Resources Definitions =========================== -->
   <message-resources parameter="ApplicationResources" null="false"/>
     
   <!-- ========== Plug Ins>  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>
 
 validation.xml
 
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 
 <!DOCTYPE form-validation PUBLIC
           "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
           "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
 
 <!--
     Validation Rules for the Struts Example Web Application
 
     $Id: validation.xml,v 1.8 2003/05/25 22:51:20 dgraham Exp $
 -->
 
 <form-validation>
 
 
     <!-- ========== Default Language Form Definitions ===================== -->
     <formset>
 
         <form name="searchForm">
             <field property="searchName"
                     depends="required, minlength">
                 <arg0   key="prompt.searchName"/>
                 <arg1   key="${var:minlength}" name="minlength"
                    resource="false"/>
                 <var>
                     <var-name>minlength</var-name>
                     <var-value>3</var-value>
                 </var>
             </field>
         </form>
 
     </formset>
 
 
 </form-validation>
 
   
 
Neil Mitchell
Senior Developer
 
E-mail: neil.mitchell@arena-online.com 
Office: +44 (0)1483 306660
Fax: +44 (0)1483 306670
Web: www.arenaleisureplc.com 
Arena Online Services Ltd, Alexandra House, 1-5 Alexandra Terrace, Guildford Surrey, GU1 3DA
**********************************************************************************************************
This e-mail and any attachments may be confidential and/or legally privileged. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. Although Arena Online routinely screens for viruses, addressees should check this e-mail and attachment for any viruses. Arena Online makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).
 


Neil Mitchell
Senior Developer

E-mail: neil.mitchell@arena-online.com 
Office: +44 (0)1483 306660
Fax: +44 (0)1483 306670
Web: www.arenaleisureplc.com 
Arena Online Services Ltd, Alexandra House, 1-5 Alexandra Terrace, Guildford Surrey, GU1 3DA
**********************************************************************************************************
This e-mail and any attachments may be confidential and/or legally privileged. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. Although Arena Online routinely screens for viruses, addressees should check this e-mail and attachment for any viruses. Arena Online makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).



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


Re: Clientside Javascript Validator Problem

Posted by Clark Kent <kr...@yahoo.com>.
Neil,
 
In the SearchForm, I am curious if it extends ValidatorForm, try to extend ActionForm instead to have it to perform client side validation.  Code and configuration appears to be fine.
 
Good Luck,
Allen Martis.

Neil Mitchell <Ne...@arena-online.com> wrote:
Hi all

I am unable to get validation working in the clientside. It's fine with serverside but will not validate on the clientside.
Here are my config files and jsp any help would be welcomed. Cheers in advance

JSP






alink="#ff00ff" background="foo.gif">





   








Animal


Jockey


Trainer


Owner








struts-config



"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

      This is the Struts configuration file for the example application,
      using the proposed new syntax.
 -->








dynamic="true"
type="org.apache.struts.validator.DynaValidatorForm"> 





dynamic="true"
type="org.apache.struts.action.DynaActionForm">















path="/quickSearch"
type="com.arena.skylla.struts.research.actions.QuickSearchAction"
scope="request"
name="searchForm"
input="/researchHome.jsp"
validate="true">



path="/quickSearchResult"
type="com.arena.skylla.struts.research.actions.QuickSearchResultAction"
scope="request"
name="searchResultsForm"
validate="false">















  Configuration ================================== -->



value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>





validation.xml



"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">

     Validation Rules for the Struts Example Web Application
 
     $Id: validation.xml,v 1.8 2003/05/25 22:51:20 dgraham Exp $
 -->








depends="required, minlength">

resource="false"/>

minlength
3











Neil Mitchell
Senior Developer

E-mail: neil.mitchell@arena-online.com 
Office: +44 (0)1483 306660
Fax: +44 (0)1483 306670
Web: www.arenaleisureplc.com 
Arena Online Services Ltd, Alexandra House, 1-5 Alexandra Terrace, Guildford Surrey, GU1 3DA
**********************************************************************************************************
This e-mail and any attachments may be confidential and/or legally privileged. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. Although Arena Online routinely screens for viruses, addressees should check this e-mail and attachment for any viruses. Arena Online makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).



Neil Mitchell
Senior Developer

E-mail: neil.mitchell@arena-online.com 
Office: +44 (0)1483 306660
Fax: +44 (0)1483 306670
Web: www.arenaleisureplc.com 
Arena Online Services Ltd, Alexandra House, 1-5 Alexandra Terrace, Guildford Surrey, GU1 3DA
**********************************************************************************************************
This e-mail and any attachments may be confidential and/or legally privileged. If you are not a named addressee you must not use, disclose, distribute, copy, print or rely on this e-mail. Although Arena Online routinely screens for viruses, addressees should check this e-mail and attachment for any viruses. Arena Online makes no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our clients and business, we may monitor and read e-mails sent to and from our server(s).



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


---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now