6 Replies Latest reply on Oct 25, 2010 4:34 AM by ilya_shaikovsky

    orderingList: How to get new order?


      I am trying to allow a user to reorder elements in a list and store the new order in the database.

      I get the list to display, but I cannot get the new order of items after a form submission. How do I do this?

      So far I have

      In the backing bean:

      public List<AuditCategory> getAuditCategoriesForSelectedProperty()
      public void setAuditCategoriesForSelectedProperty(List<AuditCategory> l)

      The list

      <rich:orderingList converter="auditCategoryConverter"
       var="cat" listHeight="300" listWidth="400">
       <rich:column width="200">
       <f:facet name="header">
       <h:outputText value="Category"/>
       <h:outputText value="#{cat.name}" />

      And a converter which I fugured out I need after looking at the richfaces code:

      public Object getAsObject(FacesContext arg0,
       UIComponent arg1, String arg2) {
      HtmlOrderingList list = (HtmlOrderingList)arg1;

      Now: I would expect that the converter would get for all objects in the correct (new) order, but doesn't seem to be the case?

      So the question remains: How do i get the new order of the list into my backing bean?

      Any pointers very welcome...

        • 1. Re: orderingList: How to get new order?

          Can JBoss reply to this please? I have the exact same need. I find it odd that this control allows you to re-order the list, but then have no way to get at the ordered list.

          Please help.

          • 2. Re: orderingList: How to get new order?

            I actually figured it out by looking at the component source code: List a lot of things with RichFaces, as soon as things go beyond "hello world". ii ts badly or not at all documented.

            Basically all you have to do is write a custom converter for the objects you are displaying in your list. This is actually redundant and should not be necessary, but hey...

            The reordered list is then available through the property-setter referenced in the value expression.

            Feel free to contact me off -list if you want a code example...

            • 3. Re: orderingList: How to get new order?

              can you give me an example code to get de new order from a list??

              • 4. Re: orderingList: How to get new order?

                Hi there,

                I have one orderinglist, 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);
                    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

                • 5. Re: orderingList: How to get new order?



                  Here's a good example resource .. check it out http://code.google.com/p/richfaces-examples/source/detail?r=7d4874785e155aac0991f3cf7d75d55706f9d9f9#



                  It really works..  I got the same problem than you ..  to get the ordered list in your backing bean you need to send the ordering list via commandbutton or via a4j:commandbutton in this case a4j be sure to put ajxSingle="false". Remember the reOrder is happening in the client side..


                  Good Luck!

                  • 6. Re: orderingList: How to get new order?

                    http://livedemo.exadel.com/richfaces-demo/richfaces/orderingList.jsf working sample. http://jboss.org/richfaces/demos - sources with Bean code available in svn.


                    unfortunatelly about the doc's you're right. there should be information that comonent requires custom converter for objects. I will add to FAQ https://jira.jboss.org/browse/RFPL-880