aspose file tools*
The moose likes Struts and the fly likes s:select Error The requested list key 'encoder' could not be resolved as a collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "s:select Error The requested list key Watch "s:select Error The requested list key New topic
Author

s:select Error The requested list key 'encoder' could not be resolved as a collection

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 582
Newby to struts I am trying to create a simple pull down menu

But I get the following error when I try to render the page:

tag 'select', field 'list', name 'encoder': The requested list key 'encoder' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
org.apache.struts2.components.Component.fieldError(Component.java:237)
org.apache.struts2.components.Component.findValue(Component.java:358)
org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
org.apache.struts2.components.UIBean.end(UIBean.java:510)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.register_jsp._jspx_meth_s_005fselect_005f0(register_jsp.java:257)
org.apache.jsp.register_jsp._jspx_meth_s_005fform_005f0(register_jsp.java:131)
org.apache.jsp.register_jsp._jspService(register_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)

JSP Page register.jsp

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Register</title>
</head>
<body>
<h3>Register Test Bay.</h3>

<s:form action="register">

<s:textfield name="personBean.firstName" label="First name" />
<s:textfield name="personBean.lastName" label="Last name" />
<s:textfield name="personBean.email" label="Email" />
<s:textfield name="personBean.age" label="Age" />

<s:select name="encoder" list="encoder" listKey="encoderId"
listValue="encodeName" headerKey="1" headerValue="Encoder"
label="Select a Encoder"/>
</s:form>

</body>
</html>

package org.apache.struts.register.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts.register.model.Encoder;
import org.apache.struts.register.model.Person;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

Register.java

/**
* Acts as a controller to handle actions
* related to registering a user.
* @author bruce phillips
*
*/
public class Register extends ActionSupport implements Preparable {

private static final long serialVersionUID = 1L;
private ArrayList encoder;

private Person personBean;



public String execute() throws Exception {
return SUCCESS;

}

public Person getPersonBean() {
return personBean;
}

public void setPersonBean(Person person) {
personBean = person;
}

public void setEncoder(ArrayList encoder){
this.encoder = encoder;
}

public ArrayList getEncoder(){
return encoder;
}


public void prepare() throws Exception {
encoder = new ArrayList();
encoder.add(new Encoder(1,"ASCII"));
encoder.add(new Encoder(2,"UniCoder"));
}

}


Encoder.java

package org.apache.struts.register.model;

public class Encoder {
private int encoderId;
private String encoderName;

public Encoder(int encoderId, String encoderName){
this.setEncoderId(encoderId);
this.encoderName = encoderName;
}
public void setEncoderName(String encoderName) {
this.encoderName = encoderName;
}
public String getEncoderName() {
return encoderName;
}
public void setEncoderId(int encoderId) {
this.encoderId = encoderId;
}
public int getEncoderId() {
return encoderId;
}
}


Thanks for any help
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How are you accessing the page?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: s:select Error The requested list key 'encoder' could not be resolved as a collection