Can anyone avise me on how to populate my formbean with the values in the html:multibox element.
I do a search for a client and return a list of clients. Each client has a checkbox associated with them. If I tick one or few of the checkboxes then submit the form my action class throws a nullpointer because the
string array which holds the multibox values has not been populated.
In my
jsp I have the following:
<html:form action="/actionClient"
name="actionClientForm"
type="com.web.forms.ActionClientForm">
<logic:iterate id="client" name="searchClientForm" property="results">
<td width="14%">
<div align="center">
<html:multibox property="resourceIds">
<bean:write name="client" property="resourceId"/>
</html:multibox>
</div>
</td>
the results property of searchClientform holds a list of clientVOs. The clientVO has a field resourceId. please note that clientVO has filed resourceID and action client form has field resourceIds.
The actionclientform is as follows:
private String [] resourceIds = {};
/**
* @return Returns the resourceIds.
*/
public String[] getResourceIds() {
return resourceIds;
}
/**
* @param resourceIds The resourceIds to set.
*/
public void setResourceIds(String[] resourceIds) {
this.resourceIds = resourceIds;
}
my
struts config action mapping is as follows:
<action path="/actionClient"
type="com.web.action.ActionClientAction"
name="actionClientForm"
scope="request"
input="/searchClient.jsp">
<forward name="edit" path="/createClient.jsp"/>
</action>
The error thrown is:
java.lang.NullPointerException
com.medina.web.action.ActionClientAction.execute(ActionClientAction.java:44)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
The code throws a null pointer on the following line:
ActionClientForm clntForm = (ActionClientForm)actionForm;
System.out.println("resource Id = " + (clntForm.getResourceIds()).length);
So can anyone tell mewhat I am doing wrong and how to pass the value to my action class
thanks in advance