• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 17496450008

05 Sep 2025 02:44PM UTC coverage: 12.094% (+0.004%) from 12.09%
17496450008

push

github

tkuhn
Add pagination for user lists

Still showing some issues:

- sometimes (but only sometimes) jumping to the top of page on
pagination link clicking
- when the list has updated in the background, it jumps to page 1

335 of 3876 branches covered (8.64%)

Branch coverage included in aggregate %.

972 of 6931 relevant lines covered (14.02%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/UserList.java
1
package com.knowledgepixels.nanodash.component;
2

3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Map;
6

7
import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
10
import org.apache.wicket.markup.html.panel.Panel;
11
import org.apache.wicket.markup.repeater.Item;
12
import org.apache.wicket.markup.repeater.data.DataView;
13
import org.apache.wicket.markup.repeater.data.ListDataProvider;
14
import org.apache.wicket.request.mapper.parameter.PageParameters;
15
import org.eclipse.rdf4j.model.IRI;
16
import org.nanopub.extra.services.ApiResponse;
17
import org.nanopub.extra.services.ApiResponseEntry;
18

19
import com.knowledgepixels.nanodash.User;
20
import com.knowledgepixels.nanodash.Utils;
21
import com.knowledgepixels.nanodash.page.UserPage;
22

23
/**
24
 * A panel that displays a list of users with links to their user pages.
25
 * Optionally, it can also display notes associated with each user.
26
 */
27
public class UserList extends Panel {
28

29
    private static final long serialVersionUID = 1L;
30

31
    /**
32
     * Constructor for UserList.
33
     *
34
     * @param id    the component id
35
     * @param users a list of user IRI objects
36
     * @param notes a map of user IRI to notes (optional)
37
     */
38
    public UserList(String id, List<IRI> users, Map<IRI, String> notes) {
39
        super(id);
×
40
        init(users, notes);
×
41
    }
×
42

43
    /**
44
     * Constructor for UserList with a list of user IRI objects.
45
     *
46
     * @param id    the component id
47
     * @param users a list of user IRI objects
48
     */
49
    public UserList(String id, List<IRI> users) {
50
        super(id);
×
51
        init(users, null);
×
52
    }
×
53

54
    /**
55
     * Constructor for UserList that initializes from an ApiResponse.
56
     *
57
     * @param id        the component id
58
     * @param resp      the ApiResponse containing user data
59
     * @param userIdKey the key in the ApiResponse entries that contains the user IRI
60
     */
61
    public UserList(String id, ApiResponse resp, String userIdKey) {
62
        super(id);
×
63
        List<IRI> users = new ArrayList<>();
×
64
        for (ApiResponseEntry e : resp.getData()) {
×
65
            users.add(Utils.vf.createIRI(e.get(userIdKey)));
×
66
        }
×
67
        init(users, null);
×
68
    }
×
69

70
    private void init(List<IRI> users, Map<IRI, String> notes) {
71
        DataView<IRI> dataView = new DataView<>("userlist", new ListDataProvider<IRI>(users)) {
×
72

73
            private static final long serialVersionUID = 1L;
74

75
            @Override
76
            protected void populateItem(Item<IRI> item) {
77
                IRI userIri = item.getModelObject();
×
78
                PageParameters params = new PageParameters();
×
79
                params.add("id", userIri);
×
80
                BookmarkablePageLink<Void> l = new BookmarkablePageLink<Void>("userlink", UserPage.class, params);
×
81
                l.add(new Label("linktext", User.getShortDisplayName(userIri)));
×
82
                item.add(l);
×
83
                if (notes != null && notes.containsKey(userIri)) {
×
84
                    item.add(new Label("notes", notes.get(userIri)));
×
85
                } else {
86
                    item.add(new Label("notes"));
×
87
                }
88
            }
×
89

90
        };
91
        dataView.setItemsPerPage(10);
×
92
        dataView.setOutputMarkupId(true);
×
93
        add(dataView);
×
94
        AjaxPagingNavigator pagingNavigator = new AjaxPagingNavigator("navigator", dataView);
×
95
        pagingNavigator.setVisible(dataView.getPageCount() > 1);
×
96
        pagingNavigator.setOutputMarkupId(true);
×
97
        add(pagingNavigator);
×
98
    }
×
99

100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc