Example usage for org.apache.wicket.markup.repeater.data DataView DataView

List of usage examples for org.apache.wicket.markup.repeater.data DataView DataView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater.data DataView DataView.

Prototype

protected DataView(String id, IDataProvider<T> dataProvider, long itemsPerPage) 

Source Link

Usage

From source file:eu.uqasar.web.pages.products.ProductManagementPage.java

License:Apache License

/**
 * Constructor building the page/*  ww w .ja  va  2  s.  com*/
 *
 * @param parameters
 */
public ProductManagementPage(final PageParameters parameters) {

    super(parameters);

    productProvider = new ProductProvider();

    final Form<Product> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    filterPanel = new ProductManagementPanel("filter") {

        /**
         * 
         */
        private static final long serialVersionUID = -3833651464215590534L;

        @Override
        public void resetClicked(AjaxRequestTarget target, Form<?> form) {
            productProvider.setFilter(productFilterStructure);
            target.add(productsContainer);
        }

        @Override
        public void applyClicked(AjaxRequestTarget target, Form<?> form) {
            productProvider.setFilter(this.getFilter());
            target.add(productsContainer);

        }
    };
    deleteForm.add(filterPanel);

    productFilterStructure = new ProductFilterStructure(filterPanel);

    // add checkgroup for selecting multiple products
    deleteForm.add(productGroup = newProductCheckGroup());

    // add the container holding list of existing products
    productGroup.add(productsContainer.setOutputMarkupId(true));

    productsContainer.add(new CheckGroupSelector("productGroupSelector", productGroup));

    DataView<Product> products = new DataView<Product>("products", productProvider, itemsPerPage) {

        private static final long serialVersionUID = 789669450347695209L;

        @Override
        protected void populateItem(final Item<Product> item) {
            final Product Product = item.getModelObject();

            item.add(new Check<>("productCheck", item.getModel(), productGroup));

            item.add(new Label("name", new PropertyModel<String>(Product, "name")));

            item.add(new Label("description", new PropertyModel<String>(Product, "description")));

            item.add(new Label("version", new PropertyModel<String>(Product, "version")));

            item.add(new DateLabel("releaseDate", new PropertyModel<Date>(Product, "releaseDate"),
                    new PatternDateConverter("dd.MM.yyyy", true)));

            // add button to show AddEditPage
            item.add(new BookmarkablePageLink<ProductAddEditPage>("edit", ProductAddEditPage.class,
                    ProductAddEditPage.linkToEdit(Product)));
        }
    };
    // add list of products to container
    productsContainer.add(products);

    // add button to create new Product
    productsContainer
            .add(new BookmarkablePageLink<ProductAddEditPage>("addProductLink", ProductAddEditPage.class));

    // add links for table pagination
    productsContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", products));
    productsContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", products));

    // add button to delete selected products
    productsContainer.add(deleteSelectedButton = newDeleteSelectedButton(productGroup));

    // add confirmation modal for deleting products
    add(deleteConfirmationModal = newDeleteConfirmationModal());
}

From source file:eu.uqasar.web.pages.search.resultpanels.AbstractSearchResultsPanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    entities = new DataView<T>("entities", getEntityProvider(), getItemsPerPage()) {
        private static final long serialVersionUID = 1918076240043442975L;

        @Override/*www  .  j  a  v  a  2s. c  o m*/
        protected void populateItem(final Item<T> item) {
            populateDataViewItem(item);
        }
    };
    container.add(entities);
    container.add(
            new Label("table.head", new StringResourceModel("panel.title", this, null, Model.of(searchTerm))));
    tableFoot.add(new BootstrapAjaxPagingNavigator("navigatorFoot", entities));
}

From source file:eu.uqasar.web.pages.tree.historic.baseindicator.HistoricBaseIndicatorPage.java

License:Apache License

/**
 * Constructor building the page/* w  ww . jav a  2s.  c o  m*/
 *
 * @param parameters
 */
public HistoricBaseIndicatorPage(final PageParameters parameters) {

    super(parameters);

    // set the Base indicator
    baseIndicatorId = parameters.get("id").toOptionalLong();
    baseIndicator = historicalService.getBaseIndicatorById(baseIndicatorId);

    add(new Label("metricName", baseIndicator.getName()));

    final Form<AbstractHistoricValues> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    // add checkgroup for selecting multiple measurements
    deleteForm.add(dataGroup = newDataCheckGroup());

    // add the container holding list of existing measurements
    dataGroup.add(dataContainer.setOutputMarkupId(true));

    dataContainer.add(new CheckGroupSelector("dataGroupSelector", dataGroup));

    DataView<AbstractHistoricValues> dataMeasurements = new DataView<AbstractHistoricValues>("dataMeasurements",
            new DataProvider(), itemsPerPage) {

        private static final long serialVersionUID = 7687248000895943825L;

        @Override
        protected void populateItem(final Item<AbstractHistoricValues> item) {
            final AbstractHistoricValues historicDataMeasurement = item.getModelObject();

            item.add(new Check<>("dataCheck", item.getModel(), dataGroup));

            item.add(new Label("value", new PropertyModel<String>(historicDataMeasurement, "value")));

            item.add(new Label("targetValue",
                    new PropertyModel<String>(historicDataMeasurement, "targetValue")));

            item.add(new Label("lowerAcceptanceLimit",
                    new PropertyModel<String>(historicDataMeasurement, "lowerAcceptanceLimit")));

            item.add(new Label("upperAcceptanceLimit",
                    new PropertyModel<String>(historicDataMeasurement, "upperAcceptanceLimit")));

            item.add(new Label("weight", new PropertyModel<String>(historicDataMeasurement, "weight")));

            item.add(new Label("timeStamp", new PropertyModel<Date>(historicDataMeasurement, "date")));

        }
    };
    dataContainer.add(dataMeasurements);

    // Add graphical representation of the values
    dataContainer.add(historicChart = historicChart());

    // add links for table pagination
    dataContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", dataMeasurements));
    dataContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", dataMeasurements));

    // add button to delete selected items
    dataContainer.add(deleteSelectedButton = newDeleteSelectedButton(dataGroup));

    // add confirmation modal for deleting products
    add(deleteConfirmationModal = newDeleteConfirmationModal());
}

From source file:eu.uqasar.web.pages.tree.historic.project.HistoricProjectPage.java

License:Apache License

/**
 * Constructor building the page/*from  w  w w.j  a v a  2  s  .c o  m*/
 *
 * @param parameters
 */
public HistoricProjectPage(final PageParameters parameters) {

    super(parameters);

    // TODO: I dont know why this does not work???
    //      String key = getPageParameters().get("project-key").toOptionalString();
    project = treeNodeService.getTreeNodeByKey("U-QASAR");
    projectId = project.getId();

    add(new Label("metricName", project.getName()));

    final Form<AbstractHistoricValues> deleteForm = new Form<>("deleteForm");
    add(deleteForm);

    // add checkgroup for selecting multiple measurements
    deleteForm.add(dataGroup = newDataCheckGroup());

    // add the container holding list of existing measurements
    dataGroup.add(dataContainer.setOutputMarkupId(true));

    dataContainer.add(new CheckGroupSelector("dataGroupSelector", dataGroup));

    DataView<AbstractHistoricValues> dataMeasurements = new DataView<AbstractHistoricValues>("dataMeasurements",
            new DataProvider(), itemsPerPage) {

        private static final long serialVersionUID = 7687248000895943825L;

        @Override
        protected void populateItem(final Item<AbstractHistoricValues> item) {
            final AbstractHistoricValues historicDataMeasurement = item.getModelObject();

            item.add(new Check<>("dataCheck", item.getModel(), dataGroup));

            item.add(new Label("value", new PropertyModel<String>(historicDataMeasurement, "value")));

            item.add(new Label("lowerAcceptanceLimit",
                    new PropertyModel<String>(historicDataMeasurement, "lowerAcceptanceLimit")));

            item.add(new Label("upperAcceptanceLimit",
                    new PropertyModel<String>(historicDataMeasurement, "upperAcceptanceLimit")));

            item.add(new Label("timeStamp", new PropertyModel<Date>(historicDataMeasurement, "date")));

        }
    };
    dataContainer.add(dataMeasurements);

    // Add graphical representation of the values
    dataContainer.add(historicChart = historicChart());

    // add links for table pagination
    dataContainer.add(new BootstrapAjaxPagingNavigator("navigatorHead", dataMeasurements));
    dataContainer.add(new BootstrapAjaxPagingNavigator("navigatorFoot", dataMeasurements));

    // add button to delete selected items
    dataContainer.add(deleteSelectedButton = newDeleteSelectedButton(dataGroup));

    // add confirmation modal for deleting products
    add(deleteConfirmationModal = newDeleteConfirmationModal());

}

From source file:org.brixcms.rmiserver.web.admin.UsersPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 *
 * @param parameters Page parameters// ww  w .j a  v  a  2 s .c  o  m
 */
public UsersPage(final PageParameters parameters) {
    DataView<User> list = null;
    add(list = new DataView<User>("list", new UsersDataProvider(), 20) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<User> item) {
            item.add(new Label("login", new PropertyModel<String>(item.getModel(), "login")));
            item.add(new Label("roles", new UserRolesModel(item.getModel())));

            final User user = item.getModelObject();
            if (user.isLocked()) {
                item.add(new LockedFragment("actions", item.getModel()));
            } else {
                item.add(new ActionsFragment("actions", item.getModel()));
            }
        }
    });
    add(new PagingNavigator("pager", list));

    add(new WebMarkupContainer("editor"));

    add(new Link<Void>("create") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            onCreateUser();
        }
    });
}

From source file:org.cipango.ims.hss.web.gba.NafGroupBrowserPage.java

License:Apache License

@SuppressWarnings("unchecked")
public NafGroupBrowserPage(PageParameters pageParameters) {

    IDataProvider<NafGroup> provider = new AbstractListDataProvider<NafGroup>() {

        @Override//w  w w  . jav  a  2 s .co  m
        public List<NafGroup> load() {
            return _dao.getAllGroups();
        }

        public IModel<NafGroup> model(NafGroup nafGroup) {
            return new CompoundPropertyModel<NafGroup>(new DaoDetachableModel(nafGroup)) {
                @Override
                protected String propertyExpression(Component component) {
                    if (component.getParent() instanceof EditableLabel)
                        return component.getParent().getId();
                    return component.getId();
                }
            };
        }

    };

    WebMarkupContainer container = new WebMarkupContainer("browser");
    container.setOutputMarkupId(true);
    add(container);

    container.add(new DataView<NafGroup>("nafGroup", provider, getItemByPage()) {

        @Override
        protected void populateItem(final Item<NafGroup> item) {
            NafGroup nafGroup = item.getModelObject();
            Form form = new Form("form", item.getModel());
            item.add(form);
            form.add(new EditableLabel("name"));
            form.add(new AjaxFallbackButton("apply", form) {

                @Override
                protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception {
                    NafGroup nafGroup = (NafGroup) form.getDefaultModelObject();
                    _dao.save(nafGroup);
                    EditableLabel name = (EditableLabel) form.get("name");
                    name.setEditable(false);
                    setVisible(false);
                    if (target != null)
                        target.addComponent(item);

                }

            }.setVisible(false));

            item.add(new Label("nbUss", String.valueOf(nafGroup.getUssSet().size())));
            item.add(new AjaxFallbackLink("editLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    EditableLabel name = (EditableLabel) item.get("form:name");
                    item.get("form:apply").setVisible(true);
                    name.setEditable(true);
                    if (target != null)
                        target.addComponent(item);
                }

            });

            item.add(new AjaxFallbackLink("deleteLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    NafGroup nafGroup = (NafGroup) getParent().getDefaultModelObject();
                    _dao.delete(nafGroup);
                    if (target != null)
                        target.addComponent(getPage().get("browser"));
                }

            });
            item.setOutputMarkupId(true);
            item.add(new OddEvenAttrModifier(item.getIndex()));
        }

    });

    Form form = new Form("form", new CompoundPropertyModel(new DaoDetachableModel(null)));
    add(form);
    form.add(new RequiredTextField("name", String.class));
    form.add(new AjaxFallbackButton("submit", form) {

        @Override
        protected void doSubmit(AjaxRequestTarget target, Form<?> form) throws Exception {
            try {
                _dao.save((NafGroup) form.getDefaultModelObject());
                if (target != null) {
                    target.addComponent(getPage().get("browser"));
                }
            } catch (Exception e) {
                __log.debug("Failed to apply edit", e);
                getSession().error(getString("nafGroup.error.duplicate", getForm().getModel()));
            }
        }

    });
    setContextMenu(new ServicesContextPanel());
}

From source file:org.cipango.ims.hss.web.gba.UssBrowserPage.java

License:Apache License

@SuppressWarnings("unchecked")
public UssBrowserPage(PageParameters pageParameters) {
    super(pageParameters);
    _privateIdKey = pageParameters.getString("privateId");

    add(new BookmarkablePageLink("createLink", EditUssPage.class,
            new PageParameters("privateId=" + _privateIdKey)));
    final PrivateIdentity privateIdentity = _privateIdentityDao.findById(_privateIdKey);

    if (privateIdentity == null) {
        error(MapVariableInterpolator.interpolate(getString("privateIdentity.error.notFound"),
                new MicroMap("identity", _privateIdKey)));
        setResponsePage(getApplication().getHomePage());
        return;/*  w  w  w. j a  va2  s .  c  o m*/
    }

    IDataProvider provider = new AbstractListDataProvider<Uss>() {

        @Override
        public List<Uss> load() {
            return new ArrayList<Uss>(_privateIdentityDao.findById(_privateIdKey).getUssSet());
        }

        public IModel<Uss> model(Uss uss) {
            return new CompoundPropertyModel<Uss>(new DaoDetachableModel(uss));
        }

    };

    WebMarkupContainer browser = new WebMarkupContainer("browser");

    browser.setOutputMarkupId(true);
    add(browser);
    browser.add(new DataView("uss", provider, getItemByPage()) {

        @Override
        protected void populateItem(Item item) {
            Uss uss = (Uss) item.getModelObject();
            Link link = new BookmarkablePageLink("editLink", EditUssPage.class,
                    new PageParameters("id=" + uss.getId()));
            item.add(link);
            link.add(new Label("id", String.valueOf(uss.getId())));
            item.add(new Label("type", uss.getTypeAsString()));
            item.add(new Label("nafGroup"));
            item.add(new Label("flagAsString"));
            item.add(new BookmarkablePageLink("edit2Link", EditUssPage.class,
                    new PageParameters("id=" + uss.getId())));
            item.add(new AjaxFallbackLink("deleteLink") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    Uss uss = (Uss) getParent().getDefaultModelObject();
                    _dao.delete(uss);
                    if (target != null) {
                        target.addComponent(getPage().get("browser"));
                        target.addComponent(getPage().get("guss"));
                    }
                }

            });
            item.add(new OddEvenAttrModifier(item.getIndex()));
        }

    });

    setContextMenu(new ContextPanel(privateIdentity));
    _title = MapVariableInterpolator.interpolate(getString("privateId.gba.title"),
            new MicroMap("identity", _privateIdKey));

    add(new Label("title", _title));

    add(new Label("guss", new LoadableDetachableModel() {

        @Override
        protected Object load() {
            return _privateIdentityDao.findById(_privateIdKey).getGuss(_zhHandler.getKeyLifetime(),
                    XML.getPretty().newOutput());
        }
    }).setOutputMarkupId(true));
}

From source file:org.onehippo.forge.exdocpicker.impl.field.ExternalDocumentFieldBrowserDialog.java

License:Apache License

/**
 * {@inheritDoc}/*from w w w .  j a v  a2  s.co m*/
 */
@Override
protected void initializeDataListView() {
    final IDataProvider<Serializable> provider = new SimpleExternalDocumentCollectionDataProvider<Serializable>(
            getSearchedExternalDocuments());

    final DataView<Serializable> resultsDataView = new DataView<Serializable>("item", provider, getPageSize()) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Serializable> listItem) {
            final ExternalDocumentServiceFacade<Serializable> exdocService = getExternalDocumentServiceFacade();
            final ExternalDocumentServiceContext exdocContext = getExternalDocumentServiceContext();

            final Serializable doc = listItem.getModelObject();
            listItem.setOutputMarkupId(true);

            AjaxCheckBox selectCheckbox = new AjaxCheckBox("select-button", new Model<Boolean>()) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    if (getModelObject()) {
                        final boolean singleSelectionMode = isSingleSelectionMode();
                        if (singleSelectionMode) {
                            getPickedExternalDocuments().clear();
                        }
                        getPickedExternalDocuments().add(doc);
                        if (singleSelectionMode) {
                            target.add(ExternalDocumentFieldBrowserDialog.this);
                        }
                    } else {
                        getPickedExternalDocuments().remove(doc);
                    }
                }
            };

            selectCheckbox.getModel().setObject(getPickedExternalDocuments().contains(doc));
            selectCheckbox.setEnabled(exdocService.isDocumentSelectable(exdocContext, doc));

            final String iconLink = exdocService.getDocumentIconLink(exdocContext, doc,
                    getRequest().getLocale());
            final String iconStyle = exdocContext.getPluginConfig().getString(PluginConstants.PARAM_ICON_STYLE,
                    null);

            final ExternalDocumentIconImage iconImage = new ExternalDocumentIconImage("image", iconLink);

            if (StringUtils.isNotBlank(iconStyle)) {
                iconImage.add(new AttributeModifier("style", iconStyle));
            }

            listItem.add(iconImage);
            listItem.add(selectCheckbox);
            listItem.add(new Label("title-label",
                    exdocService.getDocumentTitle(exdocContext, doc, getRequest().getLocale())));
            final String description = exdocService.getDocumentDescription(exdocContext, doc,
                    getRequest().getLocale());

            WebMarkupContainer frame = new WebMarkupContainer("paragraph-label") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
                    replaceComponentTagBody(markupStream, openTag, StringUtils.defaultString(description));
                }
            };

            listItem.add(frame);

            listItem.add(new AttributeAppender("class", new AbstractReadOnlyModel() {
                private static final long serialVersionUID = 1L;

                public Object getObject() {
                    return ((listItem.getIndex() & 1) == 1) ? "even" : "odd";
                }
            }, " "));
        }
    };

    resultsDataView.setOutputMarkupId(true);

    add(resultsDataView);
    add(new ExternalDocumentFieldBrowserPageNavigator("navigator", resultsDataView));
}

From source file:org.xaloon.wicket.component.comment.CurrentCommentListPanel.java

License:Apache License

public void load() {
    commentContainer.removeAll();/*from  w w w  .ja  v  a 2 s .  c  o m*/
    if (!providerAll) {
        // usual case with pages
        DataView<AbstractComment> dv = new DataView<AbstractComment>("rowContainer", provider, itemsPerPage) {

            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            protected void populateItem(Item<AbstractComment> item) {
                updateItem(item, item.getModelObject());
            }

        };
        commentContainer.add(dv);
        commentContainer.add(new AjaxPagingNavigator("navigator", dv));
    } else {
        // google app engine - special case - issues with DataView, ListView
        RepeatingView repeating = new RepeatingView("rowContainer");
        repeating.setOutputMarkupId(true);
        Iterator<? extends AbstractComment> result = provider.iterator(0, -1);
        while (result.hasNext()) {
            AbstractComment comment = result.next();
            WebMarkupContainer wmc = new WebMarkupContainer(repeating.newChildId());

            repeating.add(wmc);
            updateItem(wmc, comment);
        }
        commentContainer.add(repeating);
        commentContainer.add(new WebMarkupContainer("navigator").setVisible(false));
    }
}