Hi David,
In article <[EMAIL PROTECTED]>,
Wed, 22 Aug 2007 19:41:24 +0900 (JST),
Kazuhito SUGURI <[EMAIL PROTECTED]> wrote:
suguri> I think I can provide a patch if you can build Cactus jars from code,
suguri> although I don't have enough time to commit it to the code-base.
Please find the patch attached.
For your use case, you should write test case as follows:
import org.apache.cactus.server.ServletContextWrapper;
...
public void setUp() {
tag = new HelloWorldTag();
ServletContextWrapper context = (ServletContextWrapper)
pageContext.getServletContext();
cofntext.setInitParameter("test", "test-value at context");
tag.setPageContext(pageContext);
}
Hope this helps,
----
Kazuhito SUGURI
Index:
framework/src/java/share-12-13-14/org/apache/cactus/server/AbstractPageContextWrapper.java
===================================================================
---
framework/src/java/share-12-13-14/org/apache/cactus/server/AbstractPageContextWrapper.java
(revision 568555)
+++
framework/src/java/share-12-13-14/org/apache/cactus/server/AbstractPageContextWrapper.java
(working copy)
@@ -56,6 +56,11 @@
protected ServletURL url;
/**
+ * The wrapped ServletContext for this PageContext.
+ */
+ private ServletContextWrapper servletContext = null;
+
+ /**
* Construct an <code>PageContext</code> instance that delegates
* it's method calls to the page context object passed as parameter and
* that uses the URL passed as parameter to simulate a URL from which
@@ -110,8 +115,12 @@
*/
public ServletContext getServletContext()
{
- return new ServletContextWrapper(
- this.originalPageContext.getServletContext());
+ if (this.servletContext == null)
+ {
+ this.servletContext = new ServletContextWrapper(
+ this.originalPageContext.getServletContext());
+ }
+ return this.servletContext;
}
// Unmodified overridden methods -----------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]