You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/07/28 20:03:33 UTC

svn commit: r1151944 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/view/facelets/impl/ test/java/org/apache/myfaces/view/facelets/tag/ui/ test/resources/org/apache/myfaces/view/facelets/tag/ui/

Author: lu4242
Date: Thu Jul 28 18:03:32 2011
New Revision: 1151944

URL: http://svn.apache.org/viewvc?rev=1151944&view=rev
Log:
MYFACES-3246 java.lang.IndexOutOfBoundsException when CACHE_EL=always 

Added:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/ELExprTemplateTestCase.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included1.xhtml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included2.xhtml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_main.xhtml
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/TemplateContextImpl.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java?rev=1151944&r1=1151943&r2=1151944&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java Thu Jul 28 18:03:32 2011
@@ -126,6 +126,10 @@ final class DefaultFacelet extends Abstr
         }
         DefaultFaceletContext ctx = new DefaultFaceletContext(facesContext, this, myFaceletContext);
         
+        //Set FACELET_CONTEXT_KEY on FacesContext attribute map, to 
+        //reflect the current facelet context instance
+        facesContext.getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctx);
+        
         ctx.pushPageContext(new PageContextImpl());
         
         try
@@ -325,7 +329,10 @@ final class DefaultFacelet extends Abstr
         try
         {
             this.refresh(parent);
-            _root.apply(new DefaultFaceletContext((DefaultFaceletContext)ctx, this, false), parent);
+            DefaultFaceletContext ctxWrapper = new DefaultFaceletContext((DefaultFaceletContext)ctx, this, false);
+            ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctxWrapper);
+            _root.apply(ctxWrapper, parent);
+            ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctx);
             this.markApplied(parent);
         }
         finally
@@ -406,7 +413,12 @@ final class DefaultFacelet extends Abstr
             
             this.refresh(parent);
             mctx.markForDeletion(parent);
-            f._root.apply(new DefaultFaceletContext( (DefaultFaceletContext)ctx, f, true), parent);
+            DefaultFaceletContext ctxWrapper = new DefaultFaceletContext( (DefaultFaceletContext)ctx, f, true);
+            //Update FACELET_CONTEXT_KEY on FacesContext attribute map, to 
+            //reflect the current facelet context instance
+            ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctxWrapper);
+            f._root.apply(ctxWrapper, parent);
+            ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctx);
             mctx.finalizeForDeletion(parent);
             this.markApplied(parent);
             

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java?rev=1151944&r1=1151943&r2=1151944&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java Thu Jul 28 18:03:32 2011
@@ -194,10 +194,6 @@ final class DefaultFaceletContext extend
         
         _elExpressionCacheMode = mctx.getELExpressionCacheMode();
         _isCacheELExpressions = !ELExpressionCacheMode.noCache.equals(_elExpressionCacheMode);
-
-        //Set FACELET_CONTEXT_KEY on FacesContext attribute map, to 
-        //reflect the current facelet context instance
-        faces.getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, this);
     }
 
     /**
@@ -688,6 +684,7 @@ final class DefaultFaceletContext extend
                 boolean found = false;
                 AbstractFaceletContext actx = new DefaultFaceletContext(
                         (DefaultFaceletContext) ctx, this._owner, false);
+                ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, actx);
                 try
                 {
                     actx.pushPageContext(this._pageContext);
@@ -699,6 +696,7 @@ final class DefaultFaceletContext extend
                 {
                     actx.popPageContext();
                 }
+                ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctx);
                 this._names.remove(testName);
                 return found;
             }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/TemplateContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/TemplateContextImpl.java?rev=1151944&r1=1151943&r2=1151944&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/TemplateContextImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/TemplateContextImpl.java Thu Jul 28 18:03:32 2011
@@ -172,6 +172,7 @@ public class TemplateContextImpl extends
                 boolean found = false;
                 AbstractFaceletContext actx = new DefaultFaceletContext(
                         (DefaultFaceletContext) ctx, this._owner, false);
+                ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, actx);
                 try
                 {
                     actx.pushPageContext(this._pageContext);
@@ -183,6 +184,7 @@ public class TemplateContextImpl extends
                 {
                     actx.popPageContext();
                 }
+                ctx.getFacesContext().getAttributes().put(FaceletContext.FACELET_CONTEXT_KEY, ctx);
                 this._names.remove(testName);
                 return found;
             }

Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/ELExprTemplateTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/ELExprTemplateTestCase.java?rev=1151944&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/ELExprTemplateTestCase.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/ELExprTemplateTestCase.java Thu Jul 28 18:03:32 2011
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.view.facelets.tag.ui;
+
+import javax.faces.component.UIViewRoot;
+
+import org.apache.myfaces.view.facelets.FaceletTestCase;
+import org.apache.myfaces.view.facelets.impl.FaceletCompositionContextImpl;
+import org.junit.Test;
+
+public class ELExprTemplateTestCase extends FaceletTestCase {
+
+    
+    
+    @Override
+    protected void setUpServletObjects() throws Exception
+    {
+        super.setUpServletObjects();
+        
+        servletContext.addInitParameter(
+                FaceletCompositionContextImpl.INIT_PARAM_CACHE_EL_EXPRESSIONS,
+                "always");
+    }
+
+    /**
+     * See MYFACES-3246 for details
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testELExprTemplate() throws Exception
+    {
+        UIViewRoot root = facesContext.getViewRoot();
+        vdl.buildView(facesContext, root, "elexpr_main.xhtml");
+    }
+
+}

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included1.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included1.xhtml?rev=1151944&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included1.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included1.xhtml Thu Jul 28 18:03:32 2011
@@ -0,0 +1,23 @@
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: s_page.xhtml,v 1.2 2008/07/13 19:01:38 rlubke Exp $
+-->
+<f:subview xmlns:ui="http://java.sun.com/jsf/facelets" 
+           xmlns:f="http://java.sun.com/jsf/core" 
+           xmlns:h="http://java.sun.com/jsf/html">
+        <ui:include src="elexpr_included2.xhtml" />
+        <h:commandButton>
+            <f:ajax execute="@this" />
+        </h:commandButton>
+</f:subview>  

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included2.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included2.xhtml?rev=1151944&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included2.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_included2.xhtml Thu Jul 28 18:03:32 2011
@@ -0,0 +1,16 @@
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: s_page.xhtml,v 1.2 2008/07/13 19:01:38 rlubke Exp $
+-->
+<f:subview xmlns:f="http://java.sun.com/jsf/core" />

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_main.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_main.xhtml?rev=1151944&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_main.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/elexpr_main.xhtml Thu Jul 28 18:03:32 2011
@@ -0,0 +1,25 @@
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Id: s_page.xhtml,v 1.2 2008/07/13 19:01:38 rlubke Exp $
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<f:view xmlns="http://www.w3.org/1999/xhtml" 
+        xmlns:ui="http://java.sun.com/jsf/facelets" 
+        xmlns:f="http://java.sun.com/jsf/core" 
+        xmlns:h="http://java.sun.com/jsf/html">
+<html>
+<h:head />
+<h:body><ui:include src="elexpr_included1.xhtml" /></h:body>
+</html>
+</f:view>