Wicketテキストエリアの例
住所フィールドに一般的に使用される、テキストエリア、複数行テキスト編集コンポーネントの作成方法を示すWicketチュートリアル。
//Java import org.apache.wicket.markup.html.form.TextArea; ... final TextAreaaddress = new TextArea ("address",Model.of("")); form.add(address); //HTML
1. Wicketテキストエリアの例
アドレスのtextareaフィールドをレンダリングするコード。
ファイル: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. Wicket HTMLページ
textareaフィールドをレンダリングするページ。
ファイル:UserPage.html
Wicket TextArea Example
