File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How To Get the 'initial' From the form-property? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How To Get the Watch "How To Get the New topic
Author

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

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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".
[ June 18, 2004: Message edited by: JiaPei Jen ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

//Cast the form
DynaValidatorForm dynaForm = (DynaValidatorForm)form;

//Get the properties
dynaForm.getDynaProperty( "sort" );
dynaForm.getDynaProperty( "order" );


A good workman is known by his tools.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How To Get the 'initial' From the form-property?