3 Replies Latest reply on Dec 24, 2010 3:30 AM by Vivek Madapura

    Selection problem with rich:comboBox in 3.3.3

    Vivek Madapura Newbie

      Hi,

       

      I use richfaces 3.3.3 with jsf 1.2 in my project.

      I have a combobox which uses a object to string converter.

      Whenever a value is selected from the combobox, the  string value of the selection is passed to the converter, the object returned from the converter is then sent to the bean (I guess this is how it works!!).

       

      Now my problem is that when I try to select a value directly by clicking on the button provided, an empty string is sent to the converter and the text input part of the combobox does not contain my selection. However if I type something in the text input part of the combobox and select one of the values suggested, the string value of the selected item is passed to the converter (the value is set in the model too) and it is also displayed in the text part.

       

      Is this a known issue or am I doing some thing wrong?

       

      I tested  with 3.3.0 but could not reproduce this.

       

      Kindly let me know if any other details is necessary.

       

      I am using the below mentioned jars

      commons-beanutils.jar
      commons-beanutils-bean-collections.jar
      commons-beanutils-core.jar
      commons-collections-3.2.1.jar
      commons-digester-1.8.jar
      commons-lang-2.4.jar
      commons-logging-1.1.1.jar
      jsf-api.jar
      jsf-facelets.jar
      jsf-impl.jar
      log4j-1.2.15.jar
      ojdbc6_g.jar
      richfaces-api-3.3.0.GA.jar
      richfaces-impl-3.3.0.GA.jar
      richfaces-ui-3.3.0.GA.jar

       

      - Vivek Madapura V

        • 1. Re: Selection problem with rich:comboBox in 3.3.3
          Nick Belaevski Master

          Hi Vivek,

           

          Can you please post bean/page code?

          • 2. Re: Selection problem with rich:comboBox in 3.3.3
            Vivek Madapura Newbie

            Hi Nick,

             

            The contents of the xhtml page

             

            <h:outputText value="EA - Name" style="padding-left:10px"></h:outputText>

             

            <rich:comboBox id="eaNameSelect" width="325px"
                                        defaultLabel="EA Name" style="padding-left:10px;"
                                        suggestionValues="#{dataTableBean.eaList}"
                                        value="#{dataTableBean.selectEa}"
                                        valueChangeListener="#{dataTableBean.updateSelectedEA}">
                                        <a4j:support event="onselect" ajaxSingle="true"
                                            reRender="eaNumberSelect,comparisonTable" requestDelay="50"
                                            onsubmit="#{rich:component('panel')}.show()"
                                            oncomplete="#{rich:component('panel')}.hide()" />
                                        <f:converter converterId="eaComboConverter" />
                                    </rich:comboBox>

             

                                    <h:outputText value="EA - Number" style="padding-left:10px">
                                    </h:outputText>

             

                                    <rich:comboBox id="eaNumberSelect" selectFirstOnUpdate="false"
                                        defaultLabel="EA Number" style="padding-left:10px;"
                                        suggestionValues="#{dataTableBean.eaList}"
                                        value="#{dataTableBean.selectEa}"
                                        valueChangeListener="#{dataTableBean.updateSelectedEA}">
                                        <a4j:support event="onselect" ajaxSingle="true"
                                            reRender="eaNameSelect,comparisonTable" requestDelay="50"
                                            onsubmit="#{rich:component('panel')}.show()"
                                            oncomplete="#{rich:component('panel')}.hide()" />
                                        <f:converter converterId="eaComboConverter" />
                                    </rich:comboBox>

             

            These two combo boxes use the same converter because the object behind them are same.

            The contents of the converter

             

            public Object getAsObject(FacesContext context, UIComponent component,
                        String value) {
                    @SuppressWarnings("unchecked")
                    List<Ea> eaList = (List<Ea>) component.getAttributes().get(
                            "suggestionValues");
                    Ea returnValue = null;
                    System.out.println("in getAsObject " + component.getId());
                    Iterator<Ea> iterator = eaList.iterator();
                    while (iterator.hasNext()) {
                        Ea ea = (Ea) iterator.next();
                        if (ea.getName().equalsIgnoreCase(value)
                                || ea.getNumber().equalsIgnoreCase(value)) { // the number is a string here
                            returnValue = ea;
                            break;
                        }

             

                    }
                    System.out.println("THe input value is " + value); // this prints empty
                    System.out.println("the return value is " + returnValue); // and hence this is null
                    return returnValue;

                }

             

            public String getAsString(FacesContext context, UIComponent component,
                        Object object) {
                    String returnValue = "";
                    if (null != object) {
                        Ea ea = (Ea) object;
                        if (component.getId().equalsIgnoreCase("eaNameSelect"))
                            returnValue = ea.getName();
                        else if (component.getId().equalsIgnoreCase("eaNumberSelect"))
                            returnValue = ea.getNumber();
                    }
                    return returnValue;

             

                }

             

            The contents of the bean  :

             

                 /**
                 * The selected ea from either of the combo boxes
                 */
                private Ea selectEa = null;

             

                 /**
                 * @param event
                 */
                public void updateSelectedEA(ValueChangeEvent event) {
                    Ea ea = (Ea) event.getNewValue();
                    selectEa = ea;
                }

             

                /**
                 * @return the selectEa
                 */
                public Ea getSelectEa() {
                    return selectEa;
                }

             

                /**
                 * @param selectEa
                 *            the selectEa to set
                 */
                public void setSelectEa(Ea selectEa) {
                    this.selectEa = selectEa;
                }

             

            One correction from the post above - the richfaces jars i have used is of version 3.3.3

            • 3. Re: Selection problem with rich:comboBox in 3.3.3
              Vivek Madapura Newbie

              Hi,

               

              Any inputs on this is much appreciated.

               

              -Vivek Madapura