Search in sources :

Example 1 with BootstrapAddButton

use of org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton in project ocvn by devgateway.

the class ListViewSectionPanel method getAddNewChildButton.

/**
 * Returns the new child button
 *
 * @return
 */
protected BootstrapAddButton getAddNewChildButton() {
    BootstrapAddButton newButton = new BootstrapAddButton("newButton", new ResourceModel("newButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            @SuppressWarnings("unchecked") T newChild = createNewChild((IModel<PARENT>) ListViewSectionPanel.this.getParent().getDefaultModel());
            ListViewSectionPanel.this.getModel().getObject().add(newChild);
            listView.removeAll();
            target.add(listWrapper);
        }
    };
    newButton.setOutputMarkupPlaceholderTag(true);
    return newButton;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BootstrapAddButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton) Form(org.apache.wicket.markup.html.form.Form) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 2 with BootstrapAddButton

use of org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton in project ocvn by devgateway.

the class ListViewSectionPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    listWrapper = new TransparentWebMarkupContainer("listWrapper");
    listWrapper.setOutputMarkupId(true);
    add(listWrapper);
    listWrapper.add(new Label("panelTitle", title));
    listView = new ListView<T>("list", getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<T> item) {
            // we wrap the item model on a compound model so we can use the field ids as property models
            final CompoundPropertyModel<T> compoundPropertyModel = new CompoundPropertyModel<>(item.getModel());
            // we set back the model as the compound model, thus ensures the rest of the items added will benefit
            item.setModel(compoundPropertyModel);
            // we add the rest of the items in the listItem
            populateCompoundListItem(item);
            // we add the remove button
            final BootstrapDeleteButton removeButton = getRemoveChildButton(item.getIndex());
            item.add(removeButton);
        }
    };
    listView.setReuseItems(true);
    listView.setOutputMarkupId(true);
    listWrapper.add(listView);
    final BootstrapAddButton addButton = getAddNewChildButton();
    add(addButton);
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) BootstrapDeleteButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton) BootstrapAddButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) Label(org.apache.wicket.markup.html.basic.Label)

Example 3 with BootstrapAddButton

use of org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton in project oc-explorer by devgateway.

the class ListViewSectionPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    listWrapper = new TransparentWebMarkupContainer("listWrapper");
    listWrapper.setOutputMarkupId(true);
    add(listWrapper);
    listWrapper.add(new Label("panelTitle", title));
    listView = new ListView<T>("list", getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<T> item) {
            // we wrap the item model on a compound model so we can use the field ids as property models
            final CompoundPropertyModel<T> compoundPropertyModel = new CompoundPropertyModel<>(item.getModel());
            // we set back the model as the compound model, thus ensures the rest of the items added will benefit
            item.setModel(compoundPropertyModel);
            // we add the rest of the items in the listItem
            populateCompoundListItem(item);
            // we add the remove button
            final BootstrapDeleteButton removeButton = getRemoveChildButton(item.getIndex());
            item.add(removeButton);
        }
    };
    listView.setReuseItems(true);
    listView.setOutputMarkupId(true);
    listWrapper.add(listView);
    final BootstrapAddButton addButton = getAddNewChildButton();
    add(addButton);
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) BootstrapDeleteButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton) BootstrapAddButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) Label(org.apache.wicket.markup.html.basic.Label)

Example 4 with BootstrapAddButton

use of org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton in project oc-explorer by devgateway.

the class ListViewSectionPanel method getAddNewChildButton.

/**
 * Returns the new child button
 *
 * @return
 */
protected BootstrapAddButton getAddNewChildButton() {
    BootstrapAddButton newButton = new BootstrapAddButton("newButton", new ResourceModel("newButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            @SuppressWarnings("unchecked") T newChild = createNewChild((IModel<PARENT>) ListViewSectionPanel.this.getParent().getDefaultModel());
            ListViewSectionPanel.this.getModel().getObject().add(newChild);
            listView.removeAll();
            target.add(listWrapper);
        }
    };
    newButton.setOutputMarkupPlaceholderTag(true);
    return newButton;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BootstrapAddButton(org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton) Form(org.apache.wicket.markup.html.form.Form) ResourceModel(org.apache.wicket.model.ResourceModel)

Aggregations

BootstrapAddButton (org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 TransparentWebMarkupContainer (org.apache.wicket.markup.html.TransparentWebMarkupContainer)2 Label (org.apache.wicket.markup.html.basic.Label)2 Form (org.apache.wicket.markup.html.form.Form)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 ResourceModel (org.apache.wicket.model.ResourceModel)2 BootstrapDeleteButton (org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton)2