Wicket ListChoiceの例
Wicketでは、ListChoice
を使用してsingle select scrollable listboxを作成できます。
//Java import org.apache.wicket.markup.html.form.ListChoice; ... //choices in list box private static final ListFRUITS = Arrays.asList(new String[] { "Apple", "Orang", "Banana" }); //variable to hold the selected list box value private String selectedFruit = "Banana"; ListChoice listFruits = new ListChoice ("fruit", new PropertyModel (this, "selectedFruit"), FRUITS); //HTML for single select listbox
1. Wicketシングルセレクトリストボックスの例
「ListChoice」を介して単一の選択されたスクロール可能なリストボックスを表示し、デフォルトで選択された値を表示する例。
package com.example.user; import java.util.Arrays; import java.util.List; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.ListChoice; import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.model.PropertyModel; public class ListChoicePage extends WebPage { // single list choice private static final ListFRUITS = Arrays.asList(new String[] { "Apple", "Orang", "Banana" }); // Banana is selected by default private String selectedFruit = "Banana"; public ListChoicePage(final PageParameters parameters) { add(new FeedbackPanel("feedback")); ListChoice listFruits = new ListChoice ("fruit", new PropertyModel (this, "selectedFruit"), FRUITS); listFruits.setMaxRows(5); Form> form = new Form ("form") { @Override protected void onSubmit() { info("Selected Fruit : " + selectedFruit); } }; add(form); form.add(listFruits); } }
2. Wicket HTMLページ
単一選択のスクロール可能なリストをレンダリングするページ。
Wicket ListChoice example