struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Caswell" <scasw...@allconnect.com>
Subject DynaForm mapped property client-side validation problem
Date Tue, 22 Jul 2003 18:35:42 GMT
Using Struts 1.1.0, I'm having a problem with client-side validation of a map-backed property
on a DynaValidationForm. The Javascript fails because of naming the form field using the map
syntax. Here is my configuration:

I have the following DynaValidatorForm configured in struts-config.xml:

    <form-bean
      name="bean2DynaValidatorForm"
      type="org.apache.struts.validator.DynaValidatorForm"
    >
      <form-property
        name="longmap"
        type="java.util.HashMap"
      />
    </form-bean>

I have the following validation defined for this form in validator.xml:

    <form name="bean2DynaValidatorForm">
      <field
        property="valueD"
        indexedProperty="longmap"
        depends="required,long"
      >
        <arg0 key="longmap.valueD.prompt"/>
      </field>
      <field
        property="valueE"
        indexedProperty="longmap"
        depends="long"
      >
        <arg0 key="longmap.valueE.prompt"/>
      </field>
    </form>

And on the .jsp:

<html:form 
  action="Bean2DynaValidatorFormAction.do" 
  onsubmit="return validateBean2DynaValidatorForm(this);">
ValueD: <html:text property="longmap(valueD)"/>
<logic:messagesPresent>
 <html:errors property="longmap(valueD)"/>
</logic:messagesPresent>
<br>
ValueE: <html:text property="longmap(valueE)"/>
<logic:messagesPresent>
 <html:errors property="longmap(valueE)"/>
</logic:messagesPresent>
<br>
<html:submit/>
</html:form>
<html:javascript formName="bean2DynaValidatorForm"/>

The problem is that the client-side Javascript validation fails to complete because the dynamic
Javascript that gets generated is:

    function required () { 
     this.aa = new Array("valueC", "???en_US.valueC.prompt??? must be entered", new Function
("varName", " return this[varName];"));
     this.ab = new Array("valueD", "Value D must be entered", new Function ("varName", " return
this[varName];"));
    } 

The reason the Javascript fails is that the name of the field for the second line above should
be "longmap(valueD)", but the html:javascript tag builds it with just the key name, so the
validateRequired() function fails when it tries to find a field with that name ("valueD").

I've looked all around the documentation and the mailing list archives, and I don't see anything
specific to this case. Am I missing something, or is this a shortcoming of the html:javascript
tag?

TIA.

Steve Caswell
scaswell@allconnect.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message