Okay - some needed input first:

- addComments is called inside the constructor of a Panel.
- FooCommentComparator sorts on a java.util.Date field inside of
FooComment
- FooComment has a user, date, and message field
- For some reason the panel shows the comments sorted by the comment's
message field 

private void addComments() {
        List<FooComment> comments = getComments();
        IDataProvider dataProvider = new ListDataProvider(comments);
        DataView commentPanels = new DataView("fooPanels", dataProvider,
PAGE_LENGTH) {
            private static final long serialVersionUID =
-3952819461137344195L;

            protected void populateItem(Item item) {
                item.add(new FooCommentPanel("commentPanel",
item.getModel()));
            }
        };
        add(commentPanels);
        PagingNavigator navigator = new PagingNavigator("navigator",
commentPanels);
        add(navigator);
        // if there aren't too few comments hide the navigator
        if (comments.size() <= PAGE_LENGTH) {
            navigator.setVisible(false);
        }
    }

private List<FooComment> getComments() {
        List<FooComment> list = new ArrayList<FooComment>(((Foo)
                CommentFormPanel.this.getModelObject()).getComments());
        Collections.sort(list, new FooCommentComparator());
        if (list == null) {
            list = new ArrayList<FooComment>();
        }
        int size = list.size();
        if (LOG.isDebugEnabled()) {
            String singPlur = size == 1 ? " comment." : " comments.";
            LOG.debug("Foo has " + size + singPlur);
        }
        return list;
    }


-----Original Message-----
From: Igor Vaynberg [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 07, 2008 2:07 PM
To: users@wicket.apache.org
Subject: Re: Sort order in DataView with ListDataProvider

paste your code

-igor


On Fri, Mar 7, 2008 at 2:03 PM, Michael Mehrle <[EMAIL PROTECTED]>
wrote:
> I'm passing a ListDataProvider when creating a DataView that shows
rows
>  of comments. Each comment has a name, a date, and a message. I am
>  creating the ListDataProvider with an ArrayList, which also has been
>  sorted with a Comparator on the date.
>
>  For whatever reason on the final page my comments are however sorted
>  alphabetically by the message. What am I doing wrong here? I thought
>  that sorting the list passed into the ListDataProvider was
sufficient.
>
>  Any help would be appreciated.
>
>  Michael
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to