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