1 2 Previous Next 16 Replies Latest reply on Nov 4, 2008 11:59 AM by ilya_shaikovsky

    ComboBox does not submit initial value

    arvhatte

      Dear RichFaces Team,

      The other day I ran into a problem with the combox component (IE7 and RichFaces version 3.2.0 SR1). Though this component correctly shows the (initial) value you set it to in your xhtml file, it does not submit this value, but an empty string instead, atleast as long as the component did not receive the focus. When the component receives the focus before submitting or when you change the value, the value is correctly submitted.

      I checked the code of the page and noticed that the comboboxField input is used to show the value on the page and that this one correctly contains the initial value, but that the comboboxValue input, which is used to submit the value, does not contain the initial value. I've determined that this part of the page comes from the combobox.jspx template file and that by replacing line 208 of that file with the following fixes the problem (tested it in our project and it worked fine):

      <input id="#{clientId}comboboxValue" name="#{clientId}comboboxValue" type="hidden" value="#{value}"/>
      


      Could somebody confirm both the error and the fix? If so, I'll add an issue to JIRA if you want, including the fix.

      Cheers,
      Tim


      Ps. Big thanks to the RichFaces team for creating this wonderful AJAX/JSF implementation.

        • 1. Re: ComboBox does not submit initial value
          ilya_shaikovsky

          We have initial requirement which tells to submit only value which was selected/typed by user. Initial value should be only shown and equals null in case of submit.

          • 2. Re: ComboBox does not submit initial value
            ilya_shaikovsky

            It's just "Rich" appearance for empty input. But actually it's empty.

            • 3. Re: ComboBox does not submit initial value
              arvhatte

              Hi Ilya,

              Are you referring to the 'defaultLabel' attribute of the combobox component? I know this attribute is used for setting a text on the combobox like 'Please select a value' and that that text isn't submitted and therefore is, like you said, a "Rich" appearance for an empty input.

              In my post, though, I'm referring to the 'value' attribute. I'm under the assumption that when setting this attribute, the value should be shown and also submitted even without having to (re)select it. OR am I wrong in this assumption, is the combobox behaving differently then most of the other JSF (and RichFaces) input components?

              My form that contains the combobox represents an entity on the server side and the entity's values are shown in all kinds of RichFaces input components. If the user wants to change one or more of the values, he/she changes them and presses submit. In case of the combobox the entity's fields are cleared now when the user does not atleast set the focus on the combobox before submitting, a behaviour which of cours is unwanted in my case.

              Cheers,
              Tim

              • 4. Re: ComboBox does not submit initial value
                ilya_shaikovsky
                • 5. Re: ComboBox does not submit initial value
                  arvhatte

                  Great. And I see it is/was already fixed in the trunk a couple of days ago, perfect.

                  Thanks RichFaces team !

                  • 6. Re: ComboBox does not submit initial value
                    danliang

                    Tim,

                    I am attempting a similar thing in where I want to "pre-populate" the comboBox with some value.

                    How did you go about setting the 'value' attribute?

                    Thanks
                    Dan

                    • 7. Re: ComboBox does not submit initial value
                      danliang

                      Well, not sure how I missed the attribute "value" in the rich faces tag... either way - figured it out...

                      • 8. Re: ComboBox does not submit initial value

                         

                        In my post, though, I'm referring to the 'value' attribute. I'm under the assumption that when setting this attribute, the value should be shown and also submitted even without having to (re)select it. OR am I wrong in this assumption, is the combobox behaving differently then most of the other JSF (and RichFaces) input components?

                        I've the same problem but in the case the attribute value is not in the combobox list. In the case the attribute value is in the combobox list, it works fine.
                        My idea is to use for example a list of countries to select, but if the passed value is not yet in my combobox, it should be saved as new item in database.
                        I'm using RichFaces version 3.2.2.

                        • 9. Re: ComboBox does not submit initial value
                          ilya_shaikovsky

                          ststroppel, actually we could not figure out you problem using "i have the same problem" description... problem could not be the same because previous posts inform us about the successfull usage.. So just add you code snippets and we wil check your case separatelly.

                          • 10. Re: ComboBox does not submit initial value

                             

                            "ilya_shaikovsky" wrote:
                            ststroppel, actually we could not figure out you problem using "i have the same problem" description... problem could not be the same because previous posts inform us about the successfull usage.. So just add you code snippets and we wil check your case separatelly.

                            you're right.
                            here's the code snippet:

                            <rich:dataTable rowKeyVar="rkv" frozenColCount="2" width="100%"
                             id="flugbuchungList" columnClasses="col" sortMode="single"
                             value="#{Reisebericht.flugbuchungen}" var="flug">
                            
                            
                             <rich:column id="abflughafen">
                             <f:facet name="header">
                             <h:outputText styleClass="headerText" value="Abflughafen" />
                             </f:facet>
                             <rich:comboBox id="abflugflughafen"
                             value="#{flug.abflugflughafen.findName}"
                             suggestionValues="#{FlughafenBean.flughaefenString}"
                             directInputSuggestions="true" required="true">
                             </rich:comboBox>
                             </rich:column>
                            
                            </rich:dataTable>
                            
                            
                            <h:commandButton id="submit" value="Sichern"
                             action="#{Reisebericht.save}" />

                            and here's a screenshots to demonstrate the problem:
                            [img]http://img354.imageshack.us/img354/7980/screenshotco1.jpg[/img]
                            the value "Echterdingen" is not part of the combobox list, but is passed by my bean. so it does not submit this value.
                            if i add the value "Echterdingen" to the combobox list, it works.


                            • 11. Re: ComboBox does not submit initial value
                              ilya_shaikovsky

                               

                              the value "Echterdingen" is not part of the combobox list, but is passed by my bean. so it does not submit this value.
                              Not sure that understand you right.

                              I've created simple sample:
                               <h:form>
                              
                               <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="20" reRender="ds" id="simpletable">
                               <f:facet name="header">
                               <rich:columnGroup>
                               <rich:column colspan="2" >
                               <h:outputText value="Filtering Example"/>
                               </rich:column>
                               <rich:column breakBefore="true">
                               <h:outputText value="State Name"/>
                               </rich:column>
                               <rich:column>
                               <h:outputText value="State Capital"/>
                               </rich:column>
                               </rich:columnGroup>
                               </f:facet>
                               <rich:column filterBy="#{cap.state}" filterEvent="onkeyup">
                               <f:facet name="header">
                               <h:outputText value=" " title="Hack due to bug. Shuold be remoevd till release"></h:outputText>
                               </f:facet>
                               <h:outputText value="#{cap.state}"/>
                               </rich:column>
                               <rich:column filterBy="#{cap.name}" filterEvent="onkeyup" styleClass="lastcolumn">
                               <rich:comboBox value="#{cap.name}" suggestionValues="#{capitalsBean.capitalsNames}">
                               </rich:comboBox>
                               </rich:column>
                               <f:facet name="footer">
                               <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                               </f:facet>
                               </rich:dataTable>
                               <h:commandButton />
                               <rich:messages></rich:messages>
                               </h:form>
                              


                              After entering sometyhing which not in list and submit click - all is ok. Messages empty. Value applied and shown...

                              • 12. Re: ComboBox does not submit initial value

                                You don't.
                                in my case, I don't enter the value, it is passed by the value-attribute of the combobox. If I don't change this value or select another, the value does not submit.

                                <rich:comboBox id="abflugflughafen"
                                value="#{flug.abflugflughafen.findName}"
                                suggestionValues="#{FlughafenBean.flughaefenString}"
                                directInputSuggestions="true" required="true">
                                </rich:comboBox>



                                • 13. Re: ComboBox does not submit initial value
                                  ilya_shaikovsky

                                  ok.. please share simple war sample with us please.. you could send me directly or just upload somewhere.

                                  • 14. Re: ComboBox does not submit initial value
                                    1 2 Previous Next