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.echo;
18:
19: import org.apache.wicket.examples.WicketExamplePage;
20: import org.apache.wicket.markup.html.basic.Label;
21: import org.apache.wicket.markup.html.form.Form;
22: import org.apache.wicket.markup.html.form.TextField;
23: import org.apache.wicket.model.PropertyModel;
24:
25: /**
26: * The simplest form application possible. Just prints any user input to a
27: * label.
28: *
29: * @author Eelco Hillenius
30: */
31: public class Echo extends WicketExamplePage {
32: private String message = "[type your message to the world here]";
33:
34: /**
35: * Constructor.
36: */
37: public Echo() {
38: // This model references the page's message property and is
39: // shared by the label and form component
40: PropertyModel messageModel = new PropertyModel(this , "message");
41:
42: // The label displays the currently set message
43: add(new Label("msg", messageModel));
44:
45: // Add a form to change the message. We don't need to do anything
46: // else with this form as the shared model is automatically updated
47: // on form submits
48: Form form = new Form("form");
49: form.add(new TextField("msgInput", messageModel));
50: add(form);
51: }
52:
53: /**
54: * @return the message
55: */
56: public String getMessage() {
57: return message;
58: }
59:
60: /**
61: * @param message
62: * the message to set
63: */
64: public void setMessage(String message) {
65: this.message = message;
66: }
67: }
|