struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "O'Shea, Sean" <Sean.O'S...@fmr.com>
Subject JavaScript validation errors
Date Fri, 11 Aug 2006 15:42:58 GMT
Hi all,

I'm using struts 1.2.7 with commons-validator-1.1.4 and I'm running into
a few generated JavaScript errors. Here's what my JSP looks like:

<html:javascript formName="loginForm" />
<html:form action="/login" method="POST">
  <table border="0" cellspacing="5">
    <tr>
      <th align="right">
      	<bean:message key="login.ssn"/>:
      </th>
      <td align="left">
      	<html:text property="SSN"/><bean:message
key="login.correctssn"/>
      </td>
    </tr>
    <tr>
      <th align="right">
      	<bean:message key="login.password"/>:
      </th>
      <td align="left">
      	<html:password property="password"/><bean:message
key="login.correctpw"/>
      </td>
    </tr>
    <tr>
      <td align="right">
      	<input type="submit" value="<bean:message
key="login.button"/>"/>
      </td>
      <td align="left">
      	<input type="reset"/>
      </td>
    </tr>
  </table>
</html:form>

Here's what my action mapping looks like:

		<action path="/login" name="loginForm"
type="LoginAction"
				scope="request" validate="true"
input="login">
.....
		</action>

This is what my form bean looks like:

		<form-bean name="loginForm"
type="org.apache.struts.validator.DynaValidatorForm">
			<form-property name="SSN"
type="java.lang.String" />
			<form-property name="password"
type="java.lang.String" />
		</form-bean>

My form validations look like this:

		<form name="loginForm">
			<field property="SSN" depends="required">
				<arg key="login.ssn" position="0"/>
			</field>
			<field property="password" depends="required">
				<arg key="login.password" position="0"/>
			</field>
		</form>

When I try to submit my loginForm. my server die validations work fine,
but the JavaScript does not get executed. From looking at the generated
source I see this:

<script type="text/javascript" language="Javascript1.1"> 

<!-- Begin 

     var bCancel = false; 

    function validateLoginForm(form) {

        if (bCancel) 
      return true; 
        else 
 var formValidationResult;
       formValidationResult = validateRequired(form); 
     return (formValidationResult == 1);
   } 

    function loginForm_required () { 
     this.a0 = new Array("SSN", "SSN is required.", new Function
("varName", " return this[varName];"));
     this.a1 = new Array("password", "Password is required.", new
Function ("varName", " return this[varName];"));
    } 

Either the JavaScript is not getting called, or the generated JavaScript
does not match up. Could it be something to do with the html:javasctipt
tag? Looking at the source I have for the JavascriptValidatorTag class I
see this version:

 * $Id: JavascriptValidatorTag.java 165208 2005-04-28 21:41:45Z mrdon $ 

All help would be greatly appreciated.

Thanks

Sean 

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


Mime
View raw message