Hi,
I have been at this for several days, looked through several forums, and I have yet to find the answer to my problem.
Overview of my scenario:
I have a bean (ModuleBean)that has several fields, one of these fields is a list of another bean (PropertyBean) with several fields as well. In the code I am obtaining a list of ModuleBeans and adding that list to an ArrayList. I am able to properly display the fields that I am interested in on my
JSP page and allow the user to update them, but I can not find a way to send the entire list of ModuleBeans with the updated PropertyBean fields back to my
servlet once the JSP page has been submitted.
Flow of information:
The information is first constructed in the servlet CustomizeAction.java. The customize jsp page is then constructed with the information set by this servlet, which in turn is going to ideally send the information to the SubmitAction.java servlet so I can manipulate that information there.
Result: I continually get the error IllegalArgument: argument type mismatch error where I see the following error.(I do not have access to my precise error message but it is extremely similar to this one, if not exact).
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
.....
.....
Code:
----struts-config.xml------
<form-bean name="dbItnForm" type="mricate.bean.DatabaseItn">
<form-property name="databaseName" type="java.lang.String" />
<form-property name="itnId" type="java.lang.String" />
<form-property name="itnName" type="java.lang.String" />
<form-property name="itnDescription" type="java.lang.String" />
<form-property name="jobId" type="java.lang.String" />
<form-property name="jobName" type="java.lang.String" />
<form-property name="jobStatus" type="java.lang.String" />
<form-property name="itnModules" type="java.util.ArrayList"></form-property>
</form-bean>
<action path="/job/selectItn"
type="mricate.action.CustomizeAction"
parameter="selectItn"
name="dbItnForm"
validate="false"
scope="request">
<forward name="showCustomize" path="page.customize" />
</action>
<action path="/job/submitItn"
type="mricate.action.SubmitAction"
parameter="submit"
name="dbItnForm"
validate="false"
scope="request">
<forward name="showSubmit" path="/do/job/jobStatus"/>
<forward name="showHome" path="page.tiles"/>
</action>
------CustomizeAction.java------
ArrayList filteredList = getFilteredList();
DatabaseItn dbItn = (DatabaseItn)form;
dbItn.setItnModules(filteredList);
ArrayList getFilteredList()
{
ArrayList list = new ArrayList();
for(int i = 0; i < numberOfModuleBeans; i++)
{
list.add(new ModuleBean());
}
return list;
}
------SubmitAction.java---------
DatabaseItn dbItn = (DatabaseItn)form;
ArrayList list = dbItn.getItnModules();
-----DatabaseItn.java----(Master Bean)---
There are several fields in this Bean but I am only interested in the one that I am going to show below. The last two methods I created so that the "id" attribute of the iterate tag can properly access the ArrayList.
private ArrayList itnModules = new ArrayList();
public ArrayList getItnModules()
{
return this.itnModules;
}
public void setItnModules(ArrayList itnModules)
{
this.itnModules = itnModules;
}
public ModuleBean getModules(int index)
{
if(index >= itnModules.size())
{
while(itnModules.size() <= index)
{
itnModules.add(new ModuleBean());
}
}
return (ModuleBean)itnModules.get(index);
}
public void setModules(int index, ModuleBean mb)
{
if(index < itnModules.size())
{
itnModules.set(index, mb);
}
else
{
itnModules.add(mb);
}
}
------ModuleBean.java-----(First Level of Bean)----
String displayName;
String description;
PropertyBean[] properties;
getter and setter methods for each field.
------PropertyBean.java---(Second Level of bean)----
String displayName;
String description;
String value;
Integer typeId;
getter and setter methods for each field.
-------Customize JSP----------
<html:form action="/job/submitItn" method="post">
<logic:iterate id="modules" name="dbItnForm" property="itnModules">
<bean:write name="modules" property="displayName"/>
<nested:iterate name="modules" property="properties">
<nested:write property="displayName"/>
<nested:text property="value" indexed="true"/>
</nested:iterate>
</logic:iterate>
<html:submit>Submit Job</html:submit><html:reset value="Reset Job Parameters"/>
</html:form>