This is an automated email from the ASF dual-hosted git repository. dashorst pushed a commit to branch archive/wicket-1.1.x in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 2927504195d3464a7238f185a5735823825a5edb Author: Igor Vaynberg <[email protected]> AuthorDate: Tue Nov 1 20:04:23 2005 +0000 added CheckBoxMultipleChoice example to component reference git-svn-id: https://svn.apache.org/repos/asf/incubator/wicket/branches/WICKET_1_1@457987 13f79535-47bb-0310-9956-ffa450edef68 --- .../compref/CheckBoxMultipleChoicePage.html | 46 +++++++ .../compref/CheckBoxMultipleChoicePage.java | 132 +++++++++++++++++++++ .../src/java/wicket/examples/compref/Index.html | 1 + 3 files changed, 179 insertions(+) diff --git a/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.html b/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.html new file mode 100644 index 0000000000..b0a753313b --- /dev/null +++ b/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.html @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<html xmlns="http://www.w3.org/1999/xhtml" > +<head> + <title>Wicket Examples - component reference</title> + <link rel="stylesheet" type="text/css" href="style.css"/> +</head> +<body> + <span wicket:id="mainNavigation"/> + + <h1>wicket.markup.html.form.ListMultipleChoice</h1> + <wicket:link><a href="Index.html">[back to the reference]</a></wicket:link> + + <p> + A ListChoice component lets users select a multiple values from a scrollable list. + </p> + <p> + <form wicket:id="form"> + + <table style="border: 2px dotted #fc0; width: 400px; padding: 5px;"> + <tr> + <td valign="top">Select your favorite sites</td> + <td> + <span wicket:id="sites"> + </span> + </td> + </tr> + <tr> + <td valign="top">Select some of these excellent choices</td> + <td> + <span wicket:id="choices"> + </span> + </td> + </tr> + <tr> + <td colspan="2" align="center"> + <input type="submit" value="submit" /> + </td> + </tr> + </table> + + </form> + <span wicket:id="feedback">feedbackmessages will be put here</span> + </p> + <span wicket:id="explainPanel">panel contents come here</span> +</body> +</html> diff --git a/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.java b/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.java new file mode 100644 index 0000000000..07561e35fc --- /dev/null +++ b/wicket-examples/src/java/wicket/examples/compref/CheckBoxMultipleChoicePage.java @@ -0,0 +1,132 @@ +/* + * $Id$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package wicket.examples.compref; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import wicket.examples.WicketExamplePage; +import wicket.markup.html.form.CheckBoxMultipleChoice; +import wicket.markup.html.form.Form; +import wicket.markup.html.panel.FeedbackPanel; +import wicket.model.CompoundPropertyModel; + +/** + * Page with examples on {@link wicket.markup.html.form.CheckBoxMultipleChoice}. + * + * @author Igor Vaynberg (ivaynberg) + */ +public class CheckBoxMultipleChoicePage extends WicketExamplePage +{ + /** available sites for selection. */ + private static final List SITES = Arrays.asList(new String[] { "The Server Side", "Java Lobby", + "Java.Net" }); + + /** available choices for large selection box. */ + private static final List MANY_CHOICES = Arrays.asList(new String[] { "Choice1", "Choice2", + "Choice3", "Choice4", "Choice5", "Choice6", "Choice7", "Choice8", "Choice9", }); + + /** + * Constructor + */ + public CheckBoxMultipleChoicePage() + { + final Input input = new Input(); + setModel(new CompoundPropertyModel(input)); + + // Add a FeedbackPanel for displaying our messages + FeedbackPanel feedbackPanel = new FeedbackPanel("feedback"); + add(feedbackPanel); + + // Add a form with an onSubmit implementation that sets a message + Form form = new Form("form") + { + protected void onSubmit() + { + info("input: " + input); + } + }; + add(form); + + // add a couple of checkbox multiple choice components, notice the model + // used is a compound model set on the page + CheckBoxMultipleChoice listChoice = new CheckBoxMultipleChoice("sites", SITES); + form.add(listChoice); + + listChoice = new CheckBoxMultipleChoice("choices", MANY_CHOICES); + form.add(listChoice); + } + + /** Simple data class that acts as a model for the input fields. */ + private static class Input implements Serializable + { + /** the selected sites. */ + public List sites = new ArrayList(); + + /** the selected choices. */ + public List choices = new ArrayList(); + + /** adds pre-selected items to the choices list */ + public Input() + { + choices.add("Choice3"); + choices.add("Choice4"); + choices.add("Choice5"); + } + + /** + * @see java.lang.Object#toString() + */ + public String toString() + { + return "sites = '" + listAsString(sites) + "', choices='" + listAsString(choices) + "'"; + } + + private String listAsString(List list) + { + StringBuffer b = new StringBuffer(); + for (Iterator i = list.iterator(); i.hasNext();) + { + b.append(i.next()); + if (i.hasNext()) + b.append(", "); + } + return b.toString(); + } + } + + /** + * Override base method to provide an explanation + */ + protected void explain() + { + String html = "<span wicket:id=\"sites\">\n" + "</span>\n" + + "<span wicket:id=\"choices\">\n" + "</span>"; + String code = " CheckBoxMultipleChoice siteChoice = new CheckBoxMultipleChoice(\"sites\", SITES);\n" + + " form.add(siteChoice);\n" + + "\n" + + " ListMultipleChoice manyChoice = new CheckBoxMultipleChoice(\"choices\", MANY_CHOICES);\n" + + " form.add(manyChoice);"; + add(new ExplainPanel(html, code)); + + } +} \ No newline at end of file diff --git a/wicket-examples/src/java/wicket/examples/compref/Index.html b/wicket-examples/src/java/wicket/examples/compref/Index.html index 317919d160..0c0463b6ee 100644 --- a/wicket-examples/src/java/wicket/examples/compref/Index.html +++ b/wicket-examples/src/java/wicket/examples/compref/Index.html @@ -61,6 +61,7 @@ <li><a href="TextAreaPage.html">wicket.markup.html.form.TextArea</a></li> <li><a href="CheckBoxPage.html">wicket.markup.html.form.CheckBox</a></li> <li><a href="CheckGroupPage.html">wicket.markup.html.form.CheckGroup, wicket.markup.html.form.Check, and wicket.markup.html.form.CheckGroupSelector</a></li> + <li><a href="CheckBoxMultipleChoicePage.html">wicket.markup.html.form.CheckBoxMultipleChoice</a></li> <li><a href="DropDownChoicePage.html">wicket.markup.html.form.DropDownChoice</a></li> <li><a href="ListChoicePage.html">wicket.markup.html.form.ListChoice</a></li> <li><a href="RadioChoicePage.html">wicket.markup.html.form.RadioChoice</a></li>
