8 Replies Latest reply on Aug 2, 2010 6:50 AM by ilya_shaikovsky

    How to actually use rich:orderingList

    glammy

      I want to achieve something fairly trivial:

       

      - let the user reorder the elements in the rich:orderingList

      - on each reorder I want another component changed based on the new order (and an action method called before that)

       

      I tried with both <a4j:support and with <a4j:jsFunction (on "onchange" and "onchanged"), but the "value" of the ordering list is unchanged - i.e. the List to which I set the "value" attribute retains its initial order.

       

      I ended up calling "getExtendedDataModel" using reflection on the binded "HtmlOrderingList", which returns the properly ordered collection, but it is an ugly hack, and furthermore, it doesn't fit my case entirely.

       

      So, is this possibly a bug in the orderingList, or I'm misunderstanding something?

        • 1. Re: How to actually use rich:orderingList
          ilya_shaikovsky
          use onorderchanged event for support.
          • 2. Re: How to actually use rich:orderingList
            glammy
            Both onorderchanged and onorderchange yield the same result.
            • 3. Re: How to actually use rich:orderingList
              ilya_shaikovsky
              checked with richfaces-demo code under 3.3.3 snapshot. onorderchanged works just as you expects. And onorderchange works as described in your problem - but it's designed behavior - this event risen before actual order change.
              • 4. Re: How to actually use rich:orderingList
                glammy

                Still not working here, Richfaces 3.3.2.SR1

                 

                <rich:orderingList binding="#{routeController.stopsTable}"
                                                    var="stop" value="#{routeController.stopsList}"
                                                    converter="#{stopListConverter}" showButtonLabels="false"
                                                    listWidth="500" listHeight="150" id="stopsTable">

                 

                            <a4j:support event="onorderchanged" ajaxSingle="true"
                                                        immediate="true" action="#{routeController.listReordered}" />

                            ....

                </rich:orderingList>

                 

                The converter gets the List reference, and finds the item by name (correctly).

                 

                When I put System.out.println(stopsList); in the listReordered() method, it outputs the same sequence of objects after each reorder.

                 

                I tried removing the "binding" temoporarily - doesn't work

                 

                Using what code did you make it work?

                • 5. Re: How to actually use rich:orderingList
                  nbelaevski

                  Hi,

                   

                  You are using a4j:support that has immediate="true" and that prevents model beans from updating. See documentation for "immediate" attribute for more information.

                  • 6. Re: How to actually use rich:orderingList
                    glammy

                    Yes, I'm aware of what "immediate" is doing, but this one seems to have slipped through my fingers.

                     

                    Perhaps because I don't want to validate (and eventually fail the validation) of other field in the page. But ajaxSingle should take care of that and not submit those.

                     

                    Thanks

                    • 7. Re: How to actually use rich:orderingList
                      baranjsf

                      Hi there,

                      I have source code like Bozhidar, but I could not get the new order in my backing bean. Would you plz help me?

                      It is my ordering list:

                       

                      My rankList will be initialized in init() method in my backing bean:

                       

                      rankList = new ArrayList<Rank>();
                      rankList.add(new Rank("Alabama Montgomery"));
                          rankList.add(new Rank("Alaska Juneau"));
                          rankList.add(new Rank("Arizona Phoenix"));
                          rankList.add(new Rank("Arkansas Little Rock"));
                          rankList.add(new Rank("California Sacramento"));
                          rankList.add(new Rank("Colorado Denver"));
                          rankList.add(new Rank("Connecticut Hartford"));
                          rankList.add(new Rank("Delaware Dover"));
                          rankList.add(new Rank("Florida Tallahassee"));
                          rankList.add(new Rank("Georgia Atlanta"));
                          rankList.add(new Rank("Hawaii Honolulu"));
                          rankList.add(new Rank("Idaho Boise"));
                      

                      and it is my findEperts method in my backing bean:

                       

                      public void findExperts (){

                          System.out.println("FIND EXPERT:Hi"+rankList);
                          resultsList.clear();
                          BusinessLogic bs = new BusinessLogic();
                          resultsList = bs.search(searchedTopicList);
                         
                      }

                      and it is my convertor:

                       

                      public class StringToRankListConverter implements Converter {
                          public Object getAsObject(FacesContext context, UIComponent component, String value) {
                      
                              System.out.println("StringToRankListConverter value: "+value.toString());
                              String[] words = value.split (":");
                              String name = words[0];
                            
                      
                              Rank wonder = new Rank(name);
                      
                              return wonder;
                          
                              
                          }    
                          public String getAsString(FacesContext context, 
                                    UIComponent component, Object value) {
                                   return value.toString();
                          }
                      
                      }
                      

                      Sometimes  a4j:support calls my findexperts method, and sometimes does not call. But I saw in my setRankList and getrankList and findExpert method that the rankList has the old order, not a new order.

                      Thank in advance

                      • 8. Re: How to actually use rich:orderingList
                        ilya_shaikovsky

                        http://community.jboss.org/message/555322#555322 - do not duplication questions please or you will loose the thread where we trying to answer.