In your setupRender method of your page take the Set of beans add them in a List and sort acordingly. Pass the list as the source for the loop.

Cheers,
Joost

Like:

@SetupRender
private void setup() {
   Set<MyBean> mySet = ... whereverItComesFrom;
   List<MyBean> myList = new ArrayList<MyBean>();
   myList.addAll(mySet);
   Collections.sort(myList, DATE_COMPERATOR);
}

/**
    * This comperator will place the latest entry at the top
    */
public final static Comparator<MyBean> DATE_COMPERATOR = new Comparator<MyBean>() {

       public int compare(MyBean bean1, MyBean bean2) {
           return bean1.getPostDate().compareTo(bean2.getPostDate());
       }
};

blueboy6 wrote:
Hi everyone,

I have a question,

I have a set of beans that I'm parsing to loop component to generate divs
and populate them with data and other components that I'm using, now in this
beens i have date property.

What is best way to sort this set by date???

I was thinking to apply sorter from grid, but I'm not sure how...

Does anyone have idea what to do here?
Thank you in advance :)
Bojan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

  • T5 loop sort blueboy6
    • Re: T5 loop sort Joost Schouten (ml)

Reply via email to