Great article!
I'm fairly new to Struts and am still struggling with ActionForm setters/getters vs.
bean setters/getters. In your template file, all properties for both the form and bean
are Strings. How would you implement an int property -
In the form, it would it be -
public String getProperty10() {
return(this.property10);
}
public void setProperty10(String property10) {
this.property10 = property10;
}
public int getProperty10Int() {
return this.property10.intValue();
}
In the bean, would it be? -
int property10Int = 0;
public int getProperty10Int() {
return(this.property10Int);
}
public void setProperty10Int(int property10) {
this.property10Int = property10;
}
If this is the case, how do you copy the properties from the FormBean to the Bean when
the Action is done and validated?
MyForm frm = (MyForm)form;
MyBean bean = <Should the bean be in the session?>;
/** What if I have 100 properties, is there a better way to set them all? **/
bean.setProperty0(frm.getProperty0());
.
.
.
bean.setProperty10Int(frm.getProperty10Int());
bean.writeToDatabase();
Is this the best way to mesh all of this together?
Thanks for all the hard work. It's a very valuable article.
Ryan
>>> [EMAIL PROTECTED] 06/17/01 05:34PM >>>
A new article regarding building Struts applications is available at
< http://www.husted.com/about/struts/ >
entitled Strut by Strut. Feedback is welcome. A followup article
regarding using a database with Struts ("Stepping Out") is nearly
complete. Stay tuned.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/