webwork/src/main/webwork/view/velocity VelocityHelper.java,1.3,1.4 WebWorkVelocityServlet.java,1.6,1.7
[email protected] Wed, 19 Jan 2005 21:26:27 -0800
| Newsgroups | gmane.comp.java.open-symphony.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/opensymphony/webwork/src/main/webwork/view/velocity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23781/src/main/webwork/view/velocity
Modified Files:
VelocityHelper.java WebWorkVelocityServlet.java
Log Message:
Allow WebWorkVelocityServlet to be subclassed - made static final's
protected so that they can be accessed from a subclass.
Also made the VelocityHelper to be more flexible - you can now pass in
extra parameters.
I also added a new parameter to velocity - the '$action' property, which
evaluates to the root of the stack. Otherwise there was no way to call
methods on the root of the stack.
Index: VelocityHelper.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/view/velocity/VelocityHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- VelocityHelper.java 16 Nov 2003 04:56:41 -0000 1.3
+++ VelocityHelper.java 20 Jan 2005 05:26:24 -0000 1.4
@@ -1,8 +1,6 @@
package webwork.view.velocity;
-import java.util.Properties;
-import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.*;
import java.io.Writer;
import javax.servlet.ServletContext;
@@ -39,6 +37,8 @@
*/
public static final String RESPONSE = "res";
+ public static final String ACTION = "action";
+
static final String WEBWORK_UTIL = "webwork";
private static boolean initialized = false;
public static final String VELO_CONTEXT = "__webwork__velocity__context";
@@ -145,7 +145,12 @@
}
}
- public static Context getContext(ServletContext context, ServletRequest request, ServletResponse response)
+ public static Context getContext(ServletContext context, ServletRequest request, ServletResponse response)
+ {
+ return getContext(context, request, response, Collections.EMPTY_MAP);
+ }
+
+ public static Context getContext(ServletContext context, ServletRequest request, ServletResponse response, Map extraContextParams)
{
if(!initialized)
{
@@ -162,10 +167,11 @@
WebWorkVelocityContext ctx = (WebWorkVelocityContext)request.getAttribute(VELO_CONTEXT);
if(ctx==null)
{
- ctx = new WebWorkVelocityContext(ServletValueStack.getStack(request));
+ ctx = new WebWorkVelocityContext(ServletValueStack.getStack(request), extraContextParams);
ctx.put(REQUEST, request);
ctx.put(RESPONSE, response);
ctx.put(WEBWORK_UTIL, new WebWorkUtil(ctx));
+ ctx.put(ACTION, ServletValueStack.getStack(request).findValue("/"));
request.setAttribute(VELO_CONTEXT, ctx);
}
return ctx;
@@ -178,8 +184,9 @@
{
ServletValueStack stack;
- WebWorkVelocityContext(ServletValueStack aStack)
+ WebWorkVelocityContext(ServletValueStack aStack, Map extraContextParams)
{
+ super(extraContextParams);
stack = aStack;
}
Index: WebWorkVelocityServlet.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/view/velocity/WebWorkVelocityServlet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- WebWorkVelocityServlet.java 15 Nov 2003 20:08:11 -0000 1.6
+++ WebWorkVelocityServlet.java 20 Jan 2005 05:26:24 -0000 1.7
@@ -24,13 +24,13 @@
*
* This allows you to use Velocity templates as views of WebWork actions.
*
- * @author Rickard Öberg ([email protected])
+ * @author Rickard Åberg ([email protected])
* @version $Revision$
*/
public class WebWorkVelocityServlet extends VelocityServlet
{
- static final String CONTEXT = "velocity_context";
- static final String WEBWORK_UTIL = "webwork";
+ protected static final String CONTEXT = "velocity_context";
+ protected static final String WEBWORK_UTIL = "webwork";
protected Log log = LogFactory.getLog(getClass());
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl