Wicketでは、 `ListChoice`を使って

単一の選択可能なスクロール可能リストボックス

を作成することができます。

…​.//Java
import org.apache.wicket.markup.html.form.ListChoice;
…​

ListChoice <String> listFruits =新しいListChoice <String>( “fruit”、 ”
        新しいPropertyModel <String>(これ、 “selectedFruit”)、FRUITS);
                //単一選択リストボックスのHTML
<select wicket:id = “fruit”> </select>

=== 1. Wicket単一選択リストボックスの例

1つの選択可能なスクロール可能なリストボックスを経由して表示する例
"**  ListChoice ** "を選択し、デフォルト値を選択します。

パッケージcom.mkyong.user;

import java.util.Arrays; import java.util.List;インポート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;インポートorg.apache.wicket.model.PropertyModel;

パブリッククラスListChoicePageはWebPage {

public ListChoicePage(最後のPageParametersパラメータ){

add(新しいFeedbackPanel( “feedback”));

ListChoice <String> listFruits = new ListChoice <String>( “fruit”、新しいPropertyModel <String>(これ、 “selectedFruit”)、FRUITS);

listFruits.setMaxRows(5);

フォーム<?>フォーム=新しいフォーム<Void>( “フォーム”){@Override protected void onSubmit(){

info( “選択されたフルーツ:” selectedFruit);

}};

追加(フォーム); form.add(listFruits);

}
}

=== 2. Wicket HTMLページ

単一の選択可能なスクロール可能リストをレンダリングするページ。

<html> <head> <style> .feedbackPanelINFO {color:green; } </style> </head> <body> <h1> Wicket ListChoiceの例</h1>

</wiki:id = “form”> <p> <label>[ListChoice]あなたの好きな果物の “ONE”を選択してください:</label> <br/> <select wicket:id = “fruit”> </select> </type> <input type = “submit” value = “Display”/> </form>

</body>
</html>

===デモ

開始と訪問 -  __http://localhost:8080/WicketExamples/__

「バナナ」が自動的に選択されます。

image://wp-content/uploads/2011/05/wicket-listchoice-example1.png[wicket
リストボックス、タイトル= "wicket-listchoice-example1"、幅= 495、高さ= 340]
「バナナ」を選択し、表示ボタンをクリックします。

image://wp-content/uploads/2011/05/wicket-listchoice-example2.png[wicket
listbox、title = "wicket-listchoice-example2"、width = 504、height = 376]
それをダウンロードする -
リンク://wp-content/uploads/2011/05/Wicket-ListChoice-Examples.zip[Wicket-ListChoice-Examples.zip](7KB)

===参考文献

。 http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/form/ListChoice.html[Wicket
ListChoice Javadoc]
link://tag/listbox/[listbox]link://タグ/wicket/[wicket]