• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2: Select tag loading error

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have the exact same code?!
 
paddy Mahadeva Iyer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic