You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2004/06/18 20:10:32 UTC

How To Get the 'initial' in the form-property?

In my struts-config.xml, I provided some initial
values:

     <form-bean
        name="threadForm"
          
type="org.apache.struts.validator.DynaValidatorForm">
          <form-property
            name="sort"
            initial="thread_last_post_date"
            type="java.lang.String"/>
          <form-property
            name="order"
            initial="DESC"
            type="java.lang.String"/>
        </form-bean>    

How do I get the initial value in my servlet that
extends Action?

I tried:

form.get( "sort" );
form.get( "order" );

and 

form.getProperty( "sort" );
form.getProperty( "order" );

The compiler complains "cannot resolve symbol: method
get" and "cannot resolve symbol: method getProperty".

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: How To Get the 'initial' in the form-property?

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Hmm .. in your Action's execute method you should be able to do:

DynaValidatorForm myForm = (DynaValidatorForm) form;
String sort = myForm.get("sort");
String order = myForm.get("order");

This will get the current values on the form -- if the form was just 
created than these will be the initial values.

If you need to reset a DynaActionForm (or subclass) to its initial 
values you can the initialize method:

myForm.initialize(mapping);



Caroline Jen wrote:

> In my struts-config.xml, I provided some initial
> values:
> 
>      <form-bean
>         name="threadForm"
>           
> type="org.apache.struts.validator.DynaValidatorForm">
>           <form-property
>             name="sort"
>             initial="thread_last_post_date"
>             type="java.lang.String"/>
>           <form-property
>             name="order"
>             initial="DESC"
>             type="java.lang.String"/>
>         </form-bean>    
> 
> How do I get the initial value in my servlet that
> extends Action?
> 
> I tried:
> 
> form.get( "sort" );
> form.get( "order" );
> 
> and 
> 
> form.getProperty( "sort" );
> form.getProperty( "order" );
> 
> The compiler complains "cannot resolve symbol: method
> get" and "cannot resolve symbol: method getProperty".
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 


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


Re: How To Get the 'initial' in the form-property?

Posted by Chris Cranford <ch...@tkdsoftware.com>.
If the servlet engine does not see any input at the appropriate scope for
"sort" or "name", it will grab the values automatically for you from the
form-bean initial attribute; otherwise the values on the incoming request
(if in the right scope) will be used and the initial values disregarded.

----- Original Message -----
From: "Caroline Jen" <ji...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Friday, June 18, 2004 2:10 PM
Subject: How To Get the 'initial' in the form-property?


> In my struts-config.xml, I provided some initial
> values:
>
>      <form-bean
>         name="threadForm"
>
> type="org.apache.struts.validator.DynaValidatorForm">
>           <form-property
>             name="sort"
>             initial="thread_last_post_date"
>             type="java.lang.String"/>
>           <form-property
>             name="order"
>             initial="DESC"
>             type="java.lang.String"/>
>         </form-bean>
>
> How do I get the initial value in my servlet that
> extends Action?
>
> I tried:
>
> form.get( "sort" );
> form.get( "order" );
>
> and
>
> form.getProperty( "sort" );
> form.getProperty( "order" );
>
> The compiler complains "cannot resolve symbol: method
> get" and "cannot resolve symbol: method getProperty".
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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