You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brad Balmer <bb...@peapod.com> on 2004/04/09 14:52:47 UTC

DynaValidatorForm help

Using the DynaValidatorForm, how do you get the form variable data out 
of the form inside the action?  All examples I've seen are purely the 
setup and none show the action getting the values.

My struts-config.xml:
        <form-bean
            name="loginForm"
            type="org.apache.struts.action.DynaValidatorForm">
            <form-property name="username" type="java.lang.String"/>
            <form-property name="password" type="java.lang.String"/>
        </form-bean>

My validation.xml:
  <form name="loginForm">
    <field property="username" depends="required">
      <arg0 key="label.username"/>
    </field>
    <field property="password" depends="required">
      <arg0 key="label.password"/>
    </field>
  </form>


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


Re: DynaValidatorForm help

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Cast the ActionForm to a DynaBean and then use get(String property)

Niall


----- Original Message ----- 
From: "Brad Balmer" <bb...@peapod.com>
To: <st...@jakarta.apache.org>
Sent: Friday, April 09, 2004 1:52 PM
Subject: DynaValidatorForm help


> Using the DynaValidatorForm, how do you get the form variable data out 
> of the form inside the action?  All examples I've seen are purely the 
> setup and none show the action getting the values.
> 
> My struts-config.xml:
>         <form-bean
>             name="loginForm"
>             type="org.apache.struts.action.DynaValidatorForm">
>             <form-property name="username" type="java.lang.String"/>
>             <form-property name="password" type="java.lang.String"/>
>         </form-bean>
> 
> My validation.xml:
>   <form name="loginForm">
>     <field property="username" depends="required">
>       <arg0 key="label.username"/>
>     </field>
>     <field property="password" depends="required">
>       <arg0 key="label.password"/>
>     </field>
>   </form>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 


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


Re: DynaValidatorForm help

Posted by Brad Balmer <bb...@peapod.com>.
Thanks for the responses.  I was using the way that you showed.  I 
figured out that my problem was with my struts-config.xml where I should 
have been using:org.apache.struts.validator.DynaValidatorForm instead of 
org.apache.struts.action.DynaValidatorForm.

Adam Hardy wrote:

> DynaValidatorForm dynaForm = (DynaValidatorForm) form;
> String value = (String) dynaForm.get("myFieldName");
>
>
>
> On 04/09/2004 02:52 PM Brad Balmer wrote:
>
>> Using the DynaValidatorForm, how do you get the form variable data 
>> out of the form inside the action?  All examples I've seen are purely 
>> the setup and none show the action getting the values.
>>
>> My struts-config.xml:
>>        <form-bean
>>            name="loginForm"
>>            type="org.apache.struts.action.DynaValidatorForm">
>>            <form-property name="username" type="java.lang.String"/>
>>            <form-property name="password" type="java.lang.String"/>
>>        </form-bean>
>>
>> My validation.xml:
>>  <form name="loginForm">
>>    <field property="username" depends="required">
>>      <arg0 key="label.username"/>
>>    </field>
>>    <field property="password" depends="required">
>>      <arg0 key="label.password"/>
>>    </field>
>>  </form>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>


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


Re: DynaValidatorForm help

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
DynaValidatorForm dynaForm = (DynaValidatorForm) form;
String value = (String) dynaForm.get("myFieldName");



On 04/09/2004 02:52 PM Brad Balmer wrote:
> Using the DynaValidatorForm, how do you get the form variable data out 
> of the form inside the action?  All examples I've seen are purely the 
> setup and none show the action getting the values.
> 
> My struts-config.xml:
>        <form-bean
>            name="loginForm"
>            type="org.apache.struts.action.DynaValidatorForm">
>            <form-property name="username" type="java.lang.String"/>
>            <form-property name="password" type="java.lang.String"/>
>        </form-bean>
> 
> My validation.xml:
>  <form name="loginForm">
>    <field property="username" depends="required">
>      <arg0 key="label.username"/>
>    </field>
>    <field property="password" depends="required">
>      <arg0 key="label.password"/>
>    </field>
>  </form>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
struts 1.2 + tomcat 5.0.19 + java 1.4.2
Linux 2.4.20 Debian


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