greedsin
greedsin

Reputation: 1272

Wicket lazy load a ListView

Is it possible to lazy load a ListView in Wicket? Which means for me that inside populateItem can I load and display Item 0 and when Item 0 is rendered then proceed to Item 1. Currently I have to wait until all Items are processed inside populateItem.

Upvotes: 0

Views: 391

Answers (1)

soorapadman
soorapadman

Reputation: 4509

As RobAu mentioned you can achieve this using AjaxLazyLoadPanel(wicket-extension) with minimal changes in your coding . Let's consider you are having Item as a model.

        List<Item> itemList = new ArrayList<>();
        itemList.add(new Item());
        itemList.add(new Item());

        ListView<Item>itemListView = new ListView<Item>("itemListView",ItemList) {
            @Override
            protected void populateItem(final ListItem<Item> listItem) {
            listItem.add(new AjaxLazyLoadPanel("ViewItemPanel") {
                @Override
                public Component getLazyLoadComponent(String s) {
                     // Add a seperate panel if you are listing out many values
                    return new ItemPanel(s,listItem.getModelObject());
                }
            });
            }
        };
        add(itemListView);

ItemPanel its to seperate the component if you have to show many.

Upvotes: 3

Related Questions