Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts 2: Select tag loading error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2: Select tag loading error" Watch "Struts 2: Select tag loading error" New topic
Author

Struts 2: Select tag loading error

Smith Magadia
Greenhorn

Joined: Jun 29, 2005
Posts: 15
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 ]
paddy Mahadeva Iyer
Ranch Hand

Joined: Feb 10, 2007
Posts: 63
facing the same issue! anybody can suggest a solution?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You have the exact same code?!
paddy Mahadeva Iyer
Ranch Hand

Joined: Feb 10, 2007
Posts: 63
Not the exact same code! But the exact same error. But i found the solution also.

I need to specify the fully qualified path to my enum and the method i want to call.



That solved my problem!
Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
paddy Mahadeva Iyer wrote:Not the exact same code! But the exact same error. But i found the solution also.

I need to specify the fully qualified path to my enum and the method i want to call.



That solved my problem!




I don't know how I should have known that. I see that syntax first time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2: Select tag loading error
 
Similar Threads
how the values added from two different browsers can be seen in either of the browsers?
Something wrong with my <s:select>
Need to know if I am doing this right or not
Interceptor messes up action class in Struts2
Map not being resolved (FIXED)