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;
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.markup.html.basic.Label;
24: import org.apache.wicket.markup.html.link.BookmarkablePageLink;
25:
26: /**
27: * Simple bookmarkable page that displays page parameters.
28: *
29: * @author Igor Vaynberg
30: */
31: public class Page2 extends WicketExamplePage {
32: private Random random = new Random();
33:
34: /**
35: * Constructor
36: *
37: * @param parameters
38: */
39: public Page2(PageParameters parameters) {
40: String p1 = "CANNOT RESOLVE FROM URL";
41: if (parameters.containsKey("param1")) {
42: p1 = parameters.getString("param1");
43: }
44: String p2 = "CANNOT RESOLVE FROM URL";
45: if (parameters.containsKey("param2")) {
46: p2 = parameters.getString("param2");
47: }
48:
49: add(new Label("p1", p1));
50: add(new Label("p2", p2));
51:
52: String newP1 = String.valueOf(random.nextInt());
53: String newP2 = String.valueOf(random.nextInt());
54:
55: PageParameters params = new PageParameters();
56: params.put("param1", newP1 + " " + newP2);
57: params.put("param2", newP2 + " " + newP1);
58:
59: BookmarkablePageLink link = new BookmarkablePageLink(
60: "refreshLink", getClass(), params);
61: add(link);
62:
63: add(new BookmarkablePageLink("homeLink", Home.class));
64: }
65: }
|