Example usage for org.apache.wicket.markup.html.navigation.paging PagingNavigation PagingNavigation

List of usage examples for org.apache.wicket.markup.html.navigation.paging PagingNavigation PagingNavigation

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.navigation.paging PagingNavigation PagingNavigation.

Prototype

public PagingNavigation(final String id, final IPageable pageable) 

Source Link

Document

Constructor.

Usage

From source file:hsa.awp.admingui.view.CampaignListPanel.java

License:Open Source License

/**
 * Constructor with {@link Panel}ID.//from  w  ww.jav  a 2 s. c o  m
 *
 * @param id the id of the {@link Panel}.
 */
public CampaignListPanel(String id) {

    super(id);

    Form<Object> sortChoiceForm = new Form<Object>("campaignList.sortChoices");
    add(sortChoiceForm);

    LinkedList<String> sortFieldChoices = new LinkedList<String>();
    sortFieldChoices.addAll(SortChoice.names());

    LinkedList<String> sortDirectionChoices = new LinkedList<String>();
    sortDirectionChoices.add(ascending);
    sortDirectionChoices.add(descending);

    final DropDownChoice<String> sortFields = new DropDownChoice<String>("campaignList.sortFields",
            new Model<String>(ascending), sortFieldChoices);
    sortFields.setOutputMarkupId(true);
    sortChoiceForm.add(sortFields);

    final DropDownChoice<String> sortDirections = new DropDownChoice<String>("CampaignList.sortDirections",
            new Model<String>(SortChoice.NAME.name), sortDirectionChoices);
    sortDirections.setOutputMarkupId(true);
    sortChoiceForm.add(sortDirections);

    sortFields.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        /**
         * unique serialization id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            boolean asc = false;
            if (sortDirections.getModelObject() != null && sortDirections.getModelObject().equals(ascending)) {
                asc = false;
            }
            sort(SortChoice.choiceByName(sortFields.getModelObject()), asc);
            target.addComponent(campaignListMarkupContainer);
        }
    });

    sortDirections.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        /**
         * unique serialization id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            boolean asc = false;
            if (sortDirections.getModelObject() != null && sortDirections.getModelObject().equals(ascending)) {
                asc = false;
            }
            sort(SortChoice.choiceByName(sortFields.getModelObject()), asc);
            target.addComponent(campaignListMarkupContainer);
        }
    });

    campaigns = controller.getCampaignsByMandator(getSession());

    ListActiveCampaignsPanel activeCampaigns = new ListActiveCampaignsPanel("campaignList.activeCampaigns");
    activeCampaigns.add(new AjaxSelfUpdatingTimerBehavior(Duration.minutes(5d)));
    add(activeCampaigns);

    final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");

    campaignList = new PageableListView<Campaign>("campaignList", campaigns, pagesize) {
        /**
         * unique identifier.
         */
        private static final long serialVersionUID = 5446468946546848946L;

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

            Campaign campaign = item.getModelObject();

            Label state = new Label("campaignState");
            String stateString;
            if (campaign.isRunning()) {
                stateString = "running";
            } else if (campaign.isTerminated()) {
                stateString = "terminated";
            } else {
                stateString = "notYetStarted";
            }
            state.add(new AttributeAppender("class", new Model<String>(stateString), " "));
            item.add(state);

            item.add(new Label("startShow", format.format(item.getModelObject().getStartShow().getTime())));
            item.add(new Label("endShow", format.format(item.getModelObject().getEndShow().getTime())));

            item.add(new Label("campaignName", item.getModelObject().getName()));

            item.add(createEditLink(item));
            item.add(createDetailLink(item));
            AbstractDeleteLink<Campaign> deleteLink = new AbstractDeleteLink<Campaign>("deleteLink",
                    item.getModelObject()) {
                @Override
                public void modifyItem(Campaign campaign) {
                    controller.deleteCampaign(campaign);
                    setResponsePage(new OnePanelPage(new CampaignListPanel(OnePanelPage.getPanelIdOne())));
                }
            };
            deleteLink.setVisible(!(item.getModelObject().getAppliedProcedures().size() > 0));
            item.add(deleteLink);
        }

        private Link<AlterCampaignPanel> createEditLink(final ListItem<Campaign> item) {
            Link<AlterCampaignPanel> alterCampaign = new Link<AlterCampaignPanel>("campaignLink",
                    new PropertyModel<AlterCampaignPanel>(AlterCampaignPanel.class, "alterCampaign")) {
                /**
                 * unique serialization id.
                 */
                private static final long serialVersionUID = -5466954901705080742L;

                @Override
                public void onClick() {

                    setResponsePage(new OnePanelPage(new AlterCampaignPanel(OnePanelPage.getPanelIdOne(),
                            item.getModelObject().getId())));
                }
            };

            AccessUtil.allowRender(alterCampaign, "editCampaign");

            return alterCampaign;
        }

        private Link<CampaignDetailPanel> createDetailLink(final ListItem<Campaign> item) {
            Link<CampaignDetailPanel> campDetail;
            campDetail = new Link<CampaignDetailPanel>("eventList",
                    new PropertyModel<CampaignDetailPanel>(CampaignDetailPanel.class, "eventList")) {
                /**
                 * unique serialization id.
                 */
                private static final long serialVersionUID = -5466954901732080742L;

                @Override
                public void onClick() {

                    setResponsePage(new OnePanelPage(new CampaignDetailPanel(OnePanelPage.getPanelIdOne(),
                            item.getModelObject().getId())));
                }
            };
            return campDetail;
        }
    };
    campaignList.setOutputMarkupId(true);
    sort(SortChoice.NAME, true);

    campaignListMarkupContainer = new WebMarkupContainer("campaignList.listContainer");
    campaignListMarkupContainer.add(campaignList);
    campaignListMarkupContainer.setOutputMarkupId(true);

    PagingNavigation navigation = new PagingNavigation("campaignList.navigation", campaignList);
    navigation.setOutputMarkupId(true);
    campaignListMarkupContainer.add(navigation);

    if (campaignList.getModelObject().size() < pagesize) {
        navigation.setVisible(false);
    }

    add(campaignListMarkupContainer);
    add(feedbackPanel);
}

From source file:net.unit8.longadeseo.page.HomePage.java

License:Apache License

public HomePage() {
    add(new Label("pageTitle", "Top"));

    Form<ValueMap> form = new SearchForm("searchForm");
    form.setMarkupId("searchform");
    add(form);/*from w ww.j av  a  2  s.c o m*/

    final PageableListView<SearchResultDto> listView = new PageableListView<SearchResultDto>("results", results,
            5) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<SearchResultDto> item) {
            SearchResultDto row = item.getModelObject();
            item.add(new Label("excerpt", row.getExcerpt()).setEscapeModelStrings(false));
            ExternalLink link = new ExternalLink("titleLink",
                    WebApplication.get().getServletContext().getContextPath() + "/repository/default"
                            + row.getPath());
            link.add(new Label("title", row.getTitle()));
            item.add(link);
            item.add(new Label("size", String.valueOf(Math.round(Math.ceil(row.getSize() / 1000d))) + "k"));
            item.add(new Label("lastModified", df.format(row.getLastModified().getTime())));
            item.add(new Label("path", row.getPath()));
        }
    };
    add(listView);

    add(new PagingNavigation("navigation", listView) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(LoopItem loopItem) {
            final int page = loopItem.getIndex();
            final PagingNavigationLink<Label> link = new PagingNavigationLink<Label>("pageLink", listView,
                    page);
            if (page > 0) {
                loopItem.add(new Label("separator", "|"));
            } else {
                loopItem.add(new Label("separator", ""));
            }
            link.add(new Label("pageNumber", String.valueOf(page + 1)));
            loopItem.add(link);
        }
    });
}

From source file:transactions.TransactionsWritablePanel.java

License:Open Source License

/**
 * DOCUMENT: Constructs ...//from   w w  w.j  a  va2 s  .c o m
 *
 * @param id DOCUMENT: id description.
 */
public TransactionsWritablePanel(final String id) {
    super(id);
    setVersioned(true);
    setOutputMarkupId(true);

    add(new Form("toolbar")
            .add(new DropDownChoice<DateFilterEnum>("when", new PropertyModel(this, "when"),
                    Lists.newArrayList(DateFilterEnum.values())).add(newFilteringBehavior()))
            .add(new TextField<String>("refNum", new PropertyModel(this, "refNum")).add(newFilteringBehavior()))
            .add(new TextField<Integer>("transId", new PropertyModel(this, "transId"))
                    .add(newFilteringBehavior())));

    add(transactionsView = new PageableListView<CoreTransactionDTO>("transactions", getTransactionsModel(), 6) {
        @Override
        protected void populateItem(ListItem<CoreTransactionDTO> item) {
            final IModel<CoreTransactionDTO> model = item.getModel();
            item.add(new Label("id", new PropertyModel(model, "id")));
            AjaxLink link = new AjaxLink("ref") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    transaction = model.getObject();
                    target.add(detailsContainer);
                }
            };
            link.add(new Label("label", new PropertyModel(model, "transactionReferenceCode")));
            item.add(link);
            item.add(new Label("type", new PropertyModel(model, "transactionTypeId.id")));
            item.add(new Label("status", new PropertyModel(model, "status")));
            item.add(new Label("created", new PropertyModel(model, "creationDate")));
        }

    });
    add(new PagingNavigation("navigator", transactionsView));

    detailsContainer = new WebMarkupContainer("detailsContainer");
    add(detailsContainer.setOutputMarkupId(true));
    detailsContainer.add(new ListView<CoreStepDTO>("details", getStepsModel()) {
        @Override
        protected void populateItem(ListItem<CoreStepDTO> item) {
            IModel<CoreStepDTO> model = item.getModel();
            item.add(new Label("name", new PropertyModel(model, "operation")));
            item.add(new Label("status", new PropertyModel(model, "resultId.name")));
            item.add(new Label("msgs", new PropertyModel(model, "coreMessageCollection")));
        }
    });
}