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.util.ArrayList;
20:
21: import org.apache.wicket.examples.WicketExamplePage;
22: import org.apache.wicket.markup.html.basic.Label;
23: import org.apache.wicket.markup.html.form.Check;
24: import org.apache.wicket.markup.html.form.CheckGroup;
25: import org.apache.wicket.markup.html.form.CheckGroupSelector;
26: import org.apache.wicket.markup.html.form.Form;
27: import org.apache.wicket.markup.html.list.ListItem;
28: import org.apache.wicket.markup.html.list.ListView;
29: import org.apache.wicket.markup.html.panel.FeedbackPanel;
30: import org.apache.wicket.model.PropertyModel;
31:
32: /**
33: * CheckGroup and Check components example page
34: *
35: * @author ivaynberg
36: */
37: public class CheckGroupPage extends WicketExamplePage {
38: /**
39: * Constructor
40: */
41: public CheckGroupPage() {
42:
43: final CheckGroup group = new CheckGroup("group",
44: new ArrayList());
45: Form form = new Form("form") {
46: protected void onSubmit() {
47: info("selected person(s): "
48: + group.getModelObjectAsString());
49: }
50: };
51:
52: add(form);
53: form.add(group);
54: group.add(new CheckGroupSelector("groupselector"));
55: ListView persons = new ListView("persons",
56: ComponentReferenceApplication.getPersons()) {
57:
58: protected void populateItem(ListItem item) {
59: item.add(new Check("checkbox", item.getModel()));
60: item.add(new Label("name", new PropertyModel(item
61: .getModel(), "name")));
62: item.add(new Label("lastName", new PropertyModel(item
63: .getModel(), "lastName")));
64: }
65:
66: };
67:
68: group.add(persons);
69:
70: add(new FeedbackPanel("feedback"));
71: }
72:
73: protected void explain() {
74: String html = "<form wicket:id=\"form\">\n"
75: + "<span wicket:id=\"group\">\n"
76: + "<input type=\"checkbox\" wicket:id=\"groupselector\">check/uncheck all</input>\n"
77: + "<tr wicket:id=\"persons\">\n"
78: + "<td><input type=\"checkbox\" wicket:id=\"checkbox\"/></td>\n"
79: + "<td><span wicket:id=\"name\">[this is where name will be]</span></td>\n"
80: + "<td><span wicket:id=\"lastName\">[this is where lastname will be]</span></td>\n"
81: + "</tr>\n</span>\n</form>";
82: String code = " Form f=new Form(\"form\");<br/>"
83: + " add(f);<br/>"
84: + " CheckGroup group=new CheckGroup(\"group\");<br/>"
85: + " form.add(group);<br/>"
86: + " group.add(new CheckGroupSelector(\"groupselector\"));<br/>"
87: + " ListView persons=new ListView(\"persons\", getPersons()) {<br/>"
88: + " protected void populateItem(ListItem item) {<br/>"
89: + " item.add(new Check(\"check\", item.getModel()));<br/>"
90: + " item.add(new Label(\"name\", new PropertyModel(item.getModel(), \"name\")));<br/>"
91: + " item.add(new Label(\"lastName\", new PropertyModel(item.getModel(), \"lastName\")));<br/>"
92: + " };<br/>"
93: + " group.add(persons);<br/>";
94: add(new ExplainPanel(html, code));
95: }
96: }
|