Hi Folks,
I have a class (aka Form Bean) which has a number of variables (39 actually) and I need to copy all the values into a new class (in my case a Bean object). At current I have a setup like so:
private CenterBean convertCenter(CenterForm myForm) {
return new CenterBean(myForm.val1,myForm.val2,myForm.val3 ....);
}
This gets rather messy from a code point of view, how could I clean it up ?
I figured I could pass through the form to the bean constructor, but then I would still want a loop to assign var1 in the form to var1 in the bean....
Can I do something like:
for (int i=0;i < 40;i++){
var = myForm.var;
}
... of course, the variables are not an array. Any thoughts are welcome.
I have a class (aka Form Bean) which has a number of variables (39 actually) and I need to copy all the values into a new class (in my case a Bean object). At current I have a setup like so:
private CenterBean convertCenter(CenterForm myForm) {
return new CenterBean(myForm.val1,myForm.val2,myForm.val3 ....);
}
This gets rather messy from a code point of view, how could I clean it up ?
I figured I could pass through the form to the bean constructor, but then I would still want a loop to assign var1 in the form to var1 in the bean....
Can I do something like:
for (int i=0;i < 40;i++){
var = myForm.var;
}
... of course, the variables are not an array. Any thoughts are welcome.