You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2009/10/23 01:54:28 UTC

svn commit: r828894 - /myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java

Author: matzew
Date: Thu Oct 22 23:54:27 2009
New Revision: 828894

URL: http://svn.apache.org/viewvc?rev=828894&view=rev
Log:
some refactorings 

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=828894&r1=828893&r2=828894&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Thu Oct 22 23:54:27 2009
@@ -162,20 +162,7 @@
                 //Component / Facet removed, set to false
                 //isInView to all parent and children
                 preRemoveFromViewEvent = true;
-                this.setInView(false);
-                if (this.getChildCount() > 0)
-                {
-                    for (Iterator<UIComponent> it = this.getFacetsAndChildren();
-                        it.hasNext();)
-                    {
-                        UIComponent comp = it.next();
-                        if (comp.isInView())
-                        {
-                            //Change to false all descendants
-                            _updateChild(comp,false);
-                        }
-                    }
-                }
+                _delegateInViewState(this, false);
             }
             //else
             //{
@@ -190,21 +177,8 @@
             {
                 //Component / Facet added, set to true
                 //isInView to all parent and children
-                this.setInView(true);
                 postAddToViewEvent = true;
-                if (this.getChildCount() > 0)
-                {
-                    for (Iterator<UIComponent> it = this.getFacetsAndChildren();
-                        it.hasNext();)
-                    {
-                        UIComponent comp = it.next();
-                        if (!comp.isInView())
-                        {
-                            //Change to false all descendants
-                            _updateChild(comp,true);
-                        }
-                    }
-                }
+                _delegateInViewState(this, true);
             }
             //else
             //{
@@ -216,7 +190,6 @@
         _parent = parent;
         
         FacesContext context = getFacesContext();
-        
         if (postAddToViewEvent)
         {
             // After the child component has been added to the view, if the following condition is not met
@@ -236,6 +209,25 @@
         }
     }
 
+    private void _delegateInViewState(UIComponent component, boolean inViewState)
+    {
+      component.setInView(inViewState);
+      if (component.getChildCount() > 0)
+      {
+          for (Iterator<UIComponent> it = component.getFacetsAndChildren();
+              it.hasNext();)
+          {
+              UIComponent comp = it.next();
+              // can we do that directly ?
+              if (comp.isInView() != inViewState)
+              {
+                  //Change to false all descendants
+                  _updateChild(comp,inViewState);
+              }
+          }
+      }
+    }
+    
     /**
      * Publish PostAddToViewEvent to the component and all facets and children.
      *