Why are you making these fields so complex?  You have

   <html:text value="${sessionScope.subscriber.familyname}"
       property="familyname" name="familyname" maxlength="64"
       size="32"/>

Instead of the simple form:

<html:text property="familyname" maxlength="64" size="32" /> ?

Why do you need to specify all of that redundant information like value and
name when you have the property attribute?  And why are you pulling values
from the session scope instead of the request data that was submitted?  That
seems an unusual choice to my thinking.

Also, what is your html:form action specified there?  Is it listed as
"/changePersonalDataForm"? Or another form name?  Using a different form
might be your problem - after all the html:form uses the bean associated
with that form so a different bean would have different values, especially
if you are mixing and matching values from a session scoped bean with a
request that has its own values.

Regards,
David

-----Original Message-----
From: Tom Bednarz [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 12:34 PM
To: Struts Users Mailing List
Subject: validator and DynaValidatorActionForm


I think the validator fires too early, but probably I am doing something
wrong. Maybe somebody can hp!

I have the following form bean defined in struts-config.xml:

     <form-bean name="changePersonalDataForm"
type="org.apache.struts.validator.DynaValidatorActionForm" >
        <form-property name="subscriberid" type="java.lang.String" />
        <form-property name="firstname" type="java.lang.String" />
        <form-property name="familyname" type="java.lang.String" />
        <form-property name="zip" type="java.lang.String" />
        <form-property name="place" type="java.lang.String" />
        <form-property name="country" type="java.lang.String" />
        <form-property name="addr1" type="java.lang.String" />
        <form-property name="addr2" type="java.lang.String" />
        <form-property name="addr3" type="java.lang.String" />
        <form-property name="email" type="java.lang.String" />
     </form-bean>


and the following action mapping:

     <action
       attribute="changePersonalDataForm"
       input="/form/changePersonalData.jsp"
       name="changePersonalDataForm"
       path="/changePersonalData"
       scope="request"
       type="ch.smartsol.struts.action.ChangePersonalDataAction">
       <forward name="success" path="/template/SuccessMessage.jsp" />
       <forward name="failure" path="/form/changePersonalData.jsp" />
     </action>


The idea is, that I show a form that contains already data and the user
can edit it. When the form is submitted, the validator should check the
user input. Here is my validator configuration:


<form name="/changePersonalData">
   <field property="firstname" depends="required">
     <msg name="required" key="PersonalData.firstname.required"/>
   </field>
   <field property="familyname" depends="required">
     <msg name="required" key="PersonalData.familyname.required"/>
   </field>
   <field property="zip" depends="required">
     <msg name="required" key="PersonalData.zip.required"/>
   </field>
   <field property="place" depends="required">
     <msg name="required" key="PersonalData.place.required"/>
   </field>
   <field property="country" depends="required">
     <msg name="required" key="PersonalData.country.required"/>
   </field>
   <field property="addr1" depends="required">
     <msg name="required" key="PersonalData.addr1.required"/>
   </field>
   <field property="email" depends="required,email">
     <msg name="required" key="PersonalData.email.required"/>
     <msg name="email" key="PersonalData.email.email"/>
   </field>
</form>

Now it seems, that the validator gets fired BEFORE the form is filled!
In the JSP that displays the form, I get lots of error messages all
fired by the 'required' validator saying, that the field must not be
empty, but all fields are filled corretly!!.

Here is an extract of the JSP:

<TABLE border="0" width="95%" align="center">
   <TR>
     <TD class="headerLeftLight" width="200">
        <bean:message key="ChangePersonalData.firstname"/>
     </TD>
     <TD class="dataLightAlignLeft" width="200">
       <html:text value="${sessionScope.subscriber.firstname}"
       property="firstname" name="firstname" maxlength="64"
       size="32"/>
     </TD>
     <TD class="errMessage">
        <html:errors property="firstname"/>
     </TD>
   </TR>
   <TR>
     <TD class="headerLeftStrong">
       <bean:message key="ChangePersonalData.lastname"/>
     </TD>
     <TD class="dataStrongAlignLeft">
       <html:text value="${sessionScope.subscriber.familyname}"
       property="familyname" name="familyname" maxlength="64"
       size="32"/>
     </TD>
     <TD class="errMessage">
       <html:errors property="familyname"/>
     </TD>
   </TR>
   .......

  </TABLE>

Every row contains a label, an input control and a TD to display
validation errors of the specific field.

Does anybody know what is going wrong here??

Many thanks for your help!

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to