Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/05/2010, 09:29
galorn
 
Fecha de Ingreso: abril-2010
Ubicación: L'Hospitalet de LLobregat
Mensajes: 43
Antigüedad: 14 años
Puntos: 0
Pasar ArrayList de controller a .gsp

Hola:

Estoy trabajando con groovy+grails, y este apartado es el que he encontrado mas útil para poner mi duda.
La cuestión es que intento pasar un ArrayList desde el controlador hasta la vista pero al printar me pone null.

Código groovy:
Ver original
  1. class ConversationController {
  2.  
  3.         def mivista = {
  4.                 def i=0;
  5.                 ArrayList<Chat> listaChats= new ArrayList<Chat>();
  6.                 def fichero = "conversationexample.txt"
  7.                 def nombre1=""
  8.                 def comentarios=""
  9.                 boolean salir= false;
  10.                
  11.                 File f = new File(fichero);
  12.                
  13.                 BufferedReader entrada;
  14.                    
  15.                 entrada = new BufferedReader( new FileReader( f ) );
  16.                
  17.                 String linea;
  18.                
  19.                 while((entrada.ready()) && (salir == false)){
  20.                     linea = entrada.readLine();
  21.                    
  22.                     if ((linea.charAt(0)==('_') && linea.charAt(1)==('I'))){
  23.                        
  24.                         // Introduzco el nombre1
  25.                         linea = entrada.readLine();
  26.                         nombre1 = linea;
  27.                  
  28.                         //introduccion de comentario
  29.                         linea = entrada.readLine();
  30.                         comentarios = linea;
  31.                        
  32.                         Chat chat = new Chat(nombre1,comentarios);
  33.                         listaChats.add(chat);
  34.                     }
  35.                 }
  36.                
  37.                 for(Chat chat: listaChats){
  38.                     println "nombre: "+listaChats.get(i).getNombre1()
  39.                     println "comentarios: "+listaChats.get (i).getComentarios()
  40.                     i++;
  41.                 }
  42.                
  43.                 bean:listaChats.get(0).getComentarios()
  44.         }
  45.     }

Con el for anterior compruebo que se esta rellenando bien listaChats, el error no está ahi.

Código HTML:
Ver original
  1. <%
  2. println "prueba de mensaje!!!"
  3. println it
  4. System.out.println(it);
  5. %>


Muchas gracias por la ayuda, un saludo a todos!!!!