Example usage for org.apache.wicket.markup.html.form IFormSubmitter getForm

List of usage examples for org.apache.wicket.markup.html.form IFormSubmitter getForm

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form IFormSubmitter getForm.

Prototype

Form<?> getForm();

Source Link

Document

Returns the form this component submits.

Usage

From source file:com.userweave.components.valueListPanel.ValueListPanel.java

License:Open Source License

private void init(ValueListController<T> cb) {
    this.controller = cb;

    final RepeatingView rows = new RepeatingView("repeater");
    add(rows);//from ww w .  j a  v  a  2 s.  c  o  m

    int index = 0;

    List<T> values = controller.getValues();

    if (values != null) {
        for (T value : values) {
            addListRow(rows, value);
            index++;
        }
    }
    add(new Form("form") {

        {
            add(getInputComponent("input"));
            add(new Button("submit"));
        }

        @Override
        protected void onSubmit() {
            List<T> input = getInput();

            for (T t : input) {
                controller.addValue(t);
                addListRow(rows, t);
            }
            clearInputComponent();
        }

        @Override
        // don't submit/validate this form if root form is submitted  
        public boolean isEnabled() {
            Form rootForm = getRootForm();
            if (rootForm != null) {
                IFormSubmitter submittingButton = rootForm.findSubmittingButton();
                if (submittingButton != null) {
                    return submittingButton.getForm() == this;
                }
            }
            ;
            return true;
        }
    });
}