1 Reply Latest reply on Aug 29, 2010 6:33 PM by Dean Hiller

    Issue with rich:orderingList

    Syam G Newbie
      Hi
      I get the following exception while submitting the page with an ordering list

      sourceId=j_id16:localelist[severity=(ERROR 2), summary=("Component j_id16:localelist has invalid value expression com.rim.webservices.apps.sdownloads.model.LocalizedSite@8de88a"), detail=("Component j_id16:localelist has invalid value expression com.rim.webservices.apps.sdownloads.model.LocalizedSite@8de88a")]

      xhtml
      *********
      <rich:orderingList id="localelist" converter="siteConverter" orderControlsVisible="false" fastOrderControlsVisible="false" value="#{siteAction.localizedSites}" var="loc" listHeight="100" listWidth="150"  selection="#{siteAction.selectedLocaleList}">
                             <rich:column  width="180">  
                               <h:outputText value="${loc.language.name}" ></h:outputText>
                             </rich:column>
                           </rich:orderingList> 


      Converter
      ***********
      public Object getAsObject(FacesContext context, UIComponent component, String value)
        {
             LocalizedSite ls = new LocalizedSite();

            if (value == null || (value.trim().length() == 0))
            {
                return value;
            }
            Language l = new Language();
            l.setName(value);
            ls.setLanguage(l);   
            
            return ls;
        }

        public String getAsString(FacesContext context, UIComponent component, Object value)
        {
             LocalizedSite ls = null;

            if (value instanceof LocalizedSite)
            {
                 ls = (LocalizedSite)value;

                StringBuilder lsAsString = new StringBuilder();
                lsAsString.append(ls.getLanguage().getName());
                return lsAsString.toString();
            }
            return "";
        }

      Please help if anybody got a solution for this.
        • 1. Re: Issue with rich:orderingList
          Dean Hiller Expert

          I had same problem.  For me, my entity was implementing hashCode and equals generated from ECLIPSE!!! and I was just using the id field for equality, but for some reason, that broke it all :(.



               @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;
               }