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 a1c8214cb15d1c7aebdef1aeb13f61e6e774dd56 Author: Igor Vaynberg <[email protected]> AuthorDate: Wed Nov 23 08:13:46 2005 +0000 first pass on additional <select> components component reference git-svn-id: https://svn.apache.org/repos/asf/incubator/wicket/branches/WICKET_1_1@458078 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/wicket/examples/compref/Index.html | 1 + .../java/wicket/examples/compref/SelectPage.html | 56 +++++++ .../java/wicket/examples/compref/SelectPage.java | 169 +++++++++++++++++++++ 3 files changed, 226 insertions(+) diff --git a/wicket-examples/src/java/wicket/examples/compref/Index.html b/wicket-examples/src/java/wicket/examples/compref/Index.html index 0c0463b6ee..0cee25cd91 100644 --- a/wicket-examples/src/java/wicket/examples/compref/Index.html +++ b/wicket-examples/src/java/wicket/examples/compref/Index.html @@ -67,6 +67,7 @@ <li><a href="RadioChoicePage.html">wicket.markup.html.form.RadioChoice</a></li> <li><a href="RadioGroupPage.html">wicket.markup.html.form.RadioGroup and wicket.markup.html.form.Radio</a></li> <li><a href="ListMultipleChoicePage.html">wicket.markup.html.form.ListMultipleChoice</a></li> + <li><a href="SelectPage.html">wicket.extensions.markup.html.form.select.Select</a></li> <li>for more examples, see <a href="./forminput">FormInput</a></li> </ul> </wicket:link> diff --git a/wicket-examples/src/java/wicket/examples/compref/SelectPage.html b/wicket-examples/src/java/wicket/examples/compref/SelectPage.html new file mode 100644 index 0000000000..c9536080c0 --- /dev/null +++ b/wicket-examples/src/java/wicket/examples/compref/SelectPage.html @@ -0,0 +1,56 @@ +<?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> + <select wicket:id="site"> + <optgroup label="java sites"> + <option wicket:id="site1" style="color:green;">The Server Side (tss)</option> + <option wicket:id="site2" style="color:red;">JavaLobby (jl)</option> + </optgroup> + <optgroup label="news sites"> + <option wicket:id="site3">Slashdot.org (sd)</option> + <option wicket:id="site4">BetaNews.com (bn)</option> + </optgroup> + </select> + </td> + </tr> + <tr> + <td valign="top">Select some of these excellent choices</td> + <td> + <select wicket:id="choices" multiple size="5"> + <!-- the only trick here is that the wicket id of the option tag is fixed to "option" --> + <span wicket:id="manychoices"><option wicket:id="option"></option></span> + </select> + </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/SelectPage.java b/wicket-examples/src/java/wicket/examples/compref/SelectPage.java new file mode 100644 index 0000000000..14f8407c69 --- /dev/null +++ b/wicket-examples/src/java/wicket/examples/compref/SelectPage.java @@ -0,0 +1,169 @@ +/* + * $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.extensions.markup.html.form.select.IOptionRenderer; +import wicket.extensions.markup.html.form.select.Select; +import wicket.extensions.markup.html.form.select.SelectOption; +import wicket.extensions.markup.html.form.select.SelectOptions; +import wicket.markup.html.form.Form; +import wicket.markup.html.panel.FeedbackPanel; +import wicket.model.CompoundPropertyModel; +import wicket.model.IModel; +import wicket.model.Model; + +/** + * Page with examples on {@link wicket.extensions.markup.html.form.select.Select}. + + * @author Igor Vaynberg (ivaynberg) + * @author Eelco Hillenius + */ +public class SelectPage 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 SelectPage() + { + 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); + + Select site=new Select("site"); + form.add(site); + site.add(new SelectOption("site1", new Model("tss"))); + site.add(new SelectOption("site2", new Model("jl"))); + site.add(new SelectOption("site3", new Model("sd"))); + site.add(new SelectOption("site4", new Model("bn"))); + + Select choices=new Select("choices"); + form.add(choices); + IOptionRenderer renderer=new IOptionRenderer() { + + public String getDisplayValue(Object object) + { + return object.toString(); + } + + public IModel getModel(Object value) + { + return new Model((Serializable)value); + } + + }; + choices.add(new SelectOptions("manychoices", new Model((Serializable)MANY_CHOICES), renderer) ); + + } + + /** Simple data class that acts as a model for the input fields. */ + private static class Input implements Serializable + { + /** the selected sites. */ + public String site = new String("sd"); + + /** 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 "site = '" + site + "', 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 = "<select wicket:id=\"sites\">\n" + + " <option>site 1</option>\n" + + " <option>site 2</option>\n" + + "</select>\n" + + "<select wicket:id=\"choices\">\n" + + " <option>choice 1</option>\n" + + " <option>choice 2</option>\n" + + "</select>"; + String code = + " // Add a multiple list choice component that uses the model object's 'site'\n" + + " // property to designate the current selection, and that uses the SITES\n" + + " // list for the available options.\n" + + " // Note that our model here holds a Collection, as we need to store\n" + + " // multiple values too\n" + + " ListMultipleChoice siteChoice = new ListMultipleChoice(\"sites\", SITES);\n" + + " form.add(siteChoice);\n" + + "\n" + + " ListMultipleChoice manyChoice = new ListMultipleChoice(\"choices\", MANY_CHOICES).setMaxRows(5);\n" + + " form.add(manyChoice);"; + + //TODO todo + html="SEE INSIDE FOR NOW"; + code="SEE INSIDE FOR NOW"; + + add(new ExplainPanel(html, code)); + + } +} \ No newline at end of file
