Hi,
I'm new in
Struts 2 and any help would be greatly appreciated. I'm having an error loading a dynamic Select tag. Below is the error message and also the snippet of codes:
Error:
tag 'select', field 'list', id 'employeeType', name 'employee.employeeType': The requested list key 'employeeTypes' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
JSP:
<s:select id="employeeType" name="employee.employeeType" label="Type" list="employeeTypes" listKey="id" listValue="type" emptyOption="true"/>
EmployeeAction:
public EmployeeAction(EmployeeService service, EmployeeTypeService employeeTypeService) {
this.service = service;
this.employeeTypeService = employeeTypeService;
}
public
String execute() {
this.employees = service.findAll();
this.employeeTypes = employeeTypeService.findAll();
return Action.SUCCESS;
}
public List<EmployeeType> getEmployeeTypes() {
return employeeTypes;
}
public void setEmployeeTypes(List<EmployeeType> employeeTypes) {
this.employeeTypes = employeeTypes;
}
Employee.java
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name="employeeTypeId")
private EmployeeType employeeType;
public EmployeeType getEmployeeType() {
return employeeType;
}
public void setEmployeeType(EmployeeType employeeType) {
this.employeeType = employeeType;
}
EmployeeType.java:
@Entity
public class EmployeeType {
@Id
@GeneratedValue
private Integer id;
private String type;
private String description;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
Note:
Displaying all Employees is no problem, it can display all together with the EmployeeTypes, so JPA annotation problem is eliminated. Its the loading in Select tag for EmployeeTypes is the problem. Anyone who is expert on this please help me.
Thanks,
Smith Magadia
[ June 18, 2008: Message edited by: Smith Magadia ]