Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/04/2010, 01:21
DarkLest
 
Fecha de Ingreso: abril-2010
Mensajes: 1
Antigüedad: 14 años, 1 mes
Puntos: 0
Problema CheckBoxList Struts2

Para alguien que entienda de struts 2, tengo un problema con la etiqueta checkboxlist.

El código de la jsp es el siguiente:

Código:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/alveole-struts2" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagina del Museo</title>
</head>
<body>
<a href="<s:url link="cerrarSesion" />">Cerrar Sesion</a>
<a href="<s:url link="annadirObra" />">Añadir Obra</a>
<a href="<s:url link="borrarObra" />">Borrar Obra</a>

<s:form>
	<s:checkboxlist required="true" key="borrar" list="borrar" name="borrar" value="values" theme="vertical-checkbox"></s:checkboxlist>
	<s:submit value="Borrar"></s:submit>
</s:form>


</body>
</html>

Y el código de la clase action es el siguiente:

Código:
package contenidos;


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;


@SuppressWarnings("serial")
public class GestorContenidos extends ActionSupport {
	
	private File ficheros[];
	private String uploadContentType[]; //The content type of the file
    private String uploadFileName[]; //The uploaded file name
    private List<Obra> obras;
    
    public List<Obra> getObras() {
		return obras;
	}

	public void setObras(List<Obra> obras) {
		this.obras = obras;
	}
	
	private ArrayList<String> values= new ArrayList<String>();

    
    public List<String> getValues() {
		return values;
	}

	public void setValues(ArrayList<String> values) {
		this.values = values;
	}
	
	//Hay que borrar esto solo es una prueba
    private List<String> borrar;
    
	public List<String> getBorrar() {
		return borrar;
	}

	public void setBorrar(ArrayList<String> borrar) {
		this.borrar = borrar;
	}
	//Hasta aqui hay que borrar

	/**
	 * Struts action implementation for node AñadirObra
	 * @return a link to follow
	 */
	public String annadirObra() {
	    return "success";
	}

	/**
	 * Struts action implementation for node ComprobarDatosObra
	 * @return a link to follow
	 * @throws IOException 
	 */
	public String comprobarDatosObra() throws IOException {
		Obra o=new Obra();
		String nombre;
		
		//Hay que pasarle el fichero a obra para que
		//se cree ella misma y se guarde en la BD
		//Y se añada a la lista de obras introducidas
		
		//o.guardarObra(ficheros[0],ficheros[1]);
		
		//nombre=o.getNombre();
		//obras.add(o.mostrarObra(nombre));
		
		
		return SUCCESS;
	}

	/**
	 * Struts action implementation for node borrarObra
	 * @return a link to follow
	 */
	public String borrarObra() {
		
		borrar= new ArrayList<String>();
		borrar.add("Las meninas");
		borrar.add("El 2 de mayo");
		borrar.add("El grito");
		borrar.add("Autorretrato de Van Gogh");
		borrar.add("Venus de Milo");
		
		Iterator<String> iter = values.iterator();
		while (iter.hasNext())
		  System.out.println(iter.next());
		
	    return "success";
	}

	/**
	 * Struts action implementation for node modificarObra
	 * @return a link to follow
	 */
	public String modificarObra() {
	    return "success";
	}
	
	public File[] getFicheros() {
		    return ficheros;
	}
	public void setFicheroDatos(File[] f) {
		   ficheros = f;
	}

	public String[] getUploadContentType() {
		    return uploadContentType;
	}
	public void setUploadContentType(String[] u) {
		   uploadContentType = u;
	}
	public String[] getUploadFileName() {
		    return uploadFileName;
	}
	public void setUploadFileName(String[] up) {
		    uploadFileName = up;
	}


}
Mi problema es que todo parece que funciona bien hasta que leo la consola de eclipse que me da el siguiente error:

"GRAVE: Servlet.service() para servlet default lanzó excepción
tag 'checkboxlist', field 'list', name 'borrar': The requested list key 'borrar' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]"


siendo borrar como se puede ver en la clase action un arraylist, he mirado en todos lados pero no encuentro ninguna solución si alguien me puede ayudar se lo agradecería sobremanera.