01: /*
02: * $Id$ $Revision$ $Date$
03: *
04: * ==================================================================== Licensed
05: * under the Apache License, Version 2.0 (the "License"); you may not use this
06: * file except in compliance with the License. You may obtain a copy of the
07: * 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, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package wicket.examples.compref;
18:
19: import wicket.PageParameters;
20: import wicket.examples.WicketExamplePage;
21: import wicket.markup.html.link.BookmarkablePageLink;
22:
23: /**
24: * Page with examples on {@link wicket.markup.html.link.BookmarkablePageLink}.
25: *
26: * @author Eelco Hillenius
27: */
28: public class BookmarkablePageLinkPage extends WicketExamplePage {
29: /**
30: * Constructor
31: */
32: public BookmarkablePageLinkPage() {
33: // Addbookmarkable page links. A page is bookmarkable when it has a
34: // public default
35: // constructor and/ or a constructor with a PageParameters argument
36:
37: // Here, we add a link to a bookmarkable page without passing any
38: // parameters
39: add(new BookmarkablePageLink("pageLinkNoArgs",
40: BookmarkablePage.class));
41:
42: // And here, we add a link to a bookmarkable page with passing a
43: // parameter that holds
44: // the message that is to be displayed in the page we address.
45: // Note that any arguments are passed as request parameters, and should
46: // thus be strings
47: PageParameters parameters = new PageParameters();
48: parameters.put("message",
49: "This message was passed as a page parameter argument");
50: add(new BookmarkablePageLink("pageLinkWithArgs",
51: BookmarkablePage.class, parameters));
52: }
53:
54: /**
55: * Override base method to provide an explanation
56: */
57: protected void explain() {
58: String html = "<a wicket:id=\"pageLinkWithArgs\">go to our bookmarkable page passing a message argument</a>";
59: String code = " // Note that any arguments are passed as request parameters, and should thus be strings\n"
60: + " PageParameters parameters = new PageParameters();\n"
61: + " parameters.put(\"message\", \"This message was passed as a page parameter argument\");\n"
62: + " add(new BookmarkablePageLink(\"pageLinkWithArgs\", BookmarkablePage.class, parameters));";
63: add(new ExplainPanel(html, code));
64:
65: }
66:
67: }
|