Hi everyone,
This is my first post. Any help on this is much appreciated. I've been reading in
Struts Forum about the proper usage of <html:select>, <html
ptions>, <html
ptionsCollection>, etc, honestly I am still confused. I am getting "cannot find bean: EMPLOYEELIST in any scope" error message. Can any of your struts experts tell me what I am doing wrong? Here is my code:
JSP:
<html:form action="/search">
<table>
<tr>
<td align="right"><bean:message key="label.search.name"/>:</td>
<td>
<html:select property="employee">
<html
ptionsCollection name="EMPLOYEELIST" value="ssNum" label="name"/>
</html:select>
</td>
Struts-config.xml
<form-beans>
<form-bean name="searchForm"
type="com.jamesholmes.minihr.SearchForm">
</form-bean>
</form-beans>
<!-- Global Forwards Configuration -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>
<!-- Action Mappings Configuration -->
<action-mappings>
<action path="/search"
type="com.jamesholmes.minihr.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
</action>
</action-mappings>
Action:
public final class SearchAction extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
EmployeeSearchService service = new EmployeeSearchService();
ArrayList results;
ArrayList empList;
SearchForm searchForm = (SearchForm) form;
empList = service.getEmployeeList();
searchForm.setEmployees(empList);
request.getSession().setAttribute("EMPLOYEELIST",searchForm);
// Forward control to this Action's input page.
return mapping.getInputForward();
}
}
Form:
public class SearchForm extends ActionForm
{
private ArrayList employees = new ArrayList();
private
String employee;
public String getEmployee() {
return employee;
}
public void setEmployee(String employee) {
this.employee = employee;
}
public ArrayList getEmployees() {
return employees;
}
public void setEmployees(ArrayList employees) {
this.employees = employees;
}
Bean:
public class Employee
{
private String name;
private String ssNum;
public Employee(String name, String ssNum) {
this.name = name;
this.ssNum = ssNum;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
}
public String getSsNum() {
return ssNum;
}
}
Please help, thanks.