0 Replies Latest reply on Nov 2, 2010 10:15 PM by otrejo

    Problem with listshuttle

    otrejo

      I've had little problems with JBoss RichFaces control listshuttle of the same when I do the submit tells me that the list is null "Component j_id_id19: list has invalid null value expression, then annex my source code if someone can help me a lot know thank I need is a simple way to manage the activities, which will allow a profile.

       

      -------------- That is the jsf with the listshuttle control ----------------

       

      <%@page contentType="text/html"%>
      <%@page pageEncoding="UTF-8"%>
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
      <%@taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
      <%@taglib uri="http://richfaces.org/rich" prefix="rich" %>

       


      <f:view>
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Listing DetPerfiles Items</title>
      <link rel="stylesheet" type="text/css" href="../jsfcrud2.css" />
      </head>
      <body>
      <h:form rendered="#{not empty Login.tercero.chrUsuario}">
      <h:graphicImage url="/imagenes/web/BannerSistGint.jpg" />
      <rich:toolBar style="width: 940px; height:24px;" >
      <h:commandButton image="/imagenes/web/filesave.png" type="submit" action="#{detPerfiles.aplicarCambios}" alt="Guardar" style="border: 0px;"/>
      <rich:toolBarGroup location="right">
      <h:panelGrid columns="4">
      <h:commandButton image="/imagenes/web/home_2.png" value="Volver al Menú Principal" action="Principal" immediate="true" alt="Regresar al menú principal" style="border: 0px;"/>
      <h:commandButton image="/imagenes/web/help.png" action="#{terceros.listSetup}" immediate="true" alt="Ayuda" style="border: 0px;"/>
      <h:commandButton image="/imagenes/web/publish_x.png" value="Volver al Menú Principal" onclick="history.back();return false;" immediate="true" alt="Cerrar" style="border: 0px;"/>
      <h:commandButton image="/imagenes/web/power.png" action="#{Login.exit}" immediate="true" alt="Salir" style="border: 0px;"/>
      </h:panelGrid>
      </rich:toolBarGroup>

       

      </rich:toolBar>

       

      <rich:panel style="width: 940px; heigth:400px;text-align:left">
      <rich:panelBar style="font-size: 14pt;">Detalle de Actividades</rich:panelBar>
      <h:panelGrid>
      <rich:listShuttle id="list" sourceValue="#{detPerfiles.actividades}"
      targetValue="#{detPerfiles.detPerfilesItemsV}"
      converter="#{ve.com.ttgroup.ejb.DetPerfilesConvert er}"
      targetCaptionLabel="Permisos Actuales"
      var="detPerfil"
      sourceCaptionLabel="Permisos Disponibles"
      copyControlLabel="Añadir"
      copyAllControlLabel="Añadir Todos"
      removeControlLabel="Remover"
      removeAllControlLabel="Remover Todas"
      upControlLabel="Arriba"
      downControlLabel="Abajo"
      bottomControlLabel="Último"
      topControlLabel="Primero">
      <rich:column width="18">
      <h:graphicImage value="#{detPerfil.actividad.chrIcono}" style="border:0px"/>
      </rich:column>
      <rich:column>
      <h:outputText value="#{detPerfil.actividad.chrDescactividad}"></h:outputText>
      </rich:column>
      </rich:listShuttle>
      </h:panelGrid>

       

      </rich:panel>

       

       

       

      </h:form>
      <h:form rendered="#{empty Login.tercero.chrUsuario}">
      <h:graphicImage url="/imagenes/web/BannerSistGint.jpg" />
      <rich:panel style="width: 940px; text-align:left;" >
      <f:facet name="header">
      <h:outputText value="Error"/>
      </f:facet>
      <h:panelGrid columns="4">
      <h:graphicImage value="/imagenes/web/stop.jpg"/>
      <h:outputText value="Usted no se encuentra logueado a la aplicación, Haga clic"/> <h:commandLink value="acá" action="#{Login.exit}"/> <h:outputText value="para loguearse"/>
      </h:panelGrid>
      </rich:panel>
      </h:form>
      <h:panelGroup id="messagePanel" layout="block">
      <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
      </h:panelGroup>
      </body>
      </html>
      </f:view>

       

      ----- That's the attribute of the bean ------------------------

       

      private List<DetPerfiles> detPerfilesItems = new ArrayList<DetPerfiles>();
      private List<DetPerfiles> detPerfilesN = new ArrayList<DetPerfiles>();

       

      private List<ActividadesModulo> actividades = null;

       

       

       

       

       

      public List<DetPerfiles> getDetPerfilesItemsV() {

       

      if (detPerfilesItems.size()==0){
      detPerfilesItems = jpaController.findDetPerfilesEntities(intIdperfil, intIdmodulo);
      }

       

      return detPerfilesItems;
      }

       

      public void setDetPerfilesItemsV(List<DetPerfiles> detPerfilesItems) {
      this.detPerfilesItems = detPerfilesItems;
      }

       

       

       

      public String aplicarCambios(){

       

      for (DetPerfiles x : detPerfilesItems){
      System.out.print("Va entrar para guardar los perfiles");
      if (x.getIntIddetalleperf()==0){
      System.out.print("Detalle del perfil" + x.getIntIddetalleperf());
      detPerfiles = (DetPerfiles) x;
      try {
      jpaController.create(detPerfiles);
      JsfUtil.addSuccessMessage("DetPerfiles was successfully created.");
      } catch (Exception e) {
      JsfUtil.ensureAddErrorMessage(e, "A persistence error occurred.");
      }
      detPerfiles = null;
      }

       


      }
      return "perfiles_detail";
      }

       

      public List<DetPerfiles> getActividades() {

       


      actividades = jpaController.getActividades(intIdperfil, intIdmodulo);

       

      for (ActividadesModulo x : actividades){

       

      DetPerfiles detp = new DetPerfiles();
      detp.setIntIddetalleperf(0);
      detp.setIntIdModulo(intIdmodulo);
      detp.setIntIdperfil(intIdperfil);
      detp.setActividad(x);
      detp.setMcaActivo("S");
      detp.setMcaPermitido("S");
      detp.setMcaBorrado("N");

       

      detPerfilesN.add(detp);

       

      }

       

      return detPerfilesN;
      }

       

      that's the same converter of the entitybean DetPerfiles

       

      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */

       

      package ve.com.ttgroup.ejb;

       

      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.Converter;
      import ve.com.ttgroup.entitybeans.DetPerfiles;

       

      /**
      *
      * @author Administrador
      */
      public class DetPerfilesConverter implements Converter {

       

      public Object getAsObject(FacesContext facesContext, UIComponent component, String string) {
      if (string == null || string.length() == 0) {
      return null;
      }
      Integer id = new Integer(string);
      DetPerfilesJpaController controller = (DetPerfilesJpaController) facesContext.getApplication().getELResolver().getV alue(facesContext.getELContext(), null, "detPerfilesJpa");
      return controller.findDetPerfiles(id);
      }

       

      public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
      if (object == null) {
      return null;
      }
      if (object instanceof DetPerfiles) {
      DetPerfiles o = (DetPerfiles) object;
      return o.getIntIddetalleperf() == null ? "" : o.getIntIddetalleperf().toString();
      } else {
      throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: ve.com.ttgroup.entitybeans.DetPerfiles");
      }
      }

       

      }

       

       

       

      Please Help me....