5 Replies Latest reply on Aug 29, 2010 6:38 PM by deanhiller

    Howto : orderingList with inputText?

    asterius

      Hello!

      I'm trying to set inputText in the orderingList, but I get a problem when sending it.
      Maybe can you help me?

      Here is my code :

      <h:form id="domainForm">
       <rich:orderingList value="#{DKVEditFace.currentKeyValueList}" var="keyValue">
       <rich:column>
       <h:outputText value="#{keyValue.keyName}"/>
       </rich:column>
       <rich:column>
       <h:inputText value="#{keyValue.value}"/>
       </rich:column>
       </rich:orderingList>
       <p>
       <h:commandButton value="#{Bundle.button_save}" actionListener="#{DKVEditFace.saveKeyValues}" eventsQueue="default"/>
       </p>
      </h:form>
      


      public class DKVEditFace{
      
      private List<KeyValue> currentKeyValueList;
      
      public List<KeyValue> getCurrentKeyValueList() {
       return currentKeyValueList;
      }
      
      public void setCurrentKeyValueList(List<KeyValue> currentKeyValueList) {
       this.currentKeyValueList = currentKeyValueList;
      }
      
      public void saveKeyValues(ActionEvent event) {
       System.out.println("Save");
      }
      
      ...
      
      }
      
      public class KeyValue implements Cloneable,java.io.Serializable {
      
      protected java.lang.String keyName;
      protected java.lang.String value;
      protected java.lang.Integer keyIndex;
      
      public java.lang.String getKeyName() {
       return keyName;
      }
      
      public void setKeyName(java.lang.String keyName) {
       this.keyName = keyName;
      }
      
      public java.lang.String getValue() {
       return value;
      }
      
      public void setValue(java.lang.String value) {
       this.value = value;
      }
      
      public java.lang.Integer getKeyIndex() {
       return keyIndex;
      }
      
      public void setKeyIndex(java.lang.Integer keyIndex) {
       this.keyIndex = keyIndex;
      }
      
      ...
      
      }


      The first display is ok. But when I click on the button, I get this error :
      javax.servlet.ServletException: /pages/admin/dropdownManagement.xhtml @52,50 value="#{keyValue.keyName}": Property 'keyName' not found on type java.lang.String


      The orderingList seems to want to set the property on a String. But the var="keyValue" contains a KeyValue object which is not a String. As the list is correctly displayed before the submit, I guess the problem is probably not on my attributes?
      Any idea?

      In addition to this, do you know how I can link the setIndex() of my KeyValue object with the user changing the order of the list? I tried many ways , but never succeed...

      Thanks for your help!

        • 1. Re: Howto : orderingList with inputText?
          asterius

          No answer? Maybe a bug?

          • 2. Re: Howto : orderingList with inputText?
            asterius

            Note : if I change "keyName" by "aKeyName", or change my getter KeyValue.getKeyName() by KeyValue.getName(), the problem is still the same.

            I have tried to set an inputText in place of the outputText, and then got the following error in my logs :

            INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
            sourceId=domainForm:j_id61[severity=(ERROR 2), summary=("Component domainForm:j_id61 has invalid value expression my.package.KeyValue@1f"), detail=("Component domainForm:j_id61 has invalid value expression my.package.KeyValue@1f")]



            • 3. Re: Howto : orderingList with inputText?
              asterius

              This is probably a bug.
              How to report the bugs?

              • 4. Re: Howto : orderingList with inputText?
                ilya_shaikovsky

                just create converter for your class and implement hasCode and equals methods. Check livedemo (lsitshuttle example, for Ordering List should be the same)

                • 5. Re: Howto : orderingList with inputText?
                  deanhiller

                  seems like a big bug to me.  In my case only commenting out hashCode/equals in the entity worked for me AND those methods were generated correctly by eclipse like so....

                   

                  //HAVING equals/hashCode breaks rich:orderedList widget...
                  //    @Override
                  //    public int hashCode() {
                  //        final int prime = 31;
                  //        int result = 1;
                  //        result = prime * result + ((id == null) ? 0 : id.hashCode());
                  //        return result;
                  //    }
                  //
                  //    @Override
                  //    public boolean equals(Object obj) {
                  //        if (this == obj)
                  //            return true;
                  //        if (obj == null)
                  //            return false;
                  //        if (getClass() != obj.getClass())
                  //            return false;
                  //        Question other = (Question) obj;
                  //        if (id == null) {
                  //            if (other.id != null)
                  //                return false;
                  //        } else if (!id.equals(other.id))
                  //            return false;
                  //        return true;
                  //    }