goal: I want to submit an array of Fonbean(java class file listed below) to an action
strategy: I decide to use html:form and logic:iterate to do this
1.what I have in my configruation xml
<form-beans> <form-bean name="testBeanForm" type="com.mycom.form.TestBeanForm"/>
</form-beans>
<action-mappings> <action path="/testAction" type="com.mycom.action.TestAction" name="testBeanForm" scope="session"> </action> </action-mappings>
2.TestBeanForm.java
public class TestBeanForm extends ActionForm {
public FontBean[] getTestBean() { if(testBean==null) { testBean=new FontBean[2]; testBean[0]=new FontBean(); testBean[1]=new FontBean(); } return testBean; }
public void setTestBean(FontBean[] testBean) { this.testBean = testBean; }
FontBean[] testBean; }
3. FontBean.java
public class FontBean { public int getSize() { return size; }
public void setSize(int size) { this.size = size; }
public String getFontName() { return fontName; }
public void setFontName(String fontName) { this.fontName = fontName; }
private int size; private String fontName;
}
4. my jsp file
<html:form action="/testAction.do">
<logic:iterate name="testBeanForm" property="testBean" type="com.mycom.bean.propertybean.FontBean" id="mybean" indexId="index1">
<html:text name="mybean" property="fontName" value="font1" indexed="true"/>
/* I think when I submit, the testBeanForm will automatically fill its testBean's elements of their fontName attributes with "font1" */
</logic:iterate> <html:submit property="submitValue">Submit Changes</html:submit> </html:form>
5.my action class file
public class TestAction extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm form,
HttpServletRequest servletRequest,
HttpServletResponse servletResponse) throws Exception
{
System.out.println("stepped into action");
TestBeanForm bform=(TestBeanForm)form;
/*I stopped here to check if the form has its testBean variable filled with
"font1" of its fontName attribute, but it doesnt, the testBean of form is just the object I created in getTestBean(),that is, contains two elements, both the fontName attributes of the two elements are null */
return actionMapping.findForward("error");
}
}
so what on earth is the problem?
Thanks&Regards Mike
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]