开发者

Wicket: Repeater component which appends more items when scrolled to bottom?

Is there a repeater component which would append more items through ajax when scrolled down, but would not keep all items in model? Something like facebook does when you click "More".

In other words, how can I append to a component, while leaving the current content, without caring about it?

Note: I am looking for general solution, not only for tables.

Update: I'm okay with need to write some JavaScript.

Update: I think I could 1) Add some empty component after the ListView 2) When appending, replace this with a new ListView, and add another empty after that. Not开发者_开发技巧 sure if it's achievable in Wicket.


See https://github.com/reaktor/oegyscroll


Update: I think I could 1) Add some empty component after the ListView 2) When appending, replace this with a new ListView, and add another empty after that. Not sure if it's achievable in Wicket.

Sounds right. For the simple part ("More button"), just create a new Panel that holds a RepeatingView, a empty WebMarkupContainer and an AjaxLink (add some logic if paging is allowed/link is visible).

Now for the onClick of the AjaxLink replace your WebMarkupContainer with the same panel you're using, add some paging information and hide the AjaxLink.

I've written a extremly basic example to illustrate an possible approach.

public class MoreRepeaterPanel extends Panel {

public MoreRepeaterPanel(String id, IModel<?> model) {
    super(id, model);

}

@Override
protected void onInitialize() {
    super.onInitialize();

    List<String> stringList = Arrays.asList(new String[] { "0", "1" });
    IDataProvider<String> idataProvider = new ListDataProvider(stringList);

    DataView<String> dataView = new DataView<String>("dataView", idataProvider) {

        @Override
        protected void populateItem(Item<String> item) {
            item.add(new Label("dataString", item.getModelObject()));
        }
    };
    add(dataView);

    final WebMarkupContainer moreContent = new WebMarkupContainer("moreContent", new Model<Serializable>());
    moreContent.setOutputMarkupId(true);
    add(moreContent);

    AjaxLink<Void> moreLink = new AjaxLink<Void>("moreLink") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            WebMarkupContainer replaceMoreContent = new MoreRepeaterPanel(moreContent.getId(), new Model<Serializable>());
            moreContent.replaceWith(replaceMoreContent);
            this.setVisible(false);

            target.add(replaceMoreContent, this);
        }
    };
    moreLink.setOutputMarkupId(true);
    add(moreLink);
}

}


You can probably create such a repeater from an AjaxFallbackDefaultDataTable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜