6 Replies Latest reply on Apr 12, 2013 4:54 PM by hass0

    rich:listShuttle has invalid value expression

    spiritfox26

      Hello, i'm trying to make work this component but i can't do it. I'm recieve this error "Component addIncidenteForm:shuttleCIsAfectados has invalid value expression xxx". My Converter, equals and hashCode methods are fine. The listShuttle load the values correctly but when i'm submit the page with a h:commandLink the error appear.

       

      I search in google and JBoss forum but not found the solution.

       

      The page code:

       

       

      <rich:listShuttle id="shuttleCIsAfectados" targetValue="#{incidenteEditBean.configurationsItemsResult}" listsHeight="375px" sourceListWidth="180px"
      sourceValue="#{incidenteEditBean.configurationsItemsAll}" targetListWidth="180px" copyAllControlLabel="#{msg.copiarTodosLabel}" copyControlLabel="#{msg.copiarLabel}"
      removeAllControlLabel="#{msg.removerTodosLabel}" removeControlLabel="#{msg.removerLabel}" fastOrderControlsVisible="false"
      orderControlsVisible="false" converter="listShuttleConverter" var="items" sourceSelection="#{incidenteEditBean.ciActivos}">
                 <rich:column>
                        <h:outputText value="#{items.nombreCodigoCI}"/>
                 </rich:column>
                            </rich:listShuttle>
      <rich:listShuttle id="shuttleCIsAfectados" targetValue="#{incidenteEditBean.configurationsItemsResult}" listsHeight="375px" sourceListWidth="180px" 
           sourceValue="#{incidenteEditBean.configurationsItemsAll}" targetListWidth="180px" copyAllControlLabel="#{msg.copiarTodosLabel}" copyControlLabel="#{msg.copiarLabel}"
           removeAllControlLabel="#{msg.removerTodosLabel}" removeControlLabel="#{msg.removerLabel}" fastOrderControlsVisible="false"
           orderControlsVisible="false" converter="listShuttleConverter" var="items" sourceSelection="#{incidenteEditBean.ciActivos}"
           <rich:column>
               <h:outputText value="#{items.nombreCodigoCI}"/>
           </rich:column>
      </rich:listShuttle>
      

       

      The converter code:

       

      public class ListShuttleConverter implements Converter{
           
           public Object getAsObject(FacesContext fc, UIComponent ui, String value) {
                ConfigurationItem ci = new ConfigurationItem();
                String[] str = value.split(":");
                ci.setIdConfigurationItem(Integer.parseInt(str[0]));
                ci.setCodConfigurationItem(str[1]);
                return ci;
           }
      
           public String getAsString(FacesContext fc, UIComponent ui, Object value) {
                ConfigurationItem optionItem = (ConfigurationItem) value;
                return Integer.toString(optionItem.getIdConfigurationItem()) + ":" + optionItem.getCodConfigurationItem();
           }
      
      }
      

       

       

      the hasCode and equals:

       

      @Override
           public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + idConfigurationItem;
                return result;
           }
      
           @Override
           public boolean equals(Object obj) {
                if (this == obj){
                     return true;
                }
                if (obj == null){
                     return false;
                }
                if (getClass() != obj.getClass()){
                     return false;
                }
                ConfigurationItem other = (ConfigurationItem) obj;
                if (idConfigurationItem != other.idConfigurationItem){
                     return false;
                }
                return true;
           }
      

      I need help.

       

      Thanks in advanced!

       

      Regards

        • 1. Re: rich:listShuttle has invalid value expression
          spiritfox26

          nobody?

           

          I'm using Richfaces 3.3.3

          • 2. Re: rich:listShuttle has invalid value expression
            ilya_shaikovsky
            My Converter, equals and hashCode methods are fine. 

            Than the error should not appear... check all the methods in debug. When it risen it means that some of the converted objects getting compared with the initial list and not found there.

            • 3. Re: rich:listShuttle has invalid value expression
              spiritfox26

              Ok, i was put System.out... and the hashcode is fine, when i load the  i do this:

               

               

              this.configurationsItemsAll= (ArrayList<ConfigurationItem>) cliController.getConfigurationItemsCliente(cliente,em);
              ConfigurationItemServiceBean ciSB = new ConfigurationItemServiceBean(em);
              if(!ticket.getConfigurationItemsTickets().isEmpty()) {
              for (ConfigurationItemTicket ciTicket : ticket.getConfigurationItemsTickets()) {
              if(ciTicket.getTipoRolCiTicket().getIdTipoRolCiTicket() != TipoRolCiTicket.idServicioAfectado && ciTicket.getTipoRolCiTicket().getIdTipoRolCiTicket() != TipoRolCiTicket.idComponenteServicio) {
              //Se carga el nombre vigente
              ciTicket.getConfigurationItem().setNombreCI(ciSB.getNombreVigenteCI(ciTicket.getConfigurationItem()));
              if(ciTicket.getConfigurationItem().getEstadoConfigurationItemVigente().getTipoEstadosConfigurationItem().getIdTipoEstadosConfigurationItem() == TipoEstadosConfigurationItem.idTipoEstadoCerrado){
              configurationsItemsAll.add(ciTicket.getConfigurationItem());
              }
              this.configurationsItemsAll.remove(ciTicket.getConfigurationItem());
              configurationsItemsResult.add(ciTicket.getConfigurationItem());
              }
              }
              }
              this.configurationsItemsAll= (ArrayList<ConfigurationItem>) cliController.getConfigurationItemsCliente(cliente,em);
                                  ConfigurationItemServiceBean ciSB = new ConfigurationItemServiceBean(em);
                                  if(!ticket.getConfigurationItemsTickets().isEmpty()) {
                                       for (ConfigurationItemTicket ciTicket : ticket.getConfigurationItemsTickets()) {
                                            if(ciTicket.getTipoRolCiTicket().getIdTipoRolCiTicket() != TipoRolCiTicket.idServicioAfectado && ciTicket.getTipoRolCiTicket().getIdTipoRolCiTicket() != TipoRolCiTicket.idComponenteServicio) {
                                                 //Se carga el nombre vigente
                                                 ciTicket.getConfigurationItem().setNombreCI(ciSB.getNombreVigenteCI(ciTicket.getConfigurationItem()));
                                                 if(ciTicket.getConfigurationItem().getEstadoConfigurationItemVigente().getTipoEstadosConfigurationItem().getIdTipoEstadosConfigurationItem() == TipoEstadosConfigurationItem.idTipoEstadoCerrado){
                                                      configurationsItemsAll.add(ciTicket.getConfigurationItem());
                                                 }
                                                 this.configurationsItemsAll.remove(ciTicket.getConfigurationItem());
                                                 configurationsItemsResult.add(ciTicket.getConfigurationItem());
                                            } 
                                       }
                                  }
              

               

              I'm use remove in configuration items all maybe this is the problem?

              • 4. Re: rich:listShuttle has invalid value expression
                spiritfox26

                I was add system.out to debug, and the inital objects are equals than converted objects.

                • 5. Re: rich:listShuttle has invalid value expression
                  spiritfox26

                  I could solve it. The problem was how load the lists .

                   

                  Thanks

                  • 6. Re: rich:listShuttle has invalid value expression
                    hass0

                    I ran into this problem, too, and found the following solution (although I'm sure I'm missing something, as changes I made to my Converter were not reflected in my value expression errors):

                    I had several ListShuttle's, with one not working, and I noticed that the one not working was comparing objects using hashCode(), whereas the working ListShuttle's were using equals().  Checking faces-config.xml, I noticed that the broken Bean was request-scoped, but the working Beans were session-scoped.  Changing the scope to "session" fixed the problem.