Example usage for org.apache.wicket.markup.html.list PageableListView PageableListView

List of usage examples for org.apache.wicket.markup.html.list PageableListView PageableListView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list PageableListView PageableListView.

Prototype

public PageableListView(final String id, final List<T> list, final long itemsPerPage) 

Source Link

Document

Creates a pageable list view having the given number of rows per page that uses the provided object as a simple model.

Usage

From source file:abid.password.wicket.pages.LoginPage.java

License:Apache License

public LoginPage() {
    LoginPanel loginPanel = new LoginPanel("loginPanel");
    add(loginPanel);/*from w  ww  .  java  2 s . c  o  m*/

    LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<User> load() {
            return userService.getUsers();
        }
    };

    PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> item) {
            final User data = item.getModelObject();
            Label userLabel = new Label("userLabel", data.getUsername());
            Label passLabel = new Label("passLabel", data.getPassword());

            try {
                Password password = new MutablePasswordParser().parse(data.getPassword());
                if (password instanceof MutablePassword) {
                    MutablePassword mutablePassword = (MutablePassword) password;
                    String evalatedPassword = mutablePassword.getEvaluatedPassword();
                    passLabel = new Label("passLabel", evalatedPassword);
                }
            } catch (Exception e) {
                log.error("Could not create the mutable password", e);
            }

            item.add(userLabel);
            item.add(passLabel);
        }
    };

    int refreshTime = 3;
    final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer");
    usersContainer.setOutputMarkupId(true);
    usersContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime)));
    usersContainer.add(dataList);

    String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime);
    String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually.";
    AjaxFallbackLabel refreshLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation,
            javascriptDisabledMsg);

    add(usersContainer);
    add(refreshLabel);
}

From source file:abid.password.wicket.pages.UsersPage.java

License:Apache License

public UsersPage() {

    LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() {

        private static final long serialVersionUID = 1L;

        @Override/*from  w ww. j a v a 2 s . c om*/
        protected List<User> load() {
            return userService.getUsers();
        }
    };

    PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> item) {
            final User data = item.getModelObject();
            Label userLabel = new Label("userLabel", data.getUsername());
            Label passLabel = new Label("passLabel", data.getPassword());

            try {
                Password password = new MutablePasswordParser().parse(data.getPassword());
                if (password instanceof MutablePassword) {
                    MutablePassword mutablePassword = (MutablePassword) password;
                    String evalatedPassword = mutablePassword.getEvaluatedPassword();
                    passLabel = new Label("passLabel", evalatedPassword);
                }
            } catch (Exception e) {
                log.error("Could not create the mutable password", e);
            }

            item.add(userLabel);
            item.add(passLabel);
        }
    };

    int refreshTime = 3;
    final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer");
    dataContainer.setOutputMarkupId(true);
    dataContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime)));
    dataContainer.add(dataList);

    String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime);
    String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually.";
    AjaxFallbackLabel refreshInfoLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation,
            javascriptDisabledMsg);

    add(dataContainer);
    add(refreshInfoLabel);
}

From source file:au.org.theark.admin.web.component.activitymonitor.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public PageableListView<ArkSubjectSessionVO> buildPageableListView(IModel iModel) {
    PageableListView<ArkSubjectSessionVO> pageableListView = new PageableListView<ArkSubjectSessionVO>("list",
            iModel,//from   w ww.j a  v  a  2s .com
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ArkSubjectSessionVO> item) {
            final ArkSubjectSessionVO subject = (ArkSubjectSessionVO) item.getModelObject();
            final String sessionId = subject.getSessionId();
            final String userId = subject.getUserId();
            final String host = subject.getHost();
            final Date startTimestamp = subject.getStartTimestamp();
            final Date lastAccessTime = subject.getLastAccessTime();
            SimpleDateFormat sdf = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY_HH_MM_SS);

            item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_ID, sessionId));
            item.add(new Label(au.org.theark.core.Constants.ARK_USERID, userId));
            item.add(new Label(au.org.theark.core.Constants.ARK_HOST, host));
            item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_START_TIMESTAMP,
                    sdf.format(startTimestamp)));
            item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_LAST_ACCESS_TIME,
                    sdf.format(lastAccessTime)));

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1938679383897533820L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return pageableListView;
}

From source file:au.org.theark.admin.web.component.function.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public PageableListView<ArkFunction> buildPageableListView(IModel iModel,
        final WebMarkupContainer searchResultsContainer) {
    PageableListView<ArkFunction> pageableListView = new PageableListView<ArkFunction>("arkFunctionList",
            iModel,/*from   w ww .  ja v a  2 s.c om*/
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        private static final long serialVersionUID = 3350183112731574263L;

        @Override
        protected void populateItem(final ListItem<ArkFunction> item) {

            ArkFunction arkFunction = item.getModelObject();

            item.add(buildLink(arkFunction));

            if (arkFunction.getName() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkFunction.name", arkFunction.getName()));
            } else {
                item.add(new Label("arkFunction.name", ""));
            }

            if (arkFunction.getDescription() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkFunction.description", arkFunction.getDescription()));
            } else {
                item.add(new Label("arkFunction.description", ""));
            }

            if (arkFunction.getArkFunctionType() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkFunction.arkFunctionType", arkFunction.getArkFunctionType().getName()));
            } else {
                item.add(new Label("arkFunction.arkFunctionType", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1938679383897533820L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };
    return pageableListView;
}

From source file:au.org.theark.admin.web.component.module.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public PageableListView<ArkModule> buildPageableListView(IModel iModel,
        final WebMarkupContainer searchResultsContainer) {
    PageableListView<ArkModule> pageableListView = new PageableListView<ArkModule>("arkModuleList", iModel,
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        private static final long serialVersionUID = 3350183112731574263L;

        @Override//from w  w  w.j a  v a2s .  co  m
        protected void populateItem(final ListItem<ArkModule> item) {
            ArkModule arkModule = item.getModelObject();

            item.add(buildLink(arkModule));

            if (arkModule.getName() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkModule.name", arkModule.getName()));
            } else {
                item.add(new Label("arkModule.name", ""));
            }

            if (arkModule.getDescription() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkModule.description", arkModule.getDescription()));
            } else {
                item.add(new Label("arkModule.description", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1938679383897533820L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };
    return pageableListView;
}

From source file:au.org.theark.core.web.component.customfieldupload.SearchResultListPanel.java

License:Open Source License

/**
 * //w ww.  ja  v  a 2s .  co  m
 * @param iModel
 * @return the pageableListView of Upload
 */
public PageableListView<Upload> buildPageableListView(IModel iModel) {
    PageableListView<Upload> sitePageableListView = new PageableListView<Upload>(Constants.RESULT_LIST, iModel,
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Upload> item) {
            Upload upload = item.getModelObject();

            // The ID
            if (upload.getId() != null) {
                // Add the id component here
                item.add(new Label(Constants.UPLOADVO_UPLOAD_ID, upload.getId().toString()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_ID, ""));
            }

            // / The filename
            if (upload.getFilename() != null) {
                // Add the id component here
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FILENAME, upload.getFilename()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FILENAME, ""));
            }

            // File Format
            if (upload.getFileFormat() != null) {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FILE_FORMAT, upload.getFileFormat().getName()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FILE_FORMAT, ""));
            }

            // UserId
            if (upload.getUserId() != null) {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_USER_ID, upload.getUserId()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_USER_ID, ""));
            }

            // Start time
            if (upload.getStartTime() != null) {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_START_TIME, upload.getStartTime().toString()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_START_TIME, ""));
            }

            // Finish time
            if (upload.getFinishTime() != null) {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FINISH_TIME, upload.getFinishTime().toString()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_FINISH_TIME, ""));
            }

            if (upload.getUploadStatus() != null && upload.getUploadStatus().getShortMessage() != null) {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME,
                        upload.getUploadStatus().getShortMessage()));
            } else {
                item.add(new Label(Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME, ""));
            }

            // Download file link button
            item.add(buildDownloadButton(upload));

            // Download upload report button
            item.add(buildDownloadReportButton(upload));

            // For the alternative stripes
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return sitePageableListView;
}

From source file:au.org.theark.core.web.component.panel.table.DataTablePanel.java

License:Open Source License

private void initBody() {
    // Using a nested ListViews
    //TODO Constant for page size
    PageableListView<List<String>> listView = new PageableListView<List<String>>("data", data, 15) {

        private static final long serialVersionUID = 1L;

        @Override/*from w w  w  .  j ava 2s .com*/
        protected void populateItem(ListItem<List<String>> item) {
            IModel model = item.getModel();
            item.add(new ListView<String>("cols", model) {
                private static final long serialVersionUID = 1L;

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

            });

        }
    };
    table.add(listView);
    add(new PagingNavigator("navigator", listView));
}

From source file:au.org.theark.disease.web.component.affection.SearchResultListPanel.java

License:Open Source License

public PageableListView<AffectionVO> buildListView(IModel iModel) {

    PageableListView<AffectionVO> listView = new PageableListView<AffectionVO>("affectionList", iModel,
            iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        @Override/*from   w  ww  . java2 s. co m*/
        protected void populateItem(final ListItem<AffectionVO> item) {
            Affection affection = item.getModelObject().getAffection();
            item.add(new Label("affection.id", affection.getId().toString()));
            item.add(buildLink(item.getModelObject()));
            item.add(new Label("affection.recordDate", affection.getRecordDate().toString()));
            item.add(new Label("affection.status", affection.getAffectionStatus().getName()));
            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return listView;
}

From source file:au.org.theark.disease.web.component.disease.SearchResultListPanel.java

License:Open Source License

public PageableListView<DiseaseVO> buildListView(IModel iModel) {

    PageableListView<DiseaseVO> listView = new PageableListView<DiseaseVO>("diseaseList", iModel,
            iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        @Override//from  w w  w . j  av  a2s .  c o  m
        protected void populateItem(final ListItem<DiseaseVO> item) {
            Disease disease = item.getModelObject().getDisease();

            item.add(new Label("disease.id", disease.getId().toString()));
            item.add(buildLink(item.getModelObject()));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return listView;
}

From source file:au.org.theark.disease.web.component.gene.SearchResultListPanel.java

License:Open Source License

public PageableListView<GeneVO> buildListView(IModel iModel) {

    PageableListView<GeneVO> listView = new PageableListView<GeneVO>("diseaseList", iModel,
            iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

        @Override//from   w  ww. ja v  a  2s.co  m
        protected void populateItem(final ListItem<GeneVO> item) {

            Gene gene = item.getModelObject().getGene();

            item.add(new Label("gene.id", gene.getId().toString()));

            item.add(buildLink(item.getModelObject()));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return listView;
}