Exemple de Wicket textarea

Exemple de zone de texte de guichet

Tutoriel Wicket pour vous montrer comment créer une zone de texte, un composant d'édition de texte à plusieurs lignes, couramment utilisé pour le champ d'adresse.

//Java
import org.apache.wicket.markup.html.form.TextArea;
...
final TextArea address = new TextArea("address",Model.of(""));
form.add(address);

//HTML

1. Exemple de zone de texte de guichet

Code pour rendre un champ de zone de texte pour l'adresse.

Fichier: UserPage.java

package com.example.user;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;

public class UserPage extends WebPage {

    public UserPage(final PageParameters parameters) {

        add(new FeedbackPanel("feedback"));

        //create a textarea field for address
        final TextArea address = new TextArea("address",Model.of(""));
        address.setRequired(true);

        address.setLabel(Model.of("Address"));

        Form form = new Form("userForm") {
            @Override
            protected void onSubmit() {

                PageParameters pageParameters = new PageParameters();
                pageParameters.add("address", address.getModelObject());
                setResponsePage(SuccessPage.class, pageParameters);

            }
        };

        add(form);
        form.add(address);

    }
}

2. Page HTML du guichet

Page pour rendre le champ de zone de texte.

Fichier: UserPage.html






    

Wicket TextArea Example

3. Demo

wicket textarea address field

Téléchargez-le -Wicket-textarea-example.zip (8 Ko)