0 Replies Latest reply on Oct 29, 2010 1:00 PM by Leo K

    OrderingList removing elements (firefox only, IE works fine)

    Leo K Newbie

      This is probably one of those very rare cases where something works in IE 8.0.6001 and not in FF 3.6.8

       

      I have an OrderingList, scope request+keepAlive. My converter is

       

      /* (non-Javadoc)
           * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
           */
          @Override
          public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
              String id = arg2.substring(0, arg2.indexOf('_'));
              String desc = arg2.substring(arg2.indexOf('_')+1, arg2.length());
              PerguntaHelper ph = new PerguntaHelper();
              ph.setCoSeqPergunta(Integer.valueOf(id));
              ph.setDsPergunta(desc);
              return ph;

          }

       

          /* (non-Javadoc)
           * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
           */
          @Override
          public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {  
              PerguntaHelper ph = (PerguntaHelper) arg2;
              return ph.getCoSeqPergunta()+"_"+ph.getDsPergunta();
          }

       

      My object implements hashcode and equals

       

      public class PerguntaHelper implements Serializable{

       

          private static final long serialVersionUID = -2103294699705607573L;
          private Integer coSeqPergunta;
          private String dsPergunta;
         
          public PerguntaHelper(){
             
          }

       

          @Override
          public int hashCode() {
              return this.getCoSeqPergunta().hashCode();
          }

       

          @Override
          public boolean equals(Object obj) {
              return this.getCoSeqPergunta().equals(((PerguntaHelper) obj).getCoSeqPergunta());
          }

       

      (...)

        
      }

       

      now, watch the behaviour.

       

      My orderingList

       

      item 1

      item 2

      item 3

       

      then I select item 2 and move it up

       

      item 2

      item 1

      item 3

       

      then before I save the list, item 1 has vanished

       

      saving item 2

      saving item 3

       

      the screen is re-rendered (new request, the method returns a string)

       

      item 2

      item 3

       

      then I select item 2 and move it down

       

      item 3

      item 2

       

      then before I save the list, item 3 has vanished

       

      saving item 2

       

      finally, the screen is re-rendered, showing just item 2

       

      I am using RF 3.3.3

       

      TIA

       

      Leo K.