You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anand Raman <an...@mymailbag.com> on 2001/01/30 16:22:34 UTC

options tag

hi guys
I have the following case.

My ActionForm has a ArrayList called artistCollection which gets
populated with Artist objects in the Action class.

I now have to generate a select box using this ArrayCollection.

The jsp page has the following code to populate the drop down box.

<html:select property="artistId1"> 
	<html:options property="artistCollection"/> 
</html:select>


However this is generating a ClassCastException error. Can any one tell me whats going on
here.. I need to generate the dropdown box with artist id as the value
of the options.

I am also enclosing some portions of my code

Thanks for your assistance
Anand 

/** ActionForm **/
package net.arttoday.admin;
import java.util.*;
import org.apache.struts.action.*;
import net.arttoday.admin.*;

public class ExhibitForm extends ActionForm {
	/*
		....
	*/
	private ArrayList artistCollection = null;

	public void setArtistCollection(ArrayList artistCollection) {
		this.artistCollection = artistCollection;
	}

	public ArrayList getArtistCollection() {
		return artistCollection;
	}
}

/** Action **/

package net.arttoday.admin;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.sql.*;
import com.javaexchange.dbConnectionBroker.DbConnectionBroker;

public class ExhibitAction extends Action {
	public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
		/*
			...
			...
		*/
		ArrayList tempArtistCollection = new ArrayList();
		while(rset1.next()) 
			tempArtistCollection.add(new Artist(rset1.getInt(1),rset1.getString(2)));

		exhForm.setArtistCollection(tempArtistCollection);
		return mapping.findForward("screen1");
	}
}

/** screen1.jsp **/
<html:select property="artistId1"> 
	<html:options property="artistCollection"/> 
</html:select>