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 2014/11/24 21:35:02 UTC

svn commit: r1641470 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag: ./ jstl/core/ ui/

Author: lu4242
Date: Mon Nov 24 20:35:02 2014
New Revision: 1641470

URL: http://svn.apache.org/r1641470
Log:
MYFACES-3944 Calls to fcc.startComponentUniqueIdSection(...) and fcc.endComponentUniqueIdSection(...) should be surrounded in a try finally block

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/UserTagHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/LegacyForEachHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/DecorateHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/LegacyDecorateHandler.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/UserTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/UserTagHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/UserTagHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/UserTagHandler.java Mon Nov 24 20:35:02 2014
@@ -121,42 +121,49 @@ final class UserTagHandler extends TagHa
             actx.pushClient(this);
             FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
             String uniqueId = fcc.startComponentUniqueIdSection();
-            if (this._vars.length > 0)
+            try
             {
-                if (ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode()))
+                if (this._vars.length > 0)
                 {
-                    FaceletState faceletState = ComponentSupport.getFaceletState(ctx, parent, true);
-                    for (int i = 0; i < this._vars.length; i++)
+                    if (ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode()))
                     {
-                        //((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
-                        faceletState.putBinding(uniqueId, names[i], values[i]);
-                        ValueExpression ve;
-                        if (ExternalSpecifications.isUnifiedELAvailable())
+                        FaceletState faceletState = ComponentSupport.getFaceletState(ctx, parent, true);
+                        for (int i = 0; i < this._vars.length; i++)
                         {
-                            ve = new FaceletStateValueExpressionUEL(uniqueId, names[i]);
+                            //((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
+                            faceletState.putBinding(uniqueId, names[i], values[i]);
+                            ValueExpression ve;
+                            if (ExternalSpecifications.isUnifiedELAvailable())
+                            {
+                                ve = new FaceletStateValueExpressionUEL(uniqueId, names[i]);
+                            }
+                            else
+                            {
+                                ve = new FaceletStateValueExpression(uniqueId, names[i]);
+                            }
+                            actx.getTemplateContext().setParameter(names[i], ve);
                         }
-                        else
+                    }
+                    else
+                    {
+                        for (int i = 0; i < this._vars.length; i++)
                         {
-                            ve = new FaceletStateValueExpression(uniqueId, names[i]);
+                            ((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
                         }
-                        actx.getTemplateContext().setParameter(names[i], ve);
                     }
                 }
-                else
+                // Disable caching always, even in 'always' mode
+                // The only mode that can support EL caching in this condition is alwaysRedirect.
+                if (!ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode()))
                 {
-                    for (int i = 0; i < this._vars.length; i++)
-                    {
-                        ((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
-                    }
+                    actx.getTemplateContext().setAllowCacheELExpressions(false);
                 }
+                ctx.includeFacelet(parent, this._location);
             }
-            // Disable caching always, even in 'always' mode
-            // The only mode that can support EL caching in this condition is alwaysRedirect.
-            if (!ELExpressionCacheMode.alwaysRecompile.equals(actx.getELExpressionCacheMode()))
+            finally
             {
-                actx.getTemplateContext().setAllowCacheELExpressions(false);
+                fcc.endComponentUniqueIdSection();
             }
-            ctx.includeFacelet(parent, this._location);
         }
         catch (FileNotFoundException e)
         {

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ChooseHandler.java Mon Nov 24 20:35:02 2014
@@ -94,62 +94,96 @@ public final class ChooseHandler extends
         String uniqueId = actx.generateUniqueFaceletTagId(
             fcc.startComponentUniqueIdSection(), tagId);
         Integer savedOption = null;
-        
-        Integer restoredSavedOption = getSavedOption(ctx, fcc, parent, uniqueId);
-        
-        if (restoredSavedOption != null)
+        try
         {
-            if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
+            Integer restoredSavedOption = getSavedOption(ctx, fcc, parent, uniqueId);
+
+            if (restoredSavedOption != null)
             {
-                for (int i = 0; i < this.when.length; i++)
+                if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
                 {
-                    //Ensure each option has its unique section
-                    fcc.startComponentUniqueIdSection();
-                    if (!processed)
+                    for (int i = 0; i < this.when.length; i++)
                     {
-                        if (this.when[i].isTestTrue(ctx))
+                        //Ensure each option has its unique section
+                        fcc.startComponentUniqueIdSection();
+                        try
                         {
-                            boolean markInitialState = !restoredSavedOption.equals(i);
-                            boolean oldMarkInitialState = false;
-                            Boolean isBuildingInitialState = null;
-                            try
+                            if (!processed)
                             {
-                                if (markInitialState)
+                                if (this.when[i].isTestTrue(ctx))
                                 {
-                                    //set markInitialState flag
-                                    oldMarkInitialState = fcc.isMarkInitialState();
-                                    fcc.setMarkInitialState(true);
-                                    isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
-                                            StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
-                                }
-                                this.when[i].apply(ctx, parent);
-                            }
-                            finally
-                            {
-                                if (markInitialState)
-                                {
-                                    //unset markInitialState flag
-                                    if (isBuildingInitialState == null)
+                                    boolean markInitialState = !restoredSavedOption.equals(i);
+                                    boolean oldMarkInitialState = false;
+                                    Boolean isBuildingInitialState = null;
+                                    try
                                     {
-                                        ctx.getFacesContext().getAttributes().remove(
-                                                StateManager.IS_BUILDING_INITIAL_STATE);
+                                        if (markInitialState)
+                                        {
+                                            //set markInitialState flag
+                                            oldMarkInitialState = fcc.isMarkInitialState();
+                                            fcc.setMarkInitialState(true);
+                                            isBuildingInitialState = (Boolean) ctx.getFacesContext().
+                                                    getAttributes().put(
+                                                    StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
+                                        }
+                                        this.when[i].apply(ctx, parent);
                                     }
-                                    else
+                                    finally
                                     {
-                                        ctx.getFacesContext().getAttributes().put(
-                                                StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                                        if (markInitialState)
+                                        {
+                                            //unset markInitialState flag
+                                            if (isBuildingInitialState == null)
+                                            {
+                                                ctx.getFacesContext().getAttributes().remove(
+                                                        StateManager.IS_BUILDING_INITIAL_STATE);
+                                            }
+                                            else
+                                            {
+                                                ctx.getFacesContext().getAttributes().put(
+                                                        StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                                            }
+                                            fcc.setMarkInitialState(oldMarkInitialState);
+                                        }
                                     }
-                                    fcc.setMarkInitialState(oldMarkInitialState);
+                                    processed = true;
+                                    savedOption = i;
+                                    //return;
                                 }
                             }
-                            processed = true;
-                            savedOption = i;
-                            //return;
+                        }
+                        finally
+                        {
+                            fcc.endComponentUniqueIdSection();
                         }
                     }
-                    fcc.endComponentUniqueIdSection();
-                }
 
+                }
+                else
+                {
+                    for (int i = 0; i < this.when.length; i++)
+                    {
+                        //Ensure each option has its unique section
+                        fcc.startComponentUniqueIdSection();
+                        try
+                        {
+                            if (!processed)
+                            {
+                                if (restoredSavedOption.equals(i))
+                                {
+                                    this.when[i].apply(ctx, parent);
+                                    processed = true;
+                                    savedOption = i;
+                                    //return;
+                                }
+                            }
+                        }
+                        finally
+                        {
+                            fcc.endComponentUniqueIdSection();
+                        }
+                    }
+                }
             }
             else
             {
@@ -157,51 +191,46 @@ public final class ChooseHandler extends
                 {
                     //Ensure each option has its unique section
                     fcc.startComponentUniqueIdSection();
-                    if (!processed)
+                    try
                     {
-                        if (restoredSavedOption.equals(i))
+                        if (!processed)
                         {
-                            this.when[i].apply(ctx, parent);
-                            processed = true;
-                            savedOption = i;
-                            //return;
+                            if (this.when[i].isTestTrue(ctx))
+                            {
+                                this.when[i].apply(ctx, parent);
+                                processed = true;
+                                savedOption = i;
+                                //return;
+                            }
                         }
                     }
-                    fcc.endComponentUniqueIdSection();
+                    finally
+                    {
+                        fcc.endComponentUniqueIdSection();
+                    }
                 }
             }
-        }
-        else
-        {
-            for (int i = 0; i < this.when.length; i++)
+            if (this.otherwise != null)
             {
-                //Ensure each option has its unique section
                 fcc.startComponentUniqueIdSection();
-                if (!processed)
+                try
                 {
-                    if (this.when[i].isTestTrue(ctx))
+                    if (!processed)
                     {
-                        this.when[i].apply(ctx, parent);
-                        processed = true;
-                        savedOption = i;
-                        //return;
+                        this.otherwise.apply(ctx, parent);
+                        savedOption = -1;
                     }
                 }
-                fcc.endComponentUniqueIdSection();
+                finally
+                {
+                    fcc.endComponentUniqueIdSection();
+                }
             }
         }
-        if (this.otherwise != null)
+        finally
         {
-            fcc.startComponentUniqueIdSection();
-            if (!processed)
-            {
-                this.otherwise.apply(ctx, parent);
-                savedOption = -1;
-            }
             fcc.endComponentUniqueIdSection();
         }
-        
-        fcc.endComponentUniqueIdSection();
 
         ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, savedOption);
         if (fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() && !fcc.isRefreshingTransientBuild())

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/ForEachHandler.java Mon Nov 24 20:35:02 2014
@@ -350,38 +350,43 @@ public final class ForEachHandler extend
                         serializableValues = false;
                     }
 
-                    fcc.startComponentUniqueIdSection(base);
-
-                    setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, i);
-                    boolean last = !itr.hasNext();
-                    // set the varStatus
-                    if (vs != null)
+                    try
                     {
-                        IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
-                        ValueExpression ve;
-                        if (t || srcVE == null)
+                        fcc.startComponentUniqueIdSection(base);
+
+                        setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, i);
+                        boolean last = !itr.hasNext();
+                        // set the varStatus
+                        if (vs != null)
                         {
-                            if (srcVE == null)
+                            IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
+                            ValueExpression ve;
+                            if (t || srcVE == null)
                             {
-                                ve = null;
+                                if (srcVE == null)
+                                {
+                                    ve = null;
+                                }
+                                else
+                                {
+                                    ve = ctx.getExpressionFactory().createValueExpression(
+                                                itrS, Object.class);
+                                }
                             }
                             else
                             {
-                                ve = ctx.getExpressionFactory().createValueExpression(
-                                            itrS, Object.class);
+                                ve = new IterationStatusExpression(itrS);
                             }
+                            setVar(ctx, parent, uniqueId, base+"_vs", vs, ve);
                         }
-                        else
-                        {
-                            ve = new IterationStatusExpression(itrS);
-                        }
-                        setVar(ctx, parent, uniqueId, base+"_vs", vs, ve);
-                    }
 
-                    // execute body
-                    this.nextHandler.apply(ctx, parent);
-
-                    fcc.endComponentUniqueIdSection(base);
+                        // execute body
+                        this.nextHandler.apply(ctx, parent);
+                    }
+                    finally
+                    {
+                        fcc.endComponentUniqueIdSection(base);
+                    }
 
                     // increment steps
                     mi = 1;
@@ -435,41 +440,46 @@ public final class ForEachHandler extend
                 value = stateValue[1];
                 String base = (String) stateValue[0];
 
-                fcc.startComponentUniqueIdSection(base);
-
-                setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, (Integer) stateValue[2]);
-                
-                boolean first = (si == 0);
-                boolean last = (si == size-1);
-                int i = (Integer)stateValue[2];
-                // set the varStatus
-                if (vs != null)
+                try
                 {
-                    IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
-                    ValueExpression ve;
-                    if (t || srcVE == null)
+                    fcc.startComponentUniqueIdSection(base);
+
+                    setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, (Integer) stateValue[2]);
+
+                    boolean first = (si == 0);
+                    boolean last = (si == size-1);
+                    int i = (Integer)stateValue[2];
+                    // set the varStatus
+                    if (vs != null)
                     {
-                        if (srcVE == null)
+                        IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
+                        ValueExpression ve;
+                        if (t || srcVE == null)
                         {
-                            ve = null;
+                            if (srcVE == null)
+                            {
+                                ve = null;
+                            }
+                            else
+                            {
+                                ve = ctx.getExpressionFactory().createValueExpression(
+                                            itrS, Object.class);
+                            }
                         }
                         else
                         {
-                            ve = ctx.getExpressionFactory().createValueExpression(
-                                        itrS, Object.class);
+                            ve = new IterationStatusExpression(itrS);
                         }
+                        setVar(ctx, parent, uniqueId, base, vs, ve);
                     }
-                    else
-                    {
-                        ve = new IterationStatusExpression(itrS);
-                    }
-                    setVar(ctx, parent, uniqueId, base, vs, ve);
-                }
-
-                // execute body
-                this.nextHandler.apply(ctx, parent);
 
-                fcc.endComponentUniqueIdSection(base);
+                    // execute body
+                    this.nextHandler.apply(ctx, parent);
+                }
+                finally
+                {
+                    fcc.endComponentUniqueIdSection(base);
+                }
             }
         }
         finally
@@ -556,72 +566,77 @@ public final class ForEachHandler extend
                             new Object[]{base, value, i});
                     }
 
-                    fcc.startComponentUniqueIdSection(base);
+                    try
+                    {
+                        fcc.startComponentUniqueIdSection(base);
 
-                    setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, i);
+                        setVar(ctx, parent, uniqueId, base, t, src, srcVE, value, v, i);
 
-                    boolean last = !itr.hasNext();
-                    // set the varStatus
-                    if (vs != null)
-                    {
-                        IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
-                        ValueExpression ve;
-                        if (t || srcVE == null)
+                        boolean last = !itr.hasNext();
+                        // set the varStatus
+                        if (vs != null)
                         {
-                            if (srcVE == null)
+                            IterationStatus itrS = new IterationStatus(first, last, i, sO, eO, mO, value);
+                            ValueExpression ve;
+                            if (t || srcVE == null)
                             {
-                                ve = null;
+                                if (srcVE == null)
+                                {
+                                    ve = null;
+                                }
+                                else
+                                {
+                                    ve = ctx.getExpressionFactory().createValueExpression(
+                                                itrS, Object.class);
+                                }
                             }
                             else
                             {
-                                ve = ctx.getExpressionFactory().createValueExpression(
-                                            itrS, Object.class);
+                                ve = new IterationStatusExpression(itrS);
                             }
+                            setVar(ctx, parent, uniqueId, base, vs, ve);
                         }
-                        else
-                        {
-                            ve = new IterationStatusExpression(itrS);
-                        }
-                        setVar(ctx, parent, uniqueId, base, vs, ve);
-                    }
-                    //setVarStatus(ctx, pctx, t, sO, eO, mO, srcVE, value, vs, first, !itr.hasNext(), i);
+                        //setVarStatus(ctx, pctx, t, sO, eO, mO, srcVE, value, vs, first, !itr.hasNext(), i);
 
-                    // execute body
-                    boolean markInitialState = (stateValue == null);// !restoredSavedOption.equals(i)
-                    boolean oldMarkInitialState = false;
-                    Boolean isBuildingInitialState = null;
-                    try
-                    {
-                        if (markInitialState && fcc.isUsingPSSOnThisView())
+                        // execute body
+                        boolean markInitialState = (stateValue == null);// !restoredSavedOption.equals(i)
+                        boolean oldMarkInitialState = false;
+                        Boolean isBuildingInitialState = null;
+                        try
                         {
-                            //set markInitialState flag
-                            oldMarkInitialState = fcc.isMarkInitialState();
-                            fcc.setMarkInitialState(true);
-                            isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
-                                    StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
-                        }                                
-                        this.nextHandler.apply(ctx, parent);
-                    }
-                    finally
-                    {
-                        if (markInitialState && fcc.isUsingPSSOnThisView())
-                        {
-                            //unset markInitialState flag
-                            if (isBuildingInitialState == null)
+                            if (markInitialState && fcc.isUsingPSSOnThisView())
                             {
-                                ctx.getFacesContext().getAttributes().remove(
-                                        StateManager.IS_BUILDING_INITIAL_STATE);
-                            }
-                            else
+                                //set markInitialState flag
+                                oldMarkInitialState = fcc.isMarkInitialState();
+                                fcc.setMarkInitialState(true);
+                                isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
+                                        StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
+                            }                                
+                            this.nextHandler.apply(ctx, parent);
+                        }
+                        finally
+                        {
+                            if (markInitialState && fcc.isUsingPSSOnThisView())
                             {
-                                ctx.getFacesContext().getAttributes().put(
-                                        StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                                //unset markInitialState flag
+                                if (isBuildingInitialState == null)
+                                {
+                                    ctx.getFacesContext().getAttributes().remove(
+                                            StateManager.IS_BUILDING_INITIAL_STATE);
+                                }
+                                else
+                                {
+                                    ctx.getFacesContext().getAttributes().put(
+                                            StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                                }
+                                fcc.setMarkInitialState(oldMarkInitialState);
                             }
-                            fcc.setMarkInitialState(oldMarkInitialState);
                         }
                     }
-
-                    fcc.endComponentUniqueIdSection(base);
+                    finally
+                    {
+                        fcc.endComponentUniqueIdSection(base);
+                    }
 
                     // increment steps
                     mi = 1;

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/IfHandler.java Mon Nov 24 20:35:02 2014
@@ -87,67 +87,73 @@ public final class IfHandler extends Tag
         Boolean restoredValue = (Boolean) ComponentSupport.restoreInitialTagState(ctx, fcc, parent, uniqueId);
         boolean b = false;
         boolean markInitialState = false;
-        if (restoredValue != null)
+        try
         {
-            if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
+            if (restoredValue != null)
             {
-                b = this.test.getBoolean(ctx);
-                if (!restoredValue.equals(b))
+                if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
+                {
+                    b = this.test.getBoolean(ctx);
+                    if (!restoredValue.equals(b))
+                    {
+                        markInitialState = true;
+                    }
+                }
+                else
                 {
-                    markInitialState = true;
+                    b = restoredValue;
                 }
             }
             else
             {
-                b = restoredValue;
+                // No state restored, calculate
+                b = this.test.getBoolean(ctx);
             }
-        }
-        else
-        {
-            // No state restored, calculate
-            b = this.test.getBoolean(ctx);
-        }
-        //boolean b = getTestValue(ctx, fcc, parent, uniqueId);
-        if (this.var != null)
-        {
-            ctx.setAttribute(var.getValue(ctx), Boolean.valueOf(b));
-        }
-        if (b)
-        {
-            boolean oldMarkInitialState = false;
-            Boolean isBuildingInitialState = null;
-            try
+            //boolean b = getTestValue(ctx, fcc, parent, uniqueId);
+            if (this.var != null)
             {
-                if (markInitialState)
-                {
-                    //set markInitialState flag
-                    oldMarkInitialState = fcc.isMarkInitialState();
-                    fcc.setMarkInitialState(true);
-                    isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
-                            StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
-                }
-                this.nextHandler.apply(ctx, parent);
+                ctx.setAttribute(var.getValue(ctx), Boolean.valueOf(b));
             }
-            finally
+            if (b)
             {
-                if (markInitialState)
+                boolean oldMarkInitialState = false;
+                Boolean isBuildingInitialState = null;
+                try
                 {
-                    //unset markInitialState flag
-                    if (isBuildingInitialState == null)
+                    if (markInitialState)
                     {
-                        ctx.getFacesContext().getAttributes().remove(
-                                StateManager.IS_BUILDING_INITIAL_STATE);
+                        //set markInitialState flag
+                        oldMarkInitialState = fcc.isMarkInitialState();
+                        fcc.setMarkInitialState(true);
+                        isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
+                                StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
                     }
-                    else
+                    this.nextHandler.apply(ctx, parent);
+                }
+                finally
+                {
+                    if (markInitialState)
                     {
-                        ctx.getFacesContext().getAttributes().put(
-                                StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        //unset markInitialState flag
+                        if (isBuildingInitialState == null)
+                        {
+                            ctx.getFacesContext().getAttributes().remove(
+                                    StateManager.IS_BUILDING_INITIAL_STATE);
+                        }
+                        else
+                        {
+                            ctx.getFacesContext().getAttributes().put(
+                                    StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        }
+                        fcc.setMarkInitialState(oldMarkInitialState);
                     }
-                    fcc.setMarkInitialState(oldMarkInitialState);
                 }
             }
         }
-        fcc.endComponentUniqueIdSection();
+        finally
+        {
+            fcc.endComponentUniqueIdSection();
+        }
         //AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
         ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, b);
         if (fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() && !fcc.isRefreshingTransientBuild())

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/LegacyForEachHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/LegacyForEachHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/LegacyForEachHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jstl/core/LegacyForEachHandler.java Mon Nov 24 20:35:02 2014
@@ -199,120 +199,126 @@ public final class LegacyForEachHandler 
         FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
         if (src != null)
         {
-            fcc.startComponentUniqueIdSection();
-            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
-            PageContext pctx = actx.getPageContext();
-            Iterator<?> itr = this.toIterator(src);
-            if (itr != null)
+            try
             {
-                int i = 0;
-
-                // move to start
-                while (i < s && itr.hasNext())
+                fcc.startComponentUniqueIdSection();
+                AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
+                PageContext pctx = actx.getPageContext();
+                Iterator<?> itr = this.toIterator(src);
+                if (itr != null)
                 {
-                    itr.next();
-                    i++;
-                }
+                    int i = 0;
 
-                String v = this.getVarName(ctx);
-                String vs = this.getVarStatusName(ctx);
-                ValueExpression ve = null;
-                ValueExpression vO = this.capture(v, pctx);
-                ValueExpression vsO = this.capture(vs, pctx);
-                int mi = 0;
-                Object value = null;
-                try
-                {
-                    boolean first = true;
-                    while (i <= e && itr.hasNext())
+                    // move to start
+                    while (i < s && itr.hasNext())
                     {
-                        value = itr.next();
+                        itr.next();
+                        i++;
+                    }
 
-                        // set the var
-                        if (v != null)
+                    String v = this.getVarName(ctx);
+                    String vs = this.getVarStatusName(ctx);
+                    ValueExpression ve = null;
+                    ValueExpression vO = this.capture(v, pctx);
+                    ValueExpression vsO = this.capture(vs, pctx);
+                    int mi = 0;
+                    Object value = null;
+                    try
+                    {
+                        boolean first = true;
+                        while (i <= e && itr.hasNext())
                         {
-                            if (t || srcVE == null)
+                            value = itr.next();
+
+                            // set the var
+                            if (v != null)
                             {
-                                if (value == null)
+                                if (t || srcVE == null)
                                 {
-                                    pctx.getAttributes().put(v, null);
+                                    if (value == null)
+                                    {
+                                        pctx.getAttributes().put(v, null);
+                                    }
+                                    else
+                                    {
+                                        pctx.getAttributes().put(v, 
+                                                ctx.getExpressionFactory().createValueExpression(
+                                                    value, Object.class));
+                                    }
                                 }
                                 else
                                 {
-                                    pctx.getAttributes().put(v, 
-                                            ctx.getExpressionFactory().createValueExpression(
-                                                value, Object.class));
+                                    ve = this.getVarExpr(srcVE, src, value, i);
+                                    pctx.getAttributes().put(v, ve);
                                 }
                             }
-                            else
-                            {
-                                ve = this.getVarExpr(srcVE, src, value, i);
-                                pctx.getAttributes().put(v, ve);
-                            }
-                        }
 
-                        // set the varStatus
-                        if (vs != null)
-                        {
-                            IterationStatus itrS = new IterationStatus(first, !itr.hasNext(), i, sO, eO, mO, value);
-                            if (t || srcVE == null)
+                            // set the varStatus
+                            if (vs != null)
                             {
-                                if (srcVE == null)
+                                IterationStatus itrS = new IterationStatus(first, !itr.hasNext(), i, sO, eO, mO, value);
+                                if (t || srcVE == null)
                                 {
-                                    pctx.getAttributes().put(vs, null);
+                                    if (srcVE == null)
+                                    {
+                                        pctx.getAttributes().put(vs, null);
+                                    }
+                                    else
+                                    {
+                                        pctx.getAttributes().put(vs, 
+                                                ctx.getExpressionFactory().createValueExpression(
+                                                    itrS, Object.class));
+                                    }
                                 }
                                 else
                                 {
-                                    pctx.getAttributes().put(vs, 
-                                            ctx.getExpressionFactory().createValueExpression(
-                                                itrS, Object.class));
+                                    ve = new IterationStatusExpression(itrS);
+                                    pctx.getAttributes().put(vs, ve);
                                 }
                             }
-                            else
-                            {
-                                ve = new IterationStatusExpression(itrS);
-                                pctx.getAttributes().put(vs, ve);
-                            }
-                        }
 
-                        // execute body
-                        this.nextHandler.apply(ctx, parent);
+                            // execute body
+                            this.nextHandler.apply(ctx, parent);
 
-                        // increment steps
-                        mi = 1;
-                        while (mi < m && itr.hasNext())
-                        {
-                            itr.next();
-                            mi++;
+                            // increment steps
+                            mi = 1;
+                            while (mi < m && itr.hasNext())
+                            {
+                                itr.next();
+                                mi++;
+                                i++;
+                            }
                             i++;
-                        }
-                        i++;
 
-                        first = false;
-                    }
-                }
-                finally
-                {
-                    //Remove them from PageContext
-                    if (v != null)
-                    {
-                        pctx.getAttributes().put(v, vO);
-                    }
-                    else
-                    {
-                        pctx.getAttributes().remove(v);
-                    }
-                    if (vs != null)
-                    {
-                        pctx.getAttributes().put(vs, vsO);
+                            first = false;
+                        }
                     }
-                    else
+                    finally
                     {
-                        pctx.getAttributes().remove(vs);
+                        //Remove them from PageContext
+                        if (v != null)
+                        {
+                            pctx.getAttributes().put(v, vO);
+                        }
+                        else
+                        {
+                            pctx.getAttributes().remove(v);
+                        }
+                        if (vs != null)
+                        {
+                            pctx.getAttributes().put(vs, vsO);
+                        }
+                        else
+                        {
+                            pctx.getAttributes().remove(vs);
+                        }
                     }
                 }
             }
-            fcc.endComponentUniqueIdSection();
+            finally
+            {
+                fcc.endComponentUniqueIdSection();
+            }
         }
 
         if (fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() && !fcc.isRefreshingTransientBuild())

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/DecorateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/DecorateHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/DecorateHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/DecorateHandler.java Mon Nov 24 20:35:02 2014
@@ -137,109 +137,114 @@ public final class DecorateHandler exten
         actx.pushClient(this);
         FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
         String uniqueId = null;
-        if (!_template.isLiteral())
-        {
-            uniqueId = actx.generateUniqueFaceletTagId(
-                fcc.startComponentUniqueIdSection(), tagId);
-        }
-        else if (_params != null)
-        {
-            uniqueId = actx.generateUniqueFaceletTagId(
-                fcc.generateUniqueComponentId(), tagId);
-        }
-        
-        if (_params != null)
+        try
         {
-            //VariableMapper vm = new VariableMapperWrapper(orig);
-            //ctx.setVariableMapper(vm);
-            for (int i = 0; i < _params.length; i++)
+            if (!_template.isLiteral())
             {
-                _params[i].apply(ctx, parent, _params[i].getName(ctx), _params[i].getValue(ctx), uniqueId);
+                uniqueId = actx.generateUniqueFaceletTagId(
+                    fcc.startComponentUniqueIdSection(), tagId);
+            }
+            else if (_params != null)
+            {
+                uniqueId = actx.generateUniqueFaceletTagId(
+                    fcc.generateUniqueComponentId(), tagId);
+            }
+            if (_params != null)
+            {
+                //VariableMapper vm = new VariableMapperWrapper(orig);
+                //ctx.setVariableMapper(vm);
+                for (int i = 0; i < _params.length; i++)
+                {
+                    _params[i].apply(ctx, parent, _params[i].getName(ctx), _params[i].getValue(ctx), uniqueId);
+                }
             }
-        }
 
-        String path;
-        boolean markInitialState = false;
-        if (!_template.isLiteral())
-        {
-            //String uniqueId = fcc.startComponentUniqueIdSection();
-            //path = getTemplateValue(actx, fcc, parent, uniqueId);
-            String restoredPath = (String) ComponentSupport.restoreInitialTagState(ctx, fcc, parent, uniqueId);
-            if (restoredPath != null)
-            {
-                // If is not restore view phase, the path value should be
-                // evaluated and if is not equals, trigger markInitialState stuff.
-                if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
+            String path;
+            boolean markInitialState = false;
+            if (!_template.isLiteral())
+            {
+                //String uniqueId = fcc.startComponentUniqueIdSection();
+                //path = getTemplateValue(actx, fcc, parent, uniqueId);
+                String restoredPath = (String) ComponentSupport.restoreInitialTagState(ctx, fcc, parent, uniqueId);
+                if (restoredPath != null)
                 {
-                    path = this._template.getValue(ctx);
-                    if (path == null || path.length() == 0)
+                    // If is not restore view phase, the path value should be
+                    // evaluated and if is not equals, trigger markInitialState stuff.
+                    if (!PhaseId.RESTORE_VIEW.equals(ctx.getFacesContext().getCurrentPhaseId()))
                     {
-                        return;
+                        path = this._template.getValue(ctx);
+                        if (path == null || path.length() == 0)
+                        {
+                            return;
+                        }
+                        if (!path.equals(restoredPath))
+                        {
+                            markInitialState = true;
+                        }
                     }
-                    if (!path.equals(restoredPath))
+                    else
                     {
-                        markInitialState = true;
+                        path = restoredPath;
                     }
                 }
                 else
                 {
-                    path = restoredPath;
+                    //No state restored, calculate path
+                    path = this._template.getValue(ctx);
                 }
+                ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, path);
             }
             else
             {
-                //No state restored, calculate path
-                path = this._template.getValue(ctx);
-            }
-            ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, path);
-        }
-        else
-        {
-            path = _template.getValue(ctx);
-        }
-        try
-        {
-            boolean oldMarkInitialState = false;
-            Boolean isBuildingInitialState = null;
-            if (markInitialState)
-            {
-                //set markInitialState flag
-                oldMarkInitialState = fcc.isMarkInitialState();
-                fcc.setMarkInitialState(true);
-                isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
-                        StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
+                path = _template.getValue(ctx);
             }
             try
             {
-                ctx.includeFacelet(parent, path);
-            }
-            finally
-            {
+                boolean oldMarkInitialState = false;
+                Boolean isBuildingInitialState = null;
                 if (markInitialState)
                 {
-                    //unset markInitialState flag
-                    if (isBuildingInitialState == null)
-                    {
-                        ctx.getFacesContext().getAttributes().remove(
-                                StateManager.IS_BUILDING_INITIAL_STATE);
-                    }
-                    else
+                    //set markInitialState flag
+                    oldMarkInitialState = fcc.isMarkInitialState();
+                    fcc.setMarkInitialState(true);
+                    isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
+                            StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
+                }
+                try
+                {
+                    ctx.includeFacelet(parent, path);
+                }
+                finally
+                {
+                    if (markInitialState)
                     {
-                        ctx.getFacesContext().getAttributes().put(
-                                StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        //unset markInitialState flag
+                        if (isBuildingInitialState == null)
+                        {
+                            ctx.getFacesContext().getAttributes().remove(
+                                    StateManager.IS_BUILDING_INITIAL_STATE);
+                        }
+                        else
+                        {
+                            ctx.getFacesContext().getAttributes().put(
+                                    StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        }
+                        fcc.setMarkInitialState(oldMarkInitialState);
                     }
-                    fcc.setMarkInitialState(oldMarkInitialState);
                 }
             }
+            finally
+            {
+                //ctx.setVariableMapper(orig);
+                actx.popClient(this);
+            }
         }
         finally
         {
-            //ctx.setVariableMapper(orig);
-            actx.popClient(this);
-        }
-        if (!_template.isLiteral())
-        {
-            fcc.endComponentUniqueIdSection();
+            if (!_template.isLiteral())
+            {
+                fcc.endComponentUniqueIdSection();
+            }
         }
         if (!_template.isLiteral() && fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() &&
             !fcc.isRefreshingTransientBuild())

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/LegacyDecorateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/LegacyDecorateHandler.java?rev=1641470&r1=1641469&r2=1641470&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/LegacyDecorateHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/ui/LegacyDecorateHandler.java Mon Nov 24 20:35:02 2014
@@ -179,47 +179,53 @@ public final class LegacyDecorateHandler
         }
         try
         {
-            boolean oldMarkInitialState = false;
-            Boolean isBuildingInitialState = null;
-            if (markInitialState)
-            {
-                //set markInitialState flag
-                oldMarkInitialState = fcc.isMarkInitialState();
-                fcc.setMarkInitialState(true);
-                isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
-                        StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
-            }
             try
             {
-                ctx.includeFacelet(parent, path);
-            }
-            finally
-            {
+                boolean oldMarkInitialState = false;
+                Boolean isBuildingInitialState = null;
                 if (markInitialState)
                 {
-                    //unset markInitialState flag
-                    if (isBuildingInitialState == null)
-                    {
-                        ctx.getFacesContext().getAttributes().remove(
-                                StateManager.IS_BUILDING_INITIAL_STATE);
-                    }
-                    else
+                    //set markInitialState flag
+                    oldMarkInitialState = fcc.isMarkInitialState();
+                    fcc.setMarkInitialState(true);
+                    isBuildingInitialState = (Boolean) ctx.getFacesContext().getAttributes().put(
+                            StateManager.IS_BUILDING_INITIAL_STATE, Boolean.TRUE);
+                }
+                try
+                {
+                    ctx.includeFacelet(parent, path);
+                }
+                finally
+                {
+                    if (markInitialState)
                     {
-                        ctx.getFacesContext().getAttributes().put(
-                                StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        //unset markInitialState flag
+                        if (isBuildingInitialState == null)
+                        {
+                            ctx.getFacesContext().getAttributes().remove(
+                                    StateManager.IS_BUILDING_INITIAL_STATE);
+                        }
+                        else
+                        {
+                            ctx.getFacesContext().getAttributes().put(
+                                    StateManager.IS_BUILDING_INITIAL_STATE, isBuildingInitialState);
+                        }
+                        fcc.setMarkInitialState(oldMarkInitialState);
                     }
-                    fcc.setMarkInitialState(oldMarkInitialState);
                 }
             }
+            finally
+            {
+                ctx.setVariableMapper(orig);
+                actx.popClient(this);
+            }
         }
         finally
         {
-            ctx.setVariableMapper(orig);
-            actx.popClient(this);
-        }
-        if (!_template.isLiteral())
-        {
-            fcc.endComponentUniqueIdSection();
+            if (!_template.isLiteral())
+            {
+                fcc.endComponentUniqueIdSection();
+            }
         }
         if (!_template.isLiteral() && fcc.isUsingPSSOnThisView() && fcc.isRefreshTransientBuildOnPSS() &&
             !fcc.isRefreshingTransientBuild())