7 Replies Latest reply on Jul 14, 2010 6:33 AM by nbelaevski

    Combobox binding problem

    dracola24

      Hello, I am trying to select the values to make a combobox. This is the code:

       

      <div id="box-categories">
                  <b>Filter by topic</b>
                  <rich:inplaceSelect id="cat1" binding="#{mycompany.htmlnplaceSelect}" onchange="javascript:refreshResults(); return false;">
                                              <f:selectItems value="#{interfaceContainer.documentFormContainer.selectOnes['cat1'].items}" />
                                      </rich:inplaceSelect>
              </div>     

       

      Object mycompany.htmlnplaceSelec  type is HtmlInplaceSelect, when I make getValue() in onselect, I get null value.

      I tryed also instead of binfing, value, with the same result.

       

      This the my java code:

      public String getStringValue(){
            if ( this.selectOne ==null || this.getSelectOne().getValue()==null)
                return "";
            return this.getSelectOne().getValue().toString();
        }

       

      Any ideas??

       

      Thanks in advance

        • 1. Re: Combobox binding problem
          nbelaevski

          Hi,

           

          Use "value" attribute to get selected object on server like this <... value="#{bean.selectedObject}" >

          • 2. Re: Combobox binding problem
            dracola24

            I have try it, but with the same result.

            getValue() is still null :s

             

            More ideas please??

            Thanks

            • 3. Re: Combobox binding problem
              nbelaevski

              I should work, please post full page & bean code.

              • 4. Re: Combobox binding problem
                dracola24

                Page code with your suggest included:

                 

                <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:a4j="http://richfaces.org/a4j"
                     xmlns:rich="http://richfaces.org/rich"
                    xmlns:sec="http://www.springframework.org/security/facelets/tags"    
                >

                 

                 

                 


                    <nav><a4j:outputPanel id="navigation" >
                        <div id="box-categories">
                            <b>Filter by topic</b>
                            <rich:inplaceSelect id="cat1" value="#{interfaceContainer.documentFormContainer.selectOnes['cat1'].value}" onchange="javascript:refreshResults(); return false;">
                                                        <f:selectItems value="#{interfaceContainer.documentFormContainer.selectOnes['cat1'].items}" />
                                                </rich:inplaceSelect>
                            <b>and subtopic</b>
                <rich:comboBox id="cat2" value="#{interfaceContainer.documentFormContainer.selectOnes['cat2'].value}" onchange="javascript:refreshResults();" >
                                                        <f:selectItems value="#{interfaceContainer.documentFormContainer.selectOnes['cat2'].items}" />
                                                </rich:comboBox>
                        </div>       
                        </a4j:outputPanel>
                    </nav>

                 


                </ui:composition>

                 

                 

                Java code:

                 

                public String getStringValue(){
                      if ( this.selectOne ==null || this.getSelectOne().getValue()==null)
                          return "";
                      return this.getSelectOne().getValue().toString();
                  }

                 

                 

                Thanks for your answers

                • 5. Re: Combobox binding problem
                  nbelaevski

                  What is "interfaceContainer.documentFormContainer.selectOnes['cat1'].value"? Where is "stringValue" used?

                   

                  Also value needs to be submitted to the server, so you should have form and some submitting component like a4j:commandLink or a4j:support.

                  • 6. Re: Combobox binding problem
                    dracola24

                    interfaceContainer.documentFormContainer.selectOnes['cat1'].value is a value which is in a solr document, which was indexed before.

                     

                    Regarding the html code of the page, I get:

                     

                    <input type="text" value="Guardia"/>

                     

                    So I need to send 'value' information to the backend, and I do it with this.getSelectOne().getId();, but here is when I get null value.

                     

                    Thanks for your answers

                    • 7. Re: Combobox binding problem
                      nbelaevski

                      and I do it with this.getSelectOne().getId();, but here is when I get null value

                      Can you please explain in more details? Even better, create small example including full code and attach it here. Obtaining input value is pretty straightforward, so I'm not getting why you have problems with it.