Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

initialize an array of data to dynamic form bean

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://javaboutique.internet.com/tutorials/Dynaform/index-5.html
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic