2 Replies Latest reply on Apr 9, 2009 4:24 AM by ilya_shaikovsky

    ComboBox Renderer Changes in 3.3.0

    kragoth

      Hi,

      I'm trying to upgrade my application from Richfaces 3.2.2 to 3.3.0 and I'm having a bit of a problem.

      Upgrading makes my jsfunit tests break, so I decided to investigate what was going on and I came across what I consider to be a rather nasty change that's been made in richfaces with regards to the ComboBox.

      In 3.2.2 the html output for the combo box looked something like this

      ...
      <div class="rich-combobox-list-position"
       id="MasterPageForm:reasonTypelistPosition">
       <div class="rich-combobox-list-decoration"
       id="MasterPageForm:reasonTypelistDecoration">
       <div class="rich-combobox-list-scroll"
       id="MasterPageForm:reasonTypelist">
       <span class="rich-combobox-item rich-combobox-item-normal">
       Client Interaction
       </span>
       <span class="rich-combobox-item rich-combobox-item-normal">
       Disbursement
       </span>
       </div>
       </div>
      </div>
      


      The output from 3.3.0 is:
      ...
      <div class="rich-combobox-list-position"
       id="MasterPageForm:reasonTypelistPosition">
       <div class="rich-combobox-list-decoration"
       id="MasterPageForm:reasonTypelistDecoration">
       <div class="rich-combobox-list-scroll"
       id="MasterPageForm:reasonTypelist">
       <span class="rich-combobox-item rich-combobox-item-normal">
       gekko.domain.certificate.CertificateReason@fbc8ce
       [description=Client Interaction,targetType=/null/,deliveryDays=1,
       workgroup={proxy.id}=1,batchType=/null/,
       districtOfficeToRestrictTo=/null/,homeForm=CLIENT_INTERACTION,
       active=true,dateCreated=09/04/2009 11:27:15,
       userCreated={proxy.id}=1,dateUpdated=09/04/2009 11:27:15,
       userUpdated={proxy.id}=1,id=13,version=0]
       </span>
       <span class="rich-combobox-item rich-combobox-item-normal">
       gekko.domain.certificate.CertificateReason@3c72d7
       [description=Disbursement,targetType=PROPOSAL,deliveryDays=5,
       workgroup={proxy.id}=1,batchType=/null/,
       districtOfficeToRestrictTo=/null/,homeForm=DISBURSEMENT_FORM,
       active=true,dateCreated=09/04/2009 11:27:15,
       userCreated={proxy.id}=1,dateUpdated=09/04/2009 11:27:15,
       userUpdated={proxy.id}=1,id=18,version=0]
       </span>
       <span
       </div>
       </div>
      </div>
      


      As you can see, richfaces is now just using a toString() on my value object instead of getting the stringValue from the converter.

      So where I used to be able to set the value in my jsfunit test to the value returned by my converter if I passed an object to it, now it doesn't work. Not only that the amount of bandwith that is wasted here is quite large. If I had a large object that I was using in my ComboBox you could be potentially sending "Megabytes" of data down the wire because of the call to toString().

      I hope this is not the intended solution and is just an oversight cause this is really not going to work.


      Maybe I've completely missed some change that was made that I need to go retrofit into my code, but after analysing the renderer I think that this is a change made by richfaces. Specifically in the public List encodeItems(FacesContext context, UIComponent component) method inside ComboBoxBaseRenderer.java.


        • 1. Re: ComboBox Renderer Changes in 3.3.0
          kragoth

          Infact the lines that cause the problem are here:

          *Note I don't actually have the .java file this is just peeking in the class file :P *

           public String encodeSuggestion(FacesContext context, UIComponent component, Object value, String classes)
           throws IOException
           {
           ResponseWriter writer = context.getResponseWriter();
           String encodedValue = null;
           if(writer != null)
           {
           encodedValue = getConvertedStringValue(context, component, value);
           writer.startElement("span", component);
           writer.writeAttribute("class", classes, null);
           writer.writeText(value, null);
           writer.endElement("span");
           }
           return encodedValue;
           }
          


          The encodedValue is assigned from the getConvertedStringValue method call, but when you call writer.writeText you pass in the object instead of the encoded value. I think this is wrong as previously it was writer.write(the encoded value)

          Should I go raise a JIRA for this?

          • 2. Re: ComboBox Renderer Changes in 3.3.0
            ilya_shaikovsky