You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by awc <aw...@drytel.net> on 2003/03/18 16:03:11 UTC

Beanutils and DynaForm

Hi All,

I trying serve few actions with one Dyna form and one Data Object.

lets say I have class called Contest.

Contest like this...
class Contest {
//get and set methods...
Integer getId();
setID(..);
String getName()
setName(..);
List getCategories()
...
}

List returns instances of Categories

which has getId(), getName() etc...

I get the Contest Data object from my persistence tier...

and I have two screen, one to modify Contest and other to modify
Categories. and one DynaForm.

<form-property  name="id"  type="java.lang.Integer"/>
 <form-property  name="index"  type="int" initial="-100"/>
 <form-property  name="contestName"  type="java.lang.String"/>
<form-property  name="categories"  type="java.util.Collection"/>
<form-property  name="catName"  type="java.lang.String"/>
etc...

On modify.jsp I have one input text field to modify contestName..
just before modify, I do .
                                 -->
BeanUtils.copyProperties(form,model);  and forward to modify.jsp

modify.jsp sends call back to save.
on the save action --> I do.. BeanUtils.copyProperties(model,form);

Since modify.jsp does not have field to hold my collection. My
collection becomes null. All other fields gets initialize. That the way
it works.

I have three choices here..    1. use different Dynaforms.
                                           2. When I copy form to model.
copy only the specific fields.
                                           3. do what you have to with
new model data and reload model from DB


Is there any other way to go...

Thanks for any replies.

.anil


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