6 Replies Latest reply on Jul 25, 2008 9:11 AM by mail.micke

    Loading Dropdown List data On Click

    rmuruga

      Hi ,
        Iam new to richfaces, i wanted to load the data for rich:selectmenu on event basis like onClick or onFocus , please suggest me how to do that .


        • 1. Re: Loading Dropdown List data On Click
          mail.micke

          Have a look at the a4j:support tag (top left side on this page is a link to the developer docs which contains some more information).


          This tag will allow you to initiate an ajax call on the onclick javascript event.


          - micke

          • 2. Re: Loading Dropdown List data On Click
            rmuruga

            Hi Micke,
              Thanks for Replying to my post ,but the a4j:support will re-render the given UI id , what i need is i need to display a drop-down list and while clicking it the data for the list should be loaded .


            Thanks
            Muruga

            • 3. Re: Loading Dropdown List data On Click
              mail.micke

              Aha, I see.


              I haven't tried this one myself but the rich:suggestionbox might be what you are looking for.


              - micke

              • 4. Re: Loading Dropdown List data On Click
                damianharvey.damianharvey.gmail.com

                So are you trying to late-load your drop-down after the page has rendered?


                You can still accomplish this with a4j:support by doing something like this:


                <h:selectOneMenu id="myfield" value="#{myBean.myField}">
                     <s:selectItems value="#{myBean.myFieldList}" var="field" label="#{field.name}" noSelectionLabel="click to load list" />
                     <s:convertEntity/>
                     <a:support event="onfocus"
                          ajaxSingle="true"
                          reRender="myfield"
                          action="#{myBean.loadMyFieldList}"/>                                                  
                     <a:support event="onchange"
                          ajaxSingle="true"
                          reRender="anotherField"/>
                </h:selectOneMenu>
                


                The only problem is the stutter when the list is reRendered, but it's not a bad option if you have a list that you'd rather not have on page load due to it's size.


                Cheers,


                Damian

                • 5. Re: Loading Dropdown List data On Click
                  rmuruga

                  Can you post any sample for Suggestion box, i have checked the link what you have given , not idea how the autoComplete method should be .Please suggest me how to do that.


                  • 6. Re: Loading Dropdown List data On Click
                    mail.micke

                    Bookmark this page RichFaces live demo.


                    It contains demo, code snippets and links to the developer guide for all of the richfaces components. The source code for this is also in the SVN for you to download.


                    Here on the jboss richfaces home page you can find links to the forum and SVN.


                    Other than this I can't offer much more help since I haven't used the component myself yet.


                    - micke