• 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

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

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
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
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
 
David Newton
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
How are you accessing the page?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic