Update of /var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util
In directory james.mmbase.org:/tmp/cvs-serv11743

Modified Files:
        BasicBacking.java ContextContainer.java 
        PageContextBacking.java PageContextContainer.java 
Log Message:
more fixes related to MMB-1730


See also: 
http://cvs.mmbase.org/viewcvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util
See also: http://www.mmbase.org/jira/browse/MMB-1730


Index: BasicBacking.java
===================================================================
RCS file: 
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util/BasicBacking.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- BasicBacking.java   16 May 2007 23:24:49 -0000      1.12
+++ BasicBacking.java   7 Oct 2008 17:28:25 -0000       1.13
@@ -28,7 +28,7 @@
 
  * @author Michiel Meeuwissen
  * @since MMBase-1.8
- * @version $Id: BasicBacking.java,v 1.12 2007/05/16 23:24:49 michiel Exp $
+ * @version $Id: BasicBacking.java,v 1.13 2008/10/07 17:28:25 michiel Exp $
  */
 
 public  class BasicBacking extends AbstractMap<String, Object>  implements 
Backing {
@@ -45,15 +45,14 @@
     private final Map<String, Object> b = new HashMap<String, Object>(); // 
the actual backing.
 
     private final boolean isELIgnored;
-    private  PageContext pageContext;
+    private  transient PageContext pageContext;
 
     /**
      * @param pc The page-context to which variables must be reflected or 
<code>null</code> if this must not happen.
      */
     public BasicBacking(PageContext pc, boolean ignoreEL) {
         pageContext = pc;
-        assert pc != null;
-        isELIgnored = ignoreEL || 
"true".equals(pc.getServletContext().getInitParameter(ContextTag.ISELIGNORED_PARAM));
+        isELIgnored = ignoreEL || pageContext == null || 
"true".equals(pc.getServletContext().getInitParameter(ContextTag.ISELIGNORED_PARAM));
         if (log.isDebugEnabled()) {
             log.debug("Pushing page Context " + pc + " --> " + isELIgnored);
         }
@@ -74,8 +73,7 @@
     }
 
     public void pushPageContext(PageContext pc) {
-
-        PageContext origPageContext = pageContext;
+        final PageContext origPageContext = pageContext;
         pageContext = pc;
         if (isELIgnored) return; // never mind
 
@@ -197,7 +195,7 @@
     }
 
     void release() {
-        if (originalPageContextValues != null) {
+        if (originalPageContextValues != null && pageContext != null) {
             //log.debug("Restoring pageContext with " + 
originalPageContextValues);
             // restore the pageContext
             for (Map.Entry<String, Object> e : 
originalPageContextValues.entrySet()) {


Index: ContextContainer.java
===================================================================
RCS file: 
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util/ContextContainer.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- ContextContainer.java       26 Jun 2008 10:28:29 -0000      1.62
+++ ContextContainer.java       7 Oct 2008 17:28:25 -0000       1.63
@@ -25,7 +25,7 @@
  * there is searched for HashMaps in the HashMap.
  *
  * @author Michiel Meeuwissen
- * @version $Id: ContextContainer.java,v 1.62 2008/06/26 10:28:29 michiel Exp $
+ * @version $Id: ContextContainer.java,v 1.63 2008/10/07 17:28:25 michiel Exp $
  **/
 
 public abstract class ContextContainer extends AbstractMap<String, Object> 
implements Map<String, Object> {
@@ -112,12 +112,12 @@
      *
      * @since MMBase-1.8
      */
-    protected abstract Backing getBacking();
+    public abstract Backing getBacking();
 
 
     public void release(PageContext pc, ContextContainer p) {
         getBacking().pullPageContext(pc);
-        // restore also the parent.xb
+        // restore also the parent.
         parent = p;
     }
 
@@ -239,11 +239,14 @@
      * Like containsKey but doesn't check for dots.
      */
     private boolean simpleContainsKey(String key, boolean checkParent) {
-        boolean result = getBacking().containsKey(key);
-        if (!result && checkParent && parent != null) {
-            result = parent.simpleContainsKey(key, true);
+        if (getBacking().containsKey(key)) {
+            return true;
+        } else if (checkParent && parent != null) {
+            log.debug("Checking " + parent + " for " + key);
+            return parent.simpleContainsKey(key, true);
+        } else {
+            return false;
         }
-        return result;
     }
 
     /**


Index: PageContextBacking.java
===================================================================
RCS file: 
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util/PageContextBacking.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- PageContextBacking.java     26 Jun 2008 10:30:13 -0000      1.17
+++ PageContextBacking.java     7 Oct 2008 17:28:25 -0000       1.18
@@ -26,7 +26,7 @@
 
  * @author Michiel Meeuwissen
  * @since MMBase-1.8
- * @version $Id: PageContextBacking.java,v 1.17 2008/06/26 10:30:13 michiel 
Exp $
+ * @version $Id: PageContextBacking.java,v 1.18 2008/10/07 17:28:25 michiel 
Exp $
  */
 
 public  class PageContextBacking extends AbstractMap<String, Object> 
implements Backing {
@@ -35,7 +35,7 @@
 
     private static final int SCOPE = PageContext.PAGE_SCOPE;
 
-    private final PageContext pageContext;
+    private final transient PageContext pageContext;
 
     // We also want to store null, pageContext cannot contain those.
     private final Set<String> nulls = new HashSet<String>();
@@ -49,9 +49,11 @@
     }
 
     public void pushPageContext(PageContext pc) {
-        assert pageContext == pc;
+        assert pageContext == null || pageContext == pc;
+        if (log.isDebugEnabled()) {
         log.debug("Pushing " + pageContext + " --> " + pc);
     }
+    }
 
     public void pullPageContext(PageContext pc) {
 
@@ -159,10 +161,17 @@
         }
     }
     public Object getOriginal(String key) {
+        if (key == null) return null; // pageContext cannot accept null keys
         Object value = unwrapped.get(key);
         if (value != null) return value;
-        return pageContext.findAttribute(key);
+        if (pageContext.getRequest() == null) throw new 
IllegalArgumentException("PageContext " + pageContext + " has no request");
+        try {
+            return pageContext.findAttribute((String) key);
+        } catch (Exception e) {
+            throw new RuntimeException(" for " + (key == null ? "NULL" : 
(key.getClass() + ":" + key)) + "  " + e.getMessage() , e);
     }
+    }
+
     public boolean containsKey(Object key) {
         if (key instanceof String) {
             return pageContext.findAttribute((String) key) != null ||  
nulls.contains(key);


Index: PageContextContainer.java
===================================================================
RCS file: 
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/util/PageContextContainer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- PageContextContainer.java   10 Feb 2007 16:49:27 -0000      1.15
+++ PageContextContainer.java   7 Oct 2008 17:28:25 -0000       1.16
@@ -18,7 +18,7 @@
  * The page context container stores variables directly in the page context, 
like JSTL does.
  *
  * @author Michiel Meeuwissen
- * @version $Id: PageContextContainer.java,v 1.15 2007/02/10 16:49:27 nklasens 
Exp $
+ * @version $Id: PageContextContainer.java,v 1.16 2008/10/07 17:28:25 michiel 
Exp $
  * @since MMBase-1.8
  **/
 
@@ -46,7 +46,7 @@
         backing.release();
     }
 
-    protected Backing getBacking() {
+    public PageContextBacking getBacking() {
         return backing;
     }
 
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to