01: /*
02: * $Id: Page5.java 460265 2006-04-16 13:36:52Z jdonnerstag $ $Revision: 460265 $ $Date:
03: * 2006-03-04 13:35:30 +0100 (Sa, 04 Mrz 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.examples.niceurl.mounted;
19:
20: import java.util.Random;
21:
22: import wicket.PageParameters;
23: import wicket.examples.WicketExamplePage;
24: import wicket.examples.niceurl.Home;
25: import wicket.markup.html.basic.Label;
26: import wicket.markup.html.link.BookmarkablePageLink;
27:
28: /**
29: * Simple bookmarkable page that displays page parameters.
30: *
31: * @author Igor Vaynberg
32: */
33: public class Page5 extends WicketExamplePage {
34: private Random random = new Random();
35:
36: /**
37: * Constructor
38: *
39: * @param parameters
40: */
41: public Page5(PageParameters parameters) {
42: String p1 = "CANNOT RESOLVE FROM URL";
43: if (parameters.containsKey("param1")) {
44: p1 = "";
45: String[] array = parameters.getStringArray("param1");
46: for (int i = 0; i < array.length; i++) {
47: p1 += array[i];
48: if (array.length - 1 != i) {
49: p1 += ", ";
50: }
51: }
52: }
53: String p2 = "CANNOT RESOLVE FROM URL";
54: if (parameters.containsKey("param2")) {
55: p2 = "";
56: String[] array = parameters.getStringArray("param2");
57: for (int i = 0; i < array.length; i++) {
58: p2 += array[i];
59: if (array.length - 1 != i) {
60: p2 += ", ";
61: }
62: }
63: }
64:
65: add(new Label("p1", p1));
66: add(new Label("p2", p2));
67:
68: String newP1 = String.valueOf(random.nextInt());
69: String newP2 = String.valueOf(random.nextInt());
70:
71: PageParameters params = new PageParameters();
72: params.put("param1", newP1);
73: params.put("param2", newP2);
74:
75: BookmarkablePageLink link = new BookmarkablePageLink(
76: "refreshLink", Page5.class, params);
77: add(link);
78: add(new BookmarkablePageLink("homeLink", Home.class));
79: }
80: }
|