Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/01/2014, 14:02
GunnerJm
 
Fecha de Ingreso: enero-2014
Ubicación: En mi Laptop.
Mensajes: 32
Antigüedad: 10 años, 3 meses
Puntos: 1
Pregunta Respuesta: Session dentro de un Action, Java-JSP

Gracias!!! Ahora ya tengo los objetos en Session, ahora mi problema esta en mostrar la lista, solo muestra el ultimo y no muestra todo.

Intente colocando esto casi al final pero sigue igual solo muestra el ultimo.

Código Java:
Ver original
  1. IncidenciaDetalle wer = new IncidenciaDetalle();   
  2.                
  3.                 wer.setId(contCodDet+"");
  4.                 System.out.println("Cod:" + contCodDet);
  5.                 wer.setObj(objObj.getDTipDescripcion());
  6.                 System.out.println("Cod:" + objObj.getDTipDescripcion());
  7.                         wer.setCantidad(cant);
  8.                             System.out.println("Cant:" + cant);
  9.                
  10.                 lista.add(wer);
  11.                
  12.                 resul.append("<tr>" +
  13.                         "<td>"+wer.getId()+"</th>"+
  14.                         "<td>"+wer.getObj()+"</td>" +
  15.                         "<td>"+wer.getCantidad()+"</td>" +
  16.                         "<td>"+"<input type='radio'>"+
  17.                         "</td></tr>");

Código Completo.

Código Java:
Ver original
  1. private int contCodDet=1;
  2.     @SuppressWarnings({ "unchecked", "unused" })
  3.     public String AgregarDetalleObjCant(String objetos, int cant){
  4.         StringBuffer resul=new StringBuffer();
  5.         DettipoDTO objObj=null;
  6.         try {
  7.             System.out.println("Obj: " + objetos); 
  8.    
  9.             objObj = servicioDetalle.findOne(Integer.parseInt(objetos));
  10.            
  11.             /* Aumente desde aqui */
  12.             System.out.println("Antes de la Session");
  13.            
  14.             //IncidenciaDetalle inciSession = (IncidenciaDetalle) session.get("incidetalle");
  15.             List <IncidenciaDetalle> lista = (List<IncidenciaDetalle>) session.get("incidetalle");
  16.            
  17.             //List<IncidenciaDetalle> lista= null;
  18.             if( session.get("incidetalle")== null){
  19.                 lista = new ArrayList<IncidenciaDetalle>();
  20.                 session.put("incidetalle", lista);
  21.             }else{
  22.                 lista = (List<IncidenciaDetalle>) session.get("incidetalle");
  23.             }
  24.            
  25.             System.out.println("Total Session: "+ lista);
  26.             System.out.println("Antes del If 0");
  27.            
  28.  
  29.             System.out.println("Entre al For");
  30.             if(cant!=0){
  31.                 for(IncidenciaDetalle in : lista)
  32.                 {
  33.                     contCodDet++;
  34.                 }
  35.            
  36.             System.out.println("Salio del For");
  37.            
  38.             /* Hasta aqui*/
  39.            
  40.             resul.append("<table id='tbDetalleIncidencia' class='ui-widget ui-widget-content' style='width: 50%; font-size: 15px; ' align='center'>"+
  41.                     "<thead>"+
  42.                       "<tr class='ui-widget-header'>"+
  43.                         "<th colspan='6' align='center'>Detalle</th>"+
  44.                       "</tr>"+
  45.                     "</thead>"+
  46.                     "<thead>"+
  47.                       "<tr class='ui-widget-header'>"+ 
  48.                         "<th>Codigo</th>"+
  49.                         "<th>Obejto/Lenceria</th>"+
  50.                         "<th>Cantidad</th>"+
  51.                         "<th>Accion</th>"+
  52.                       "</tr>"+
  53.                     "</thead>"+
  54.                     "<tbody>");
  55.  
  56.                 System.out.println("Agarro el objeto = "+ objObj.getDTipDescripcion());
  57.                
  58.                 /*resul.append("<tr>" +
  59.                         "<td>"+contCodDet+"</th>"+
  60.                         "<td>"+objObj.getDTipDescripcion()+"</td>" +
  61.                         "<td>"+cant+"</td>" +
  62.                         "<td>"+"<input type='radio'>"+
  63.                         "</td></tr>");
  64.             */
  65.                 IncidenciaDetalle wer = new IncidenciaDetalle();   
  66.                
  67.                 wer.setId(contCodDet+"");
  68.                 System.out.println("Cod:" + contCodDet);
  69.                 wer.setObj(objObj.getDTipDescripcion());
  70.                 System.out.println("Cod:" + objObj.getDTipDescripcion());
  71.                 wer.setCantidad(cant);
  72.                 System.out.println("Cant:" + cant);
  73.                
  74.                 lista.add(wer);
  75.                
  76.                 resul.append("<tr>" +
  77.                         "<td>"+wer.getId()+"</th>"+
  78.                         "<td>"+wer.getObj()+"</td>" +
  79.                         "<td>"+wer.getCantidad()+"</td>" +
  80.                         "<td>"+"<input type='radio'>"+
  81.                         "</td></tr>");
  82.            
  83.                
  84.                 System.out.println("Total: "+ lista.size());
  85.                
  86.                 session.put("incidetalle", lista);
  87.                
  88.                 System.out.println("Total Session: "+ lista.size());
  89.             }
  90.  
  91.         } catch (Exception e) {
  92.             e.printStackTrace();
  93.         }
  94.        
  95.         resul.append("</tbody>"+
  96.                  "</table>");
  97.         return resul.toString();
  98.        
  99.     }