Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12613

rich:select with enablemanualinput selects wrong items

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: 4.1.0.Final, 4.3.0.M2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      use following select:

      <rich:select id="select" enableManualInput="true">
        <f:selectItem id="opt1" itemValue="test test" itemLabel="test test"/>
        <f:selectItem id="opt2" itemValue="test" itemLabel="test"/>
      </rich:select>
      

      Select "test"

      Show
      use following select: <rich:select id= "select" enableManualInput= " true " > <f:selectItem id= "opt1" itemValue= "test test" itemLabel= "test test" /> <f:selectItem id= "opt2" itemValue= "test" itemLabel= "test" /> </rich:select> Select "test"
    • Workaround Description:
      Hide

      Override the richfaces javascript of the select component as follows:

      (function($, rf){
      	if (rf.ui.Select != undefined) {
      		rf.ui.Select.prototype.__getClientItemFromCache = function(inputLabel) {
                  var value;
                  var label;
                  if (this.enableManualInput) {
                      var items = this.cache.getItems(inputLabel, this.filterFunction);
                      if (items && items.length > 0) {
                          var first = $(items[0]);
                          $.each(this.clientSelectItems, function() {
                              if (this.label == inputLabel) {
                                  label = this.label;
                                  value = this.value;
                                  return false;
                              }
                          });
                      } else {
                          this.container.removeClass("rf-sel-fld-err");
                          
                          var prevValue = this.selValueInput.val();
                          if (prevValue && prevValue != "") {
                              $.each(this.clientSelectItems, function() {
                                  if (this.value == prevValue) {
                                      label = this.label;
                                      value = this.value;
                                      return false;
                                  }
                              });
                          }
                      }
                  }
                  
                  if (label && value) {
                      return {'label': label,'value': value};
                  }
              };
      	}
      })(jQuery, RichFaces);
      
      Show
      Override the richfaces javascript of the select component as follows: (function($, rf){ if (rf.ui.Select != undefined) { rf.ui.Select.prototype.__getClientItemFromCache = function(inputLabel) { var value; var label; if ( this .enableManualInput) { var items = this .cache.getItems(inputLabel, this .filterFunction); if (items && items.length > 0) { var first = $(items[0]); $.each( this .clientSelectItems, function() { if ( this .label == inputLabel) { label = this .label; value = this .value; return false ; } }); } else { this .container.removeClass( "rf-sel-fld-err" ); var prevValue = this .selValueInput.val(); if (prevValue && prevValue != "") { $.each( this .clientSelectItems, function() { if ( this .value == prevValue) { label = this .label; value = this .value; return false ; } }); } } } if (label && value) { return { 'label' : label, 'value' : value}; } }; } })(jQuery, RichFaces);

      Description

      When using rich:select with enablemanualinput = "true", the wrong item might be selected. If the list of possible items is (in this order): "test test" and "test" and the user selects "test" richfaces will select "test test" as input. The same happens if the user types "test". If the list is "test" and "test test" and the user selects or types "test" the correct item is selected.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  g.olaerts geert olaerts
                • Votes:
                  3 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 30 minutes
                    30m
                    Remaining:
                    Remaining Estimate - 30 minutes
                    30m
                    Logged:
                    Time Spent - Not Specified
                    Not Specified