You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/06/24 17:04:47 UTC
svn commit: r550244 - in
/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages:
Application.java Home.html Home.java Page.html Page.java Sent.html Sent.java
Author: jbq
Date: Sun Jun 24 08:04:46 2007
New Revision: 550244
URL: http://svn.apache.org/viewvc?view=rev&rev=550244
Log:
Add an example with a Wicket bookmarkable page, and give an example to send a
Wicket page by email
Added:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html (with props)
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java (with props)
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html (with props)
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java (with props)
Modified:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.html
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.java
Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java?view=diff&rev=550244&r1=550243&r2=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java Sun Jun 24 08:04:46 2007
@@ -17,15 +17,21 @@
package org.apache.wicket.examples.staticpages;
import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.RequestCycle;
import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.request.WebExternalResourceRequestTarget;
import org.apache.wicket.request.RequestParameters;
import org.apache.wicket.request.target.basic.URIRequestTargetUrlCodingStrategy;
+import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget;
import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.response.StringResponse;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.PackageResourceStream;
import org.apache.wicket.util.resource.WebExternalResourceStream;
import org.apache.wicket.util.resource.XSLTResourceStream;
+import org.apache.wicket.util.value.ValueMap;
/**
* Examples for serving static files
@@ -65,6 +71,39 @@
"layout.xsl");
IResourceStream docStream = new WebExternalResourceStream(path);
return new ResourceStreamRequestTarget(new XSLTResourceStream(xslStream, docStream));
+ }
+ });
+
+ // Passing URI to a Wicket page
+ mount(new URIRequestTargetUrlCodingStrategy("/pages")
+ {
+ @Override
+ public IRequestTarget decode(RequestParameters requestParameters)
+ {
+ final ValueMap requestParams = decodeParameters(requestParameters);
+ final StringResponse emailResponse = new StringResponse();
+ final WebResponse originalResponse = (WebResponse)RequestCycle.get().getResponse();
+ if (requestParams.getString("email") != null) {
+ RequestCycle.get().setResponse(emailResponse);
+ }
+ PageParameters params = new PageParameters();
+ params.put("uri", requestParams.get(URI));
+ return new BookmarkablePageRequestTarget(Page.class, params) {
+ /**
+ * @see org.apache.wicket.request.target.component.BookmarkablePageRequestTarget#respond(org.apache.wicket.RequestCycle)
+ */
+ @Override
+ public void respond(RequestCycle requestCycle)
+ {
+ super.respond(requestCycle);
+ if (requestParams.getString("email") != null) {
+ // Here send the email instead of dumping it to stdout!
+ System.out.println(emailResponse.toString());
+ RequestCycle.get().setResponse(originalResponse);
+ RequestCycle.get().setRequestTarget(new BookmarkablePageRequestTarget(Sent.class));
+ }
+ }
+ };
}
});
}
Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.html?view=diff&rev=550244&r1=550243&r2=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.html (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.html Sun Jun 24 08:04:46 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
- <title>Wicket Examples - stockquote</title>
+ <title>Wicket Examples - Static Pages</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
@@ -50,6 +50,7 @@
<li><a wicket:id="hellostream">Hello World as a Static Page</a></li>
<li><a wicket:id="helloxslt">Hello World as a Static Page with XSLT
layout</a></li>
+ <li><a wicket:id="wicketpage">Passing URI to a Wicket page</a></li>
</ul>
<p>NOTE: it is possible to serve any kind of content using this method, not
Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.java?view=diff&rev=550244&r1=550243&r2=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.java (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Home.java Sun Jun 24 08:04:46 2007
@@ -41,6 +41,8 @@
add(new StaticLink("hellostream", new Model("docs/hello.html")));
// Hello World as a Static Page with XSLT layout
add(new StaticLink("helloxslt", new Model("xsldocs/hello.html")));
+ // Passing URI to a Wicket page
+ add(new StaticLink("wicketpage", new Model("pages/path/to/hello.html")));
}
private class StaticLink extends WebMarkupContainer
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html?view=auto&rev=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html Sun Jun 24 08:04:46 2007
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Wicket Examples - Static Pages</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ </head>
+ <body>
+ <span wicket:id="mainNavigation"/>
+ <p>The <tt>uri</tt> parameter is: <b><span wicket:id="uri"></span></b></p>
+
+ <p>This parameter can be used to fetch contents in a database or from a file while using a nice URL to identify the
+ document. The example is using a Wicket bookmarkable page.</p>
+ </body>
+</html>
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java?view=auto&rev=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java Sun Jun 24 08:04:46 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.staticpages;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * @author jbq
+ */
+public class Page extends WicketExamplePage
+{
+ public Page(PageParameters parameters)
+ {
+ add(new Label("uri", parameters.getString("uri")));
+ }
+}
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Page.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html?view=auto&rev=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html Sun Jun 24 08:04:46 2007
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Wicket Examples - Static Pages</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ </head>
+ <body>
+ <span wicket:id="mainNavigation"/>
+ <p><b>The email has been sent!</b></p>
+
+ <p>Well, that's if you have a little bit of imagination. But for now the page has been dumped to stdout. Sending
+ the real email is left as an exercise for the reader.</p>
+ </body>
+</html>
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java?view=auto&rev=550244
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java Sun Jun 24 08:04:46 2007
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.staticpages;
+
+import org.apache.wicket.examples.WicketExamplePage;
+
+/**
+ * @author jbq
+ */
+public class Sent extends WicketExamplePage
+{
+}
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Sent.java
------------------------------------------------------------------------------
svn:keywords = Id