You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by blueboy6 <bl...@gmail.com> on 2009/11/27 17:41:55 UTC
T5 loop sort
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
--
View this message in context: http://old.nabble.com/T5-loop-sort-tp26544856p26544856.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 loop sort
Posted by "Joost Schouten (ml)" <jo...@jsportal.com>.
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org