This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Struts 2: Select tag loading error

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
facing the same issue! anybody can suggest a solution?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have the exact same code?!
 
paddy Mahadeva Iyer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!