Wicket Remove

wicket.markup.html.form.Form

[back to the reference]

A Form is a component that has special interaction with nested form components. Form components are components that extend from wicket.markup.html.form.FormComponent, and which are called controls in the HTML specification. Examples of such controls are textfields, checkboxes and radio buttons. Users generally "complete" a form by modifying its controls (entering text, selecting menu items, etc.), before submitting the form usually by clicking on a submit button. On a form submit, the form normally goes through a processing cycle of validation, model updating of the nested controls, possibly persisting (with cookies) the model values of the controls and calling the form's onSubmit method.

This example shows you the basic Form itself. It has no nested controls, but it does have an implementation of onSubmit, which sets a feedback message, and it works together with a feeback panel (a panel that lists any feedback messages that were set).


Behind the Scenes

Example HTML

<form wicket:id="form">
<input type="submit" value="click me to submit the form and display a message" />
</form>
<span wicket:id="feedback">feedbackmessages will be put here</span>

Example Code

    public FormPage() {
        // Add a FeedbackPanel for displaying our messages
        FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
        add(feedbackPanel);

        // Add a form with an onSubmit implementation that sets a message
        add(new Form("form") {
            protected void onSubmit() {
                info("the form was submitted!");
            }
        });
    }

Further examples & and comments/explanations may be available in the source code.