You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2015/10/11 20:05:09 UTC
[1/2] wicket git commit: WICKET-5994 Mounted
TemplateResourceReference throws org.apache.wicket.WicketRuntimeException
when https is used
Repository: wicket
Updated Branches:
refs/heads/master ada27ba4e -> 500f9b9aa
WICKET-5994 Mounted TemplateResourceReference throws org.apache.wicket.WicketRuntimeException when https is used
Use ServletContext to read local resources
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/500f9b9a
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/500f9b9a
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/500f9b9a
Branch: refs/heads/master
Commit: 500f9b9aa99f044153130713f026ba27757e81c5
Parents: c95ad48
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun Oct 11 20:03:34 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sun Oct 11 20:05:00 2015 +0200
----------------------------------------------------------------------
.../wicket/markup/html/include/Include.java | 32 +++++++++++---------
1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/500f9b9a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java
index 03c40a7..bfc52d9 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java
@@ -20,7 +20,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
-import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletContext;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.core.util.resource.UrlResourceStream;
@@ -31,6 +31,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.UrlUtils;
import org.apache.wicket.resource.ResourceUtil;
+import org.apache.wicket.util.lang.Args;
/**
@@ -154,23 +155,24 @@ public class Include extends WebComponent
* the url to import
* @return the imported url's contents
*/
- private String importRelativeUrl(CharSequence url)
+ private String importRelativeUrl(String url)
{
- // make the url absolute
- HttpServletRequest req = (HttpServletRequest)getRequest().getContainerRequest();
- StringBuilder buildUrl = new StringBuilder(url.length());
- String scheme = req.getScheme();
- int port = req.getServerPort();
- buildUrl.append(scheme); // http, https
- buildUrl.append("://");
- buildUrl.append(req.getServerName());
- if ((scheme.equals("http") && port != 80) || (scheme.equals("https") && port != 443))
+ Args.notEmpty(url, "url");
+
+ if (url.charAt(0) != '/')
+ {
+ url = '/' + url;
+ }
+
+ try
+ {
+ ServletContext servletContext = getWebApplication().getServletContext();
+ URL resource = servletContext.getResource(url);
+ return importUrl(resource);
+ } catch (MalformedURLException mux)
{
- buildUrl.append(':');
- buildUrl.append(req.getServerPort());
+ throw new WicketRuntimeException(mux);
}
- buildUrl.append(req.getContextPath()).append('/').append(url);
- return importAbsoluteUrl(buildUrl);
}
/**
[2/2] wicket git commit: Add convenience method to WebMarkupContainer
for getting the WebApplication
Posted by mg...@apache.org.
Add convenience method to WebMarkupContainer for getting the WebApplication
Add the same methods to WebComponent
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c95ad484
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c95ad484
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c95ad484
Branch: refs/heads/master
Commit: c95ad484b1911a098627d6c5f17aad3bd2aea5d5
Parents: ada27ba
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun Oct 11 19:56:58 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sun Oct 11 20:05:00 2015 +0200
----------------------------------------------------------------------
.../apache/wicket/markup/html/WebComponent.java | 57 +++++++++++++++++++-
.../wicket/markup/html/WebMarkupContainer.java | 15 +++++-
2 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/c95ad484/wicket-core/src/main/java/org/apache/wicket/markup/html/WebComponent.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebComponent.java
index b2bc9fa..3d7ac26 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebComponent.java
@@ -18,6 +18,10 @@ package org.apache.wicket.markup.html;
import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.request.http.WebRequest;
+import org.apache.wicket.request.http.WebResponse;
/**
* Base class for simple HTML components which do not hold nested components. If you need to support
@@ -55,4 +59,55 @@ public class WebComponent extends Component
{
internalRenderComponent();
}
-}
\ No newline at end of file
+
+
+ /**
+ * A convenience method to return the WebPage. Same as getPage().
+ *
+ * @return WebPage
+ */
+ public final WebPage getWebPage()
+ {
+ return (WebPage)getPage();
+ }
+
+ /**
+ * A convenience method to return the current WebRequest. Same as {@link org.apache.wicket.Component#getRequest()}.
+ *
+ * @return the current WebRequest
+ */
+ public final WebRequest getWebRequest()
+ {
+ return (WebRequest)getRequest();
+ }
+
+ /**
+ * A convenience method to return the current WebResponse. Same as {@link org.apache.wicket.Component#getResponse()}.
+ *
+ * @return the current WebResponse
+ */
+ public final WebResponse getWebResponse()
+ {
+ return (WebResponse)getResponse();
+ }
+
+ /**
+ * A convenience method to return the WebSession. Same as {@link org.apache.wicket.Component#getSession()} .
+ *
+ * @return the current WebSession
+ */
+ public final WebSession getWebSession()
+ {
+ return WebSession.get();
+ }
+
+ /**
+ * A convenience method to return the WebApplication. Same as {@link WebApplication#get()}.
+ *
+ * @return the current WebApplication
+ */
+ public final WebApplication getWebApplication()
+ {
+ return WebApplication.get();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/c95ad484/wicket-core/src/main/java/org/apache/wicket/markup/html/WebMarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebMarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebMarkupContainer.java
index 222169a..7be4716 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebMarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebMarkupContainer.java
@@ -19,6 +19,7 @@ package org.apache.wicket.markup.html;
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.WebResponse;
@@ -89,6 +90,16 @@ public class WebMarkupContainer extends MarkupContainer
*/
public final WebSession getWebSession()
{
- return (WebSession)getSession();
+ return WebSession.get();
}
-}
\ No newline at end of file
+
+ /**
+ * A convenience method to return the WebApplication. Same as {@link WebApplication#get()}.
+ *
+ * @return the current WebApplication
+ */
+ public final WebApplication getWebApplication()
+ {
+ return WebApplication.get();
+ }
+}