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 2010/05/21 23:37:51 UTC
svn commit: r947184 - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets:
FaceletViewDeclarationLanguage.java compiler/UIInstructionHandler.java
tag/composite/InsertChildrenHandler.java
tag/jsf/ComponentTagHandlerDelegate.java
Author: lu4242
Date: Fri May 21 21:37:50 2010
New Revision: 947184
URL: http://svn.apache.org/viewvc?rev=947184&view=rev
Log:
MYFACES-2638 Fix PostAddToViewEvent and PreRemoveFromViewEvent publishing conditions (allow PostAddToViewEvent/PreRemoveFromViewEvent to be activated if the component is not being refreshed)
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/InsertChildrenHandler.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=947184&r1=947183&r2=947184&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java Fri May 21 21:37:50 2010
@@ -295,7 +295,10 @@ public class FaceletViewDeclarationLangu
{
context.getAttributes().put(REFRESHING_TRANSIENT_BUILD, Boolean.TRUE);
- context.setProcessingEvents(false);
+ // In theory, this should be disabled on ComponentTagHandlerDelegate,
+ // otherwise we could lost PostAddToViewEvent / PreRemoveFromViewEvent
+ // caused by c:if effect or facelets cleanup algorithm
+ //context.setProcessingEvents(false);
}
// populate UIViewRoot
_getFacelet(renderedViewId).apply(context, view);
@@ -308,7 +311,7 @@ public class FaceletViewDeclarationLangu
}
if (refreshTransientBuild)
{
- context.setProcessingEvents(true);
+ //context.setProcessingEvents(true);
if (!usePartialStateSavingOnThisView || refreshTransientBuildOnPSS)
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java?rev=947184&r1=947183&r2=947184&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java Fri May 21 21:37:50 2010
@@ -182,13 +182,23 @@ final class UIInstructionHandler extends
}
c.getAttributes().put(ComponentSupport.MARK_CREATED, id);
}
+
+ boolean oldProcessingEvents = ctx.getFacesContext().isProcessingEvents();
// finish cleaning up orphaned children
if (componentFound)
{
ComponentSupport.finalizeForDeletion(c);
if (!componentFoundInserted)
{
+ if (mctx.isRefreshingTransientBuild())
+ {
+ ctx.getFacesContext().setProcessingEvents(false);
+ }
parent.getChildren().remove(c);
+ if (mctx.isRefreshingTransientBuild())
+ {
+ ctx.getFacesContext().setProcessingEvents(oldProcessingEvents);
+ }
}
}
if ( mctx.isRefreshingTransientBuild()
@@ -231,7 +241,15 @@ final class UIInstructionHandler extends
}
if (!componentFoundInserted)
{
+ if (componentFound && mctx.isRefreshingTransientBuild())
+ {
+ ctx.getFacesContext().setProcessingEvents(false);
+ }
this.addComponent(ctx, parent, c);
+ if (componentFound && mctx.isRefreshingTransientBuild())
+ {
+ ctx.getFacesContext().setProcessingEvents(oldProcessingEvents);
+ }
}
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/InsertChildrenHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/InsertChildrenHandler.java?rev=947184&r1=947183&r2=947184&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/InsertChildrenHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/InsertChildrenHandler.java Fri May 21 21:37:50 2010
@@ -66,13 +66,23 @@ public class InsertChildrenHandler exten
//Prevent deletion of components present on parentCompositeComponent. This components will not be changed.
List<UIComponent> childList = new ArrayList<UIComponent>(parent.getChildren());
+ boolean oldProcessingEvents = ctx.getFacesContext().isProcessingEvents();
+
for (UIComponent tcChild : childList)
{
if (tcChild.getAttributes().remove(USES_INSERT_CHILDREN) != null)
{
ComponentSupport.finalizeForDeletion(tcChild);
- parent.getChildren().remove(tcChild);
- parent.getChildren().add(tcChild);
+ ctx.getFacesContext().setProcessingEvents(false);
+ try
+ {
+ parent.getChildren().remove(tcChild);
+ parent.getChildren().add(tcChild);
+ }
+ finally
+ {
+ ctx.getFacesContext().setProcessingEvents(oldProcessingEvents);
+ }
}
}
return;
@@ -118,7 +128,7 @@ public class InsertChildrenHandler exten
//All composite components are NamingContainer and the target is inside it, so we can remove the prefix.
_targetComponent = parentCompositeComponent.findComponent(_targetClientId.substring(parentCompositeComponent.getClientId().length()+1));
}
-
+
if (parentCompositeComponent.getChildCount() <= 0)
{
return;
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=947184&r1=947183&r2=947184&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Fri May 21 21:37:50 2010
@@ -263,6 +263,7 @@ public class ComponentTagHandlerDelegate
// first allow c to get populated
_delegate.applyNextHandler(ctx, c);
+ boolean oldProcessingEvents = facesContext.isProcessingEvents();
// finish cleaning up orphaned children
if (componentFound)
{
@@ -270,6 +271,10 @@ public class ComponentTagHandlerDelegate
if (!componentFoundInserted)
{
+ if (mctx.isRefreshingTransientBuild())
+ {
+ facesContext.setProcessingEvents(false);
+ }
if (facetName == null)
{
parent.getChildren().remove(c);
@@ -278,6 +283,10 @@ public class ComponentTagHandlerDelegate
{
ComponentSupport.removeFacet(ctx, parent, c, facetName);
}
+ if (mctx.isRefreshingTransientBuild())
+ {
+ facesContext.setProcessingEvents(oldProcessingEvents);
+ }
}
}
@@ -345,6 +354,10 @@ public class ComponentTagHandlerDelegate
// add to the tree afterwards
// this allows children to determine if it's
// been part of the tree or not yet
+ if (componentFound && mctx.isRefreshingTransientBuild())
+ {
+ facesContext.setProcessingEvents(false);
+ }
if (facetName == null)
{
parent.getChildren().add(c);
@@ -353,6 +366,10 @@ public class ComponentTagHandlerDelegate
{
ComponentSupport.addFacet(ctx, parent, c, facetName);
}
+ if (componentFound && mctx.isRefreshingTransientBuild())
+ {
+ facesContext.setProcessingEvents(oldProcessingEvents);
+ }
}
/*
else