Hi,
I have done the exactly what you provided. I think I am missing something though.
I am getting an error - [ServletException in:/jsp/searchBySystem.jsp] Cannot retrieve definition for form bean null'
Form is:
public final class SearchBySystemForm extends ActionForm {
private ArrayList systems;
private int systemId;
public int getSystemId() {
return systemId;
}
public ArrayList getSystems() {
return systems;
}
public void setSystemId(int i) {
systemId = i;
}
public void setSystems(ArrayList list) {
systems = list;
}
}
My Bean is:
public class System implements java.io.Serializable {
private int systemId;
private String systemName;
/**
* @return
*/
public int getSystemId() {
return systemId;
}
/**
* @return
*/
public String getSystemName() {
return systemName;
}
/**
* @param i
*/
public void setSystemId(int i) {
systemId = i;
}
/**
* @param string
*/
public void setSystemName(String string) {
systemName = string;
}
}
My Action Class is:
public class SearchBySystemAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String forward = "error";
ArrayList systemList = new ArrayList();
SearchBySystemForm systemForm;
systemForm = new SearchBySystemForm();
System system = new System();
system.setSystemId(1);
system.setSystemName("MARS");
systemList.add(system);
system = new System();
system.setSystemId(2);
system.setSystemName("JUPITER");
systemList.add(system);
systemForm.setSystems(systemList);
request.getSession().setAttribute("SYSTEMFORM",systemForm);
forward = "showSystemList";
return (mapping.findForward(forward));
}
My
jsp is:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<title>System List</title>
</head>
<body>
<html:errors/>
<html:form action="/searchBySystem">
<table>
<tr>
<td>System:</td>
<td>
<html:select name="SYSTEMFORM" property="systemId">
<html
ptionsCollection property="systemList" value="systemId" label="systemName"/>
</html:select>
</td>
<td><html:submit>Ok</html:submit></td>
<td><html:cancel>Cancel</html:cancel></td>
</tr>
</table>
</html:form>
</body>
</html>