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.examples.WicketExamplePage;
20: import org.apache.wicket.markup.html.form.Form;
21: import org.apache.wicket.markup.html.form.SubmitLink;
22: import org.apache.wicket.markup.html.panel.FeedbackPanel;
23:
24: /**
25: * Page with examples on {@link org.apache.wicket.markup.html.form.Form}.
26: *
27: * @author Eelco Hillenius
28: */
29: public class SubmitLinkPage extends WicketExamplePage {
30: /**
31: * Constructor
32: */
33: public SubmitLinkPage() {
34: // Add a FeedbackPanel for displaying our messages
35: FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
36: add(feedbackPanel);
37:
38: // Add a form with 2 SubmitLinks that can be called
39: Form form = new Form("form");
40: add(form);
41:
42: SubmitLink internal = new SubmitLink("internal") {
43: public void onSubmit() {
44: info("internal onsubmit");
45: };
46: };
47: form.add(internal);
48:
49: SubmitLink external = new SubmitLink("external", form) {
50: public void onSubmit() {
51: info("external onsubmit");
52: };
53: };
54: add(external);
55: }
56:
57: /**
58: * Override base method to provide an explanation
59: */
60: protected void explain() {
61: String html = "<form wicket:id=\"form\">\n"
62: + "<a wicket:id=\"internal\">Internal SubmitLink</a>\n"
63: + "</form>\n"
64: + "<a wicket:id=\"external\">External SubmitLink</a>\n";
65: String code = " public SubmitLinkPage() {\n"
66: + " // Add a FeedbackPanel for displaying our messages\n"
67: + " FeedbackPanel feedbackPanel = new FeedbackPanel(\"feedback\");\n"
68: + " add(feedbackPanel);\n"
69: + "\n"
70: + " // Add a form with 2 SubmitLinks that can be called\n"
71: + " Form form = new Form(\"form\");\n"
72: + " add(form);\n"
73: + " SubmitLink internal = new SubmitLink(\"internal\");\n"
74: + " form.add(internal);\n"
75: + " SubmitLink external = new SubmitLink(\"external\", form);\n"
76: + " add(external);\n"
77: + " });\n"
78: + " }";
79: add(new ExplainPanel(html, code));
80:
81: }
82: }
|