aspose file tools*
The moose likes Struts and the fly likes initialize an array of data to dynamic form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "initialize an array of data to dynamic form bean" Watch "initialize an array of data to dynamic form bean" New topic
Author

initialize an array of data to dynamic form bean

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I want to initialize an array of data to dynamic form bean. How could I do that ?

I create a static method , GetShoe.getShoe(), which returns an array of Shoe. But I found the "initial" in "form-property" is just for String. So my way doesn't work.

I want to initialize an array of data to dynamic form bean because I want the form has default value when jsp file starts up.

How to work out ?


-----------
<form-bean name="shoeForm"
type= "org.apache.struts.validator.DynaValidatorForm">
<form-property name="shoeList"
type="playground.Shoe[]"
initial="GetShoe.getShoe()"/>
--------------
<action path="/shoe"
type="playground.ShoeAction"
name="shoeForm"
scope="request"
validate="false">
<forward name="success" path="/submit.jsp"/>
</action>
------------------
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
http://javaboutique.internet.com/tutorials/Dynaform/index-5.html


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
From Class FormPropertyConfig API Document:


initial
public java.lang.Object initial()Return an object representing the initial value of this property. This is calculated according to the following algorithm:

If the value you have specified for the type property represents an array (i.e. it ends with "[]"):
If you have specified a value for the initial property, ConvertUtils.convert will be called to convert it into an instance of the specified array type.
If you have not specified a value for the initial property, an array of the length specified by the size property will be created. Each element of the array will be instantiated via the zero-args constructor on the specified class (if any). Otherwise, null will be returned.
If the value you have specified for the type property does not represent an array:
If you have specified a value for the initial property, ConvertUtils.convert will be called to convert it into an object instance.
If you have not specified a value for the initial attribute, Struts will instantiate an instance via the zero-args constructor on the specified class (if any). Otherwise, null will be returned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: initialize an array of data to dynamic form bean