3 Replies Latest reply on May 13, 2009 6:11 AM by ilya_shaikovsky

    Problem with listShuttle

      Please help me. I am getting this error message.

      "Component my_form:shuttle has invalid value expression eu.digitania.admingui.beans.Content@12c55e4"

      Here is my code.

      shuttle_demo.jsp

      <f:view>
       <h:form id="my_form">
       <h:messages></h:messages>
       <rich:listShuttle id="shuttle"
       sourceValue="#{contentBean.allContent}"
       converter="listShuttleConverter" var="content" listsHeight="200"
       sourceListWidth="200" targetValue="#{contentBean.targetSelection}">
      
       <rich:column>
       <h:outputText value="#{content.contentId}"></h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="#{content.title}"></h:outputText>
       </rich:column>
      
       </rich:listShuttle>
       <br />
       <br />
       <h:commandButton value="Process"
       action="#{contentBean.submitShuttle}"></h:commandButton>
       </h:form>
       </f:view>



      ContentBackingBean
      public class ContentBackingBean extends Content
      {
      private Set targetSelection;

      public List getAllContent()
      {
      ContentDAOImpl contentDAOImpl = new ContentDAOImpl(MobileContentPortalDao.getSqlMapper());

      List contentList = null;

      try
      {
      contentList=contentDAOImpl.getAllContentByContenttype(6);
      }
      catch (SQLException e)
      {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }

      return contentList;

      }


      public String submitShuttle()
      {
      System.out.println("\n\n\n\n\n"+this.targetSelection.size()+"\n\n\n\n");
      return "success";
      }

      public void setTargetSelection(Set targetSelection)
      {
      this.targetSelection = targetSelection;
      }

      public Set getTargetSelection()
      {
      return targetSelection;
      }
      }

      converter
      public class ListShuttleConverter implements Converter
      {
      
       @Override
       public Object getAsObject(FacesContext context, UIComponent component, String value)
       {
       Content content = new Content();
       content.setTitle(value);
       System.out.println("Returning Content");
      
       return content;
       }
      
       @Override
       public String getAsString(FacesContext context, UIComponent component, Object value)
       {
       Content content= (Content)value;
       System.out.println("Returning Title");
       return content.getTitle();
       }
      
      }


        • 1. Re: Problem with listShuttle
          ilya_shaikovsky

          do you have hashCode and equals methods implemented in your Content class?

          • 2. Re: Problem with listShuttle

            Thanks for your reply

            I overrode the functions like this.


            @Override
             public boolean equals(Object obj)
             {
             return true;
             }
            
             @Override
             public int hashCode()
             {
             return 0;
             }


            But the problem is there. Could you please tell me what is the purpose to override these functions?



            • 3. Re: Problem with listShuttle
              ilya_shaikovsky

              You should override the equals() and hashCode() methods from the Object class. The default implementation of the equals() and hashcode(), which are inherited from the java.lang.Object uses an object instance’s memory location (e.g. MyObject@6c60f2ea).
              This can cause problems when two instances of the objects have the same value  but the inherited equals() will return false because it uses the memory location, which is different for the two instances.