01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.examples.compref;
18:
19: import java.io.Serializable;
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import org.apache.wicket.examples.WicketExamplePage;
24: import org.apache.wicket.extensions.markup.html.form.palette.Palette;
25: import org.apache.wicket.markup.html.form.ChoiceRenderer;
26: import org.apache.wicket.markup.html.form.Form;
27: import org.apache.wicket.markup.html.form.IChoiceRenderer;
28: import org.apache.wicket.markup.html.panel.FeedbackPanel;
29: import org.apache.wicket.model.Model;
30:
31: /**
32: * Palette component example
33: *
34: * @author ivaynberg
35: */
36: public class PalettePage extends WicketExamplePage {
37: /**
38: * Constructor
39: */
40: public PalettePage() {
41: List persons = ComponentReferenceApplication.getPersons();
42: IChoiceRenderer renderer = new ChoiceRenderer("fullName",
43: "fullName");
44:
45: final Palette palette = new Palette("palette", new Model(
46: new ArrayList()), new Model((Serializable) persons),
47: renderer, 10, true);
48:
49: Form form = new Form("form") {
50: protected void onSubmit() {
51: info("selected person(s): "
52: + palette.getModelObjectAsString());
53: }
54: };
55:
56: add(form);
57: form.add(palette);
58:
59: add(new FeedbackPanel("feedback"));
60: }
61:
62: protected void explain() {
63: String html = "<form wicket:id=\"form\">\n"
64: + "<span wicket:id=\"palette\">\n" + "</span>\n</form>";
65: String code = " Form f=new Form(\"form\");<br/>"
66: + " add(f);<br/>"
67: + " List persons = ComponentReferenceApplication.getPersons();;<br/>"
68: + " IChoiceRenderer renderer = new ChoiceRenderer(\"fullName\", \"fullName\");<br/>"
69: + " final Palette palette = new Palette(\"palette\", new Model(new ArrayList()), new Model(<br/>"
70: + " (Serializable)persons), renderer, 10, true);<br/>";
71: add(new ExplainPanel(html, code));
72: }
73: }
|