01: /*
02: * $Id: AttributeModifierComponentPage.java,v 1.8 2005/02/09 18:52:59
03: * jonathanlocke Exp $ $Revision: 458694 $ $Date: 2006-01-16 08:25:03 +0100 (Mon, 16 Jan 2006) $
04: *
05: * ==================================================================== Licensed
06: * under the Apache License, Version 2.0 (the "License"); you may not use this
07: * file except in compliance with the License. You may obtain a copy of the
08: * License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15: * License for the specific language governing permissions and limitations under
16: * the License.
17: */
18: package wicket;
19:
20: import wicket.markup.html.WebPage;
21: import wicket.markup.html.basic.Label;
22: import wicket.model.AbstractDetachableModel;
23: import wicket.model.IModel;
24: import wicket.model.Model;
25:
26: /**
27: * Test page used for checking the attribute modification functionality of
28: * Component.
29: *
30: * @see AttributeModifierComponentTest
31: * @author Chris Turner
32: */
33: public class AttributeModifierComponentPage extends WebPage {
34: private static final long serialVersionUID = 1L;
35:
36: /**
37: * Construct.
38: *
39: *
40: */
41: public AttributeModifierComponentPage() {
42: // Label with attribute modifier
43: Label label1 = new Label("label1", new Model("Label 1"));
44: add(label1);
45:
46: // Label with override attribute modifier
47: Label label2 = new Label("label2", new Model("Label 2"));
48: label2.add(new AttributeModifier("class", new Model(
49: "overrideLabel")));
50: label2.add(new AttributeModifier("unknown",
51: new Model("invalid")));
52: add(label2);
53:
54: // Label with attribute inserter
55: Label label3 = new Label("label3", new Model("Label 3"));
56: label3.add(new AttributeModifier("class", true,
57: new AbstractDetachableModel() {
58: private static final long serialVersionUID = 1L;
59:
60: private transient String text = null;
61:
62: public void onDetach() {
63: text = null;
64: }
65:
66: public void onAttach() {
67: text = "insertLabel";
68: }
69:
70: public Object onGetObject(final Component component) {
71: return text;
72: }
73:
74: public void onSetObject(final Component component,
75: final Object object) {
76: text = object.toString();
77: }
78:
79: public IModel getNestedModel() {
80: // TODO General: Remove return text
81: return null;
82: }
83: }));
84: add(label3);
85: }
86: }
|