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:30 UTC
[1/2] wicket git commit: Add convenience method to WebMarkupContainer
for getting the WebApplication
Repository: wicket
Updated Branches:
refs/heads/wicket-6.x 7d811219d -> 6edf15417
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/65539b02
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/65539b02
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/65539b02
Branch: refs/heads/wicket-6.x
Commit: 65539b02314188daf3edafe54cdefd3b856e0a45
Parents: 7d81121
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:02:25 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/65539b02/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/65539b02/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();
+ }
+}
[2/2] wicket git commit: WICKET-5994 Mounted
TemplateResourceReference throws org.apache.wicket.WicketRuntimeException
when https is used
Posted by mg...@apache.org.
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/6edf1541
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/6edf1541
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/6edf1541
Branch: refs/heads/wicket-6.x
Commit: 6edf1541748fb2de969ee695bf988573e621cafd
Parents: 65539b0
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:21 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/6edf1541/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 df90241..115e9a7 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;
/**
@@ -171,23 +172,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);
}
/**