You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2010/09/02 22:07:14 UTC
svn commit: r992097 - in /tiles/sandbox/trunk/tiles-request:
tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java
tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java
Author: apetrelli
Date: Thu Sep 2 20:07:13 2010
New Revision: 992097
URL: http://svn.apache.org/viewvc?rev=992097&view=rev
Log:
TILESSB-35
Some fixes in VelocityRenderer e DispatchRenderer.
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java
tiles/sandbox/trunk/tiles-request/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java
Modified: tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java?rev=992097&r1=992096&r2=992097&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java (original)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/render/DispatchRenderer.java Thu Sep 2 20:07:13 2010
@@ -44,10 +44,6 @@ public class DispatchRenderer implements
/** {@inheritDoc} */
public boolean isRenderable(String path, Request request) {
- if (path == null) {
- throw new InvalidTemplateException("Cannot dispatch a null path");
- }
-
- return path.startsWith("/");
+ return path != null && path.startsWith("/");
}
}
Modified: tiles/sandbox/trunk/tiles-request/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java?rev=992097&r1=992096&r2=992097&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java (original)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/render/VelocityRenderer.java Thu Sep 2 20:07:13 2010
@@ -55,31 +55,25 @@ public class VelocityRenderer implements
/** {@inheritDoc} */
@Override
- public void render(String value, Request request) throws IOException {
- if (value != null) {
- if (value instanceof String) {
- ServletRequest servletRequest = ServletUtil.getServletRequest(request);
- // then get a context
- Context context = velocityView.createContext(servletRequest
- .getRequest(), servletRequest.getResponse());
+ public void render(String path, Request request) throws IOException {
+ if (path == null) {
+ throw new InvalidTemplateException("Cannot dispatch a null path");
+ }
- // get the template
- Template template = velocityView.getTemplate((String) value);
+ ServletRequest servletRequest = ServletUtil.getServletRequest(request);
+ // then get a context
+ Context context = velocityView.createContext(servletRequest
+ .getRequest(), servletRequest.getResponse());
- // merge the template and context into the writer
- velocityView.merge(template, context, request.getWriter());
- } else {
- throw new InvalidTemplateException(
- "Cannot render a template that is not a string: "
- + value.toString());
- }
- } else {
- throw new InvalidTemplateException("Cannot render a null template");
- }
+ // get the template
+ Template template = velocityView.getTemplate((String) path);
+
+ // merge the template and context into the writer
+ velocityView.merge(template, context, request.getWriter());
}
/** {@inheritDoc} */
- public boolean isRenderable(String string, Request request) {
- return string.startsWith("/") && string.endsWith(".vm");
+ public boolean isRenderable(String path, Request request) {
+ return path != null && path.startsWith("/") && path.endsWith(".vm");
}
}