Exemple de liste de portillon
Dans Wicket, vous pouvez utiliserListChoice
pour créer unsingle 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. Exemple de liste de sélection à guichet unique
Exemple pour afficher une seule liste déroulante de sélection via «ListChoice», et par défaut une valeur sélectionnée.
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. Page HTML du guichet
Page pour rendre la liste déroulante à sélection unique.
Wicket ListChoice example
3. Demo
Démarrer et visiter -http://localhost:8080/WicketExamples/
«Banane» est sélectionné automatiquement.
Sélectionnez "Banane" et cliquez sur le bouton d'affichage.
Téléchargez-le -Wicket-ListChoice-Examples.zip (7 Ko)