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 org.apache.wicket.IClusterable;
20: import org.apache.wicket.examples.WicketExamplePage;
21: import org.apache.wicket.markup.html.form.Form;
22: import org.apache.wicket.markup.html.form.TextArea;
23: import org.apache.wicket.markup.html.panel.FeedbackPanel;
24: import org.apache.wicket.model.CompoundPropertyModel;
25:
26: /**
27: * Page with examples on {@link org.apache.wicket.markup.html.form.TextArea}.
28: *
29: * @author Eelco Hillenius
30: */
31: public class TextAreaPage extends WicketExamplePage {
32: /**
33: * Constructor
34: */
35: public TextAreaPage() {
36: final Input input = new Input();
37: setModel(new CompoundPropertyModel(input));
38:
39: // Add a FeedbackPanel for displaying our messages
40: FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
41: add(feedbackPanel);
42:
43: // Add a form with an onSumbit implementation that sets a message
44: Form form = new Form("form") {
45: protected void onSubmit() {
46: info("input: " + input);
47: }
48: };
49: add(form);
50:
51: // add a text area component that uses Input's 'text' property.
52: form.add(new TextArea("text"));
53: }
54:
55: /** Simple data class that acts as a model for the input fields. */
56: private static class Input implements IClusterable {
57: /** some plain text. */
58: public String text = "line 1\nline 2\nline 3";
59:
60: /**
61: * @see java.lang.Object#toString()
62: */
63: public String toString() {
64: return "text = '" + text + "'";
65: }
66: }
67:
68: /**
69: * Override base method to provide an explanation
70: */
71: protected void explain() {
72: String html = "<textarea wicket:id=\"text\" rows=\"6\" cols=\"20\">Input comes here</textarea>";
73: String code = " // add a text area component that uses the model object's 'text' property.\n"
74: + " form.add(new TextArea(\"text\"));";
75: add(new ExplainPanel(html, code));
76: }
77:
78: }
|