Exemple de boutons radio de portillon - RadioChoice
Exemple de portillon pour créer un groupe de boutons radio, et par défaut coché un seul bouton radio.
//Java import org.apache.wicket.markup.html.form.RadioChoice; ... //choices in radio button private static final ListTYPES = Arrays .asList(new String[] { "Shared Host", "VPS", "Dedicated Server" }); //variable to hold the selected radio button value, and default "VPS" is selected private String selected = "VPS"; RadioChoice hostingType = new RadioChoice ( "hosting", new PropertyModel (this, "selected"), TYPES); //HTML for radio button
1. Exemple de bouton radio de portillon
Exemple pour afficher un groupe de boutons radio via «RadioChoice», et cocher par défaut un seul bouton radio.
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.RadioChoice; import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.model.PropertyModel; public class RadioChoicePage extends WebPage { //choices in radio button private static final ListTYPES = Arrays .asList(new String[] { "Shared Host", "VPS", "Dedicated Server" }); //variable to hold radio button values private String selected = "VPS"; public RadioChoicePage(final PageParameters parameters) { add(new FeedbackPanel("feedback")); RadioChoice hostingType = new RadioChoice ( "hosting", new PropertyModel (this, "selected"), TYPES); Form> form = new Form ("form") { @Override protected void onSubmit() { info("Selected Type : " + selected); } }; add(form); form.add(hostingType); } }
2. Page HTML du guichet
Page pour rendre un groupe de boutons radio.
Wicket RadioChoice Example
3. Demo
Démarrer et visiter -http://localhost:8080/WicketExamples/
«VPS» est sélectionné automatiquement.
Maintenant, sélectionnez l'option «Serveur dédié» et cliquez sur le bouton d'affichage.
Téléchargez-le -Wicket-RadioChoice-Examples.zip (7 Ko)