struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Cantatore <>
Subject java.lang.ClassCastException trying to populate html:select
Date Wed, 02 Jul 2003 22:22:08 GMT
Hi all, I have been working on this for two days and
it's gotten to the point where I cannot see what I did
wrong in the least.  I'm just trying to figure out how
to make it work; the actual program is a bare shell
with the sole purpose of populating a <html:select>. 
There is a RegisterAction,success.jsp, ArrayForm, and

You start by calling, which creates an
ArrayList and puts three ValueInfoBeans in it.  It
then sets ArrayForm to carry the ArrayList, wherein it
is converted to a Collection.  Control is then passed
to success.jsp which tries to read in the Collection
to populate the <html:select>, but instead gives me a
ClassCastException.  Any help would be greatly
appreciated.  Code follows.

public class ValueInfoBean extends ActionForm {

	private String value = null;
	private String info = null;

	public String getValue() {
		return value;

	public void setValue(String v) {
		value = v;

	public String getInfo() {
		return info;

	public void setInfo(String i) {
		info = i;

	public ValueInfoBean() {


	public void reset(ActionMapping mapping,
HttpServletRequest request) {
		value = null;
		info = null;

public class ArrayForm extends ActionForm {

	private Collection theArray = null;

	public Collection getTheArray() {
		return theArray;

	public void setTheArray(ArrayList t) {
		theArray = t;

	public ArrayForm() {


	public void reset(ActionMapping mapping,
HttpServletRequest request) {

		theArray = null;


public class RegisterAction extends Action {

	* Constructor
	public RegisterAction() {


	public ActionForward perform(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws IOException, ServletException {

		ActionErrors errors = new ActionErrors();	

		ArrayList myList = new ArrayList();
		ValueInfoBean myBean = new ValueInfoBean();
		for(int i = 0; i < 3; i++)
			myBean.setInfo(i + "Please work" + i);
		ArrayForm thisArray = new ArrayForm();
		request.setAttribute("beanArray", thisArray);

		return mapping.findForward("success");

and success.jsp:

<html:form action="">
<bean:define id="theArray" scope="request"
name="beanArray" type="java.util.Collection"/>

<html:select property="username" multiple="true">
 <html:options collection="theArray" property="value"


Once again, major thanks to anyone who can help in the


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message