What's a nice paging component ?

Hi All,

I am creating my personal table component and I’d like to manage the pagination using an external paging component.
Any suggestion about it ?
I am using Vaadin 7.
Cheers.

                Stefano

Hi Stefano,

vaadin table is paging out of the box.

Hi Wolfgang,

What do you mean ?
Cheers.

        Stefano

Hi Stefano,

vaadin Table renders just the page size of elements. If you watch this example
http://demo.vaadin.com/book-examples-vaadin7/book/#component.table.features.detailsshrink
and scroll quite fast to the end you will see how the next elements will be lazy loaded.

Could you specify your requirements?
If you want to save your database resources for example you can use the JPA container (
https://vaadin.com/directory#addon/vaadin-jpacontainer
) implementing lazy loading

Hi Wolfgang,

I’d like to add a component like this: << < 1/12 > >>
Where << go to the first page, < go to the previuos page, > go to the next page, >> go to the last page.
I saw the add-on paging component but it doesn’t seem so nice.
Cheers.

             Stefano

Hi Stefano,

sorry I thought it should be something table specific. I don’t know a matching add on but it doesn’t seem to be very tricky.
You should do it quite fast by yourself. So you can design your navigation and stuff as you want.

Something like this

public class PagingComponent extends CustomComponent {


    private final List<Component> components;
    private int pos;
    private Panel body;

    public PagingComponent() {
        components = new ArrayList<>();
        pos = 0;

        VerticalLayout layout = new VerticalLayout();
        body = new Panel();
        layout.addComponent(body);
        layout.addComponent(createNavigation());

        setCompositionRoot(layout);
    }

    public void addComponent(final Component c) {
        components.add(c);
    }

    private Component createNavigation() {
        return null;
    }

    public void next() {
        pos++;
        if (pos >= components.size()) {
            pos = 0;
        }
        showCurrent();
    }

    public void prev() {
        pos--;
        if (pos < 0) {
            pos = components.size() - 1;
        }
        showCurrent();
    }

    private void showCurrent() {
        body.setContent(components.get(pos));
    }

}

It does exist an add on you look for:
PagedTable

Hello Guys,
I have a similar requirement. I would like to use vaadin table (not paged table) and implement lazy initialization. Also, I can’t use JPA. So, I created a custom bean container as follows.

class LazyLoadedContainer extends BeanContainer { private UserService userService = new UserService(); public LazyLoadedContainer(Class type) { super(type); } @Override public int size() { return userService.size(); } @Override public BeanItem getItem(Object itemId) { return new BeanItem((User) itemId); } @Override public List getItemIds(int startIndex, int numberOfIds) { int endIndex = startIndex + numberOfIds; System.out.println("startIndex: " + startIndex + ", endIndex: " + endIndex); List<User> list = userService.list(startIndex, endIndex); return list; } } When I scroll up and down, the container makes call to the service and it returns the next items. So far so good. But the problem is that, the table treats all items as an array and don’t react to value change events. I mean, when I go up and down with the keyboard keys, the table does not trigger value change event. However, everything works fine if I use addItem(…) inetad of the above approach. Possibly, the addItem() method calls something elese on the container and sets something that I am missing. Please let me know if you have a clue.
Thanks in advance

You can try
MCont add on
, which inicializes items lazily also.