myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1215287 - in /myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component: UIData.java UIViewRoot.java
Date Fri, 16 Dec 2011 21:28:10 GMT
Author: lu4242
Date: Fri Dec 16 21:28:10 2011
New Revision: 1215287

URL: http://svn.apache.org/viewvc?rev=1215287&view=rev
Log:
MYFACES-3424 call popComponentFromEL from right instance when broadcast

Modified:
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java?rev=1215287&r1=1215286&r2=1215287&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIData.java Fri Dec
16 21:28:10 2011
@@ -247,7 +247,9 @@ public class UIData extends UIComponentB
         public void setRowIndex(int i)
         {
             if (i < -1)
+            {
                 throw new IllegalArgumentException();
+            }
         }
 
         @Override
@@ -406,9 +408,12 @@ public class UIData extends UIComponentB
                         UIComponent child = itChildren.next();
                         if (child instanceof UIColumn && clientId.equals(child.getClientId(context)))
                         {
-                            try {
+                            try
+                            {
                                 callback.invokeContextCallback(context, child);
-                            } catch (Exception e) {
+                            }
+                            catch (Exception e)
+                            {
                                 throw new FacesException(e);
                             }
                             returnValue = true;
@@ -714,7 +719,8 @@ public class UIData extends UIComponentB
      * @param iterateFacets
      * @param restoreChildFacets 
      */
-    private void restoreDescendantComponentWithoutRestoreState(UIComponent parent, boolean
iterateFacets, boolean restoreChildFacets)
+    private void restoreDescendantComponentWithoutRestoreState(UIComponent parent, boolean
iterateFacets,
+                                                               boolean restoreChildFacets)
     {
         if (iterateFacets && parent.getFacetCount() > 0)
         {
@@ -1033,10 +1039,10 @@ public class UIData extends UIComponentB
             }
             finally
             {
-                popComponentFromEL(getFacesContext());
+                source.popComponentFromEL(getFacesContext());
                 if (compositeParent != null)
                 {
-                    popComponentFromEL(getFacesContext());
+                    compositeParent.popComponentFromEL(getFacesContext());
                 }
                 setRowIndex(currentRowIndex);
             }
@@ -1361,7 +1367,8 @@ public class UIData extends UIComponentB
      * <p>
      * This is complicated by the fact that this table may be nested within another table.
In this case a different
      * datamodel should be fetched for each row. When nested within a parent table, the parent
reference won't change
-     * but parent.getContainerClientId() will, as the suffix changes depending upon the current
row index. A map object on this
+     * but parent.getContainerClientId() will, as the suffix changes
+     * depending upon the current row index. A map object on this
      * component is therefore used to cache the datamodel for each row of the table. In the
normal case where this table
      * is not nested inside a component that changes its id (like a table does) then this
map only ever has one entry.
      */
@@ -1590,9 +1597,11 @@ public class UIData extends UIComponentB
                     if (skipIterationHint != null && skipIterationHint.booleanValue())
                     {
                         // If SKIP_ITERATION is enabled, do not take into account rows.
-                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++ ) {
+                        for (int i = 0, childCount = getChildCount(); i < childCount;
i++ )
+                        {
                             UIComponent child = getChildren().get(i);
-                            if (child.visitTree(context, callback)) {
+                            if (child.visitTree(context, callback))
+                            {
                                 return true;
                             }
                         }

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java?rev=1215287&r1=1215286&r2=1215287&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java Fri
Dec 16 21:28:10 2011
@@ -155,7 +155,8 @@ public class UIViewRoot extends UICompon
         // Call getComponentResources to obtain the child list for the given target
         List<UIComponent> componentResources = _getComponentResources(context, target);
 
-        // If the component ID of componentResource matches the ID of a resource that has
already been added, remove the old resource.
+        // If the component ID of componentResource matches the ID of a resource
+        // that has already been added, remove the old resource.
         String componentId = componentResource.getId();
         
         if (componentId == null)
@@ -233,7 +234,9 @@ public class UIViewRoot extends UICompon
     public void addPhaseListener(PhaseListener phaseListener)
     {
         if (phaseListener == null)
+        {
             throw new NullPointerException("phaseListener");
+        }
         
         getStateHelper().add(PropertyKeys.phaseListeners, phaseListener);
     }
@@ -251,7 +254,8 @@ public class UIViewRoot extends UICompon
         Events events = _getEvents(phaseId);
         
         // Spec. 3.4.2.6 Event Broadcasting:
-        // Queue one or more additional events, from the same source component or a different
one, for processing during the
+        // Queue one or more additional events, from the same source
+        // component or a different one, for processing during the
         // current lifecycle phase.
         
         // Unfortunately with that requirement it is easy to create infinite loop in processing.
One example can be:
@@ -271,7 +275,7 @@ public class UIViewRoot extends UICompon
         {
             // First broadcast events that have been queued for PhaseId.ANY_PHASE.
             _broadcastAll(context, events.getAnyPhase(), eventsAborted);
-            Collection<FacesEvent> eventsOnPhase = events.getOnPhase();
+            List<FacesEvent> eventsOnPhase = events.getOnPhase();
             if (!eventsAborted.isEmpty())
             {
                 eventsOnPhase.removeAll(eventsAborted);
@@ -284,11 +288,13 @@ public class UIViewRoot extends UICompon
             
         } while (events.hasMoreEvents() && loops < maxLoops);
         
-        if (loops == maxLoops && events.hasMoreEvents()) {
+        if (loops == maxLoops && events.hasMoreEvents())
+        {
             // broadcast reach maxLoops - probably a infinitive recursion:
             boolean production = getFacesContext().isProjectStage(ProjectStage.Production);
             Level level = production ? Level.FINE : Level.WARNING;
-            if (logger.isLoggable(level)) {
+            if (logger.isLoggable(level))
+            {
                 List<String> name = new ArrayList<String>(events.getAnyPhase().size()
+ events.getOnPhase().size());
                 for (FacesEvent facesEvent : events.getAnyPhase())
                 {
@@ -300,7 +306,8 @@ public class UIViewRoot extends UICompon
                     String clientId = facesEvent.getComponent().getClientId(getFacesContext());
                     name.add(clientId);
                 }
-                logger.log(level, "Event broadcating for PhaseId {0} at UIViewRoot {1} reaches
maximal limit, please check " +
+                logger.log(level,
+                        "Event broadcating for PhaseId {0} at UIViewRoot {1} reaches maximal
limit, please check " +
                         "listeners for infinite recursion. Component id: {2}",
                         new Object [] {phaseId, getViewId(), name});
             }
@@ -329,12 +336,14 @@ public class UIViewRoot extends UICompon
         Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter);
         uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
         getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L));
-        // Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX,
and will be unique within this UIViewRoot. 
+        // Generate an identifier for a component. The identifier will be prefixed with
+        // UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot.
         if(seed==null)
         {
             return bld.append(UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString();    
         }
-        // Optionally, a unique seed value can be supplied by component creators which should
be included in the generated unique id.
+        // Optionally, a unique seed value can be supplied by component creators which
+        // should be included in the generated unique id.
         else
         {
             return bld.append(UNIQUE_ID_PREFIX).append(seed).toString();
@@ -416,10 +425,12 @@ public class UIViewRoot extends UICompon
             PartialViewContext partialContext = context.getPartialViewContext();
             if (!partialContext.isAjaxRequest())
             {
-                ViewDeclarationLanguage vdl = context.getApplication().getViewHandler().getViewDeclarationLanguage(context,
getViewId());
+                ViewDeclarationLanguage vdl
+                        = context.getApplication().getViewHandler().getViewDeclarationLanguage(context,
getViewId());
                 if (vdl != null)
                 {
-                    // If the current view has view parameters, as indicated by a non-empty
and non-UnsupportedOperationException throwing 
+                    // If the current view has view parameters, as indicated by a non-empty
+                    // and non-UnsupportedOperationException throwing
                     // return from ViewDeclarationLanguage.getViewMetadata(javax.faces.context.FacesContext,
String)
                     ViewMetadata metadata = null;
                     try
@@ -447,7 +458,8 @@ public class UIViewRoot extends UICompon
                         }
                         catch(UnsupportedOperationException e)
                         {
-                            // If calling getViewParameters() causes UnsupportedOperationException
to be thrown, the exception must be silently swallowed.
+                            // If calling getViewParameters() causes UnsupportedOperationException
+                            // to be thrown, the exception must be silently swallowed.
                         }
                     }
                 }
@@ -471,7 +483,8 @@ public class UIViewRoot extends UICompon
      *
      * @return the new afterPhaseListener value
      */
-    @JSFProperty(returnSignature = "void", methodSignature = "javax.faces.event.PhaseEvent",
jspName = "afterPhase", stateHolder=true)
+    @JSFProperty(returnSignature = "void", methodSignature = "javax.faces.event.PhaseEvent",
+                 jspName = "afterPhase", stateHolder=true)
     public MethodExpression getAfterPhaseListener()
     {
         return (MethodExpression) getStateHelper().eval(PropertyKeys.afterPhaseListener);
@@ -483,7 +496,8 @@ public class UIViewRoot extends UICompon
      *
      * @return the new beforePhaseListener value
      */
-    @JSFProperty(returnSignature = "void", methodSignature = "javax.faces.event.PhaseEvent",
jspName = "beforePhase", stateHolder=true)
+    @JSFProperty(returnSignature = "void", methodSignature = "javax.faces.event.PhaseEvent",
+                 jspName = "beforePhase", stateHolder=true)
     public MethodExpression getBeforePhaseListener()
     {
         return (MethodExpression) getStateHelper().eval(PropertyKeys.beforePhaseListener);
@@ -514,7 +528,8 @@ public class UIViewRoot extends UICompon
         // If the facet is not found,
         if (facet == null)
         {
-            // create the facet by calling context.getApplication().createComponent()  using
javax.faces.Panel as the argument
+            // create the facet by calling context.getApplication().createComponent()
+            // using javax.faces.Panel as the argument
             facet = context.getApplication().createComponent("javax.faces.Panel");
 
             // Set the id of the facet to be target
@@ -525,7 +540,8 @@ public class UIViewRoot extends UICompon
         }
 
         // Return the children of the facet
-        // The API doc indicates that this method should "Return an unmodifiable List of
UIComponents for the provided target argument."
+        // The API doc indicates that this method should "Return an unmodifiable
+        // List of UIComponents for the provided target argument."
         // and also that "If no children are found for the facet, return Collections.emptyList()."
         List<UIComponent> children = facet.getChildren();
         return ( children == null ? Collections.<UIComponent>emptyList() : Collections.unmodifiableList(children)
);
@@ -552,7 +568,8 @@ public class UIViewRoot extends UICompon
         // If the facet is not found,
         if (facet == null)
         {
-            // create the facet by calling context.getApplication().createComponent()  using
javax.faces.Panel as the argument
+            // create the facet by calling context.getApplication().createComponent()
+            // using javax.faces.Panel as the argument
             facet = context.getApplication().createComponent("javax.faces.ComponentResourceContainer");
 
             // Set the id of the facet to be target
@@ -819,7 +836,8 @@ public class UIViewRoot extends UICompon
                 beforePhaseSuccess = new boolean[listenerCount];
                 listenerSuccessMap.put(phaseId, beforePhaseSuccess);
             }
-            else {
+            else
+            {
                 // afterPhase - get beforePhaseSuccess from the Map
                 beforePhaseSuccess = listenerSuccessMap.get(phaseId);
                 if (beforePhaseSuccess == null)
@@ -849,7 +867,8 @@ public class UIViewRoot extends UICompon
                                              " in Phase " + phaseId, t);
                     if (beforePhase)
                     {
-                        return context.getResponseComplete() || (context.getRenderResponse()
&& !PhaseId.RENDER_RESPONSE.equals(phaseId));
+                        return context.getResponseComplete() ||
+                                (context.getRenderResponse() && !PhaseId.RENDER_RESPONSE.equals(phaseId));
                     }
                 }
             }
@@ -892,7 +911,8 @@ public class UIViewRoot extends UICompon
                                 logger.log(Level.SEVERE, "An Exception occured while processing
the " +
                                                          "beforePhase method of PhaseListener
" + phaseListener +
                                                          " in Phase " + phaseId, t);
-                                return context.getResponseComplete() || (context.getRenderResponse()
&& !PhaseId.RENDER_RESPONSE.equals(phaseId));
+                                return context.getResponseComplete() ||
+                                        (context.getRenderResponse() && !PhaseId.RENDER_RESPONSE.equals(phaseId));
                             }
                         }
                     }
@@ -937,7 +957,8 @@ public class UIViewRoot extends UICompon
 
         if (beforePhase)
         {
-            return context.getResponseComplete() || (context.getRenderResponse() &&
!PhaseId.RENDER_RESPONSE.equals(phaseId));
+            return context.getResponseComplete() ||
+                    (context.getRenderResponse() && !PhaseId.RENDER_RESPONSE.equals(phaseId));
         }
         else
         {
@@ -969,12 +990,15 @@ public class UIViewRoot extends UICompon
      *
      * @return <code>true</code> if the broadcast was completed without abortion,
<code>false</code> otherwise
      */
-    private void _broadcastAll(FacesContext context, Collection<? extends FacesEvent>
events, Collection<FacesEvent> eventsAborted)
+    private void _broadcastAll(FacesContext context,
+                               List<? extends FacesEvent> events,
+                               Collection<FacesEvent> eventsAborted)
     {
         assert events != null;
 
-        for (FacesEvent event : events)
+        for (int i = 0; i < events.size(); i++)
         {
+            FacesEvent event = events.get(i);
             UIComponent source = event.getComponent();
             UIComponent compositeParent = UIComponent.getCompositeComponentParent(source);
             if (compositeParent != null)
@@ -1002,10 +1026,10 @@ public class UIViewRoot extends UICompon
             finally
             {
                 // Restore the current component
-                popComponentFromEL(context);
+                source.popComponentFromEL(context);
                 if (compositeParent != null)
                 {
-                    popComponentFromEL(context);
+                    compositeParent.popComponentFromEL(context);
                 }
             }
         }
@@ -1127,7 +1151,9 @@ public class UIViewRoot extends UICompon
     public void removePhaseListener(PhaseListener phaseListener)
     {
         if (phaseListener == null)
+        {
             return;
+        }
 
         getStateHelper().remove(PropertyKeys.phaseListeners, phaseListener);
     }
@@ -1222,7 +1248,8 @@ public class UIViewRoot extends UICompon
         
         listeners = _systemEventListeners.get (systemEvent);
         
-        if (listeners == null) {
+        if (listeners == null)
+        {
             listeners = new ArrayList<SystemEventListener>();
             
             _systemEventListeners.put (systemEvent, listeners);
@@ -1241,7 +1268,8 @@ public class UIViewRoot extends UICompon
         
         listeners = _systemEventListeners.get (systemEvent);
         
-        if (listeners != null) {
+        if (listeners != null)
+        {
             listeners.remove (listener);
         }
     }
@@ -1320,7 +1348,8 @@ public class UIViewRoot extends UICompon
      * Gathers all event for current and ANY phase
      * @param phaseId current phase id
      */
-    private Events _getEvents(PhaseId phaseId) {
+    private Events _getEvents(PhaseId phaseId)
+    {
         // Gather the events and purge the event list to prevent concurrent modification
during broadcasting
         List<FacesEvent> anyPhase = new ArrayList<FacesEvent>(
                 _events.size());
@@ -1354,15 +1383,19 @@ public class UIViewRoot extends UICompon
         public void process(FacesContext context, UIViewRoot root)
         {
             PartialViewContext pvc = context.getPartialViewContext();
-            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
with PhaseId.UPDATE_MODEL_VALUES if:
-            //   * PartialViewContext.isPartialRequest() returns true and we don't have a
request to process all components in the view (PartialViewContext.isExecuteAll() returns false)
+            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
+            // with PhaseId.UPDATE_MODEL_VALUES if:
+            //   * PartialViewContext.isPartialRequest() returns true and we don't have a
request to process all
+            // components in the view (PartialViewContext.isExecuteAll() returns false)
             //section 13.4.2 from the  JSF2  spec also see https://issues.apache.org/jira/browse/MYFACES-2119
             if (pvc.isPartialRequest() && !pvc.isExecuteAll())
             {
                 pvc.processPartial(PhaseId.APPLY_REQUEST_VALUES);
             }
-            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
if one of the following conditions are met:
-            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components in the view (PartialViewContext.isExecuteAll() returns true)
+            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
+            // if one of the following conditions are met:
+            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components
+            // in the view (PartialViewContext.isExecuteAll() returns true)
             // *   PartialViewContext.isPartialRequest() returns false
             else
             {
@@ -1376,15 +1409,19 @@ public class UIViewRoot extends UICompon
         public void process(FacesContext context, UIViewRoot root)
         {
             PartialViewContext pvc = context.getPartialViewContext();
-            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
with PhaseId.UPDATE_MODEL_VALUES if:
-            // PartialViewContext.isPartialRequest() returns true and we don't have a request
to process all components in the view (PartialViewContext.isExecuteAll() returns false)
+            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
+            // with PhaseId.UPDATE_MODEL_VALUES if:
+            // PartialViewContext.isPartialRequest() returns true and we don't have a request
to process all components
+            // in the view (PartialViewContext.isExecuteAll() returns false)
             //section 13.4.2 from the  JSF2  spec also see https://issues.apache.org/jira/browse/MYFACES-2119
             if (pvc.isPartialRequest() && !pvc.isExecuteAll())
             {
                 pvc.processPartial(PhaseId.PROCESS_VALIDATIONS);
             }
-            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
if one of the following conditions are met:
-            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components in the view (PartialViewContext.isExecuteAll() returns true)
+            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
+            // if one of the following conditions are met:
+            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components
+            // in the view (PartialViewContext.isExecuteAll() returns true)
             // *   PartialViewContext.isPartialRequest() returns false
             else
             {
@@ -1398,15 +1435,19 @@ public class UIViewRoot extends UICompon
         public void process(FacesContext context, UIViewRoot root)
         {
             PartialViewContext pvc = context.getPartialViewContext();
-            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
with PhaseId.UPDATE_MODEL_VALUES if:
-            //   * PartialViewContext.isPartialRequest() returns true and we don't have a
request to process all components in the view (PartialViewContext.isExecuteAll() returns false)
+            // Perform partial processing by calling PartialViewContext.processPartial(javax.faces.event.PhaseId)
+            // with PhaseId.UPDATE_MODEL_VALUES if:
+            //   * PartialViewContext.isPartialRequest() returns true and we don't have a
request to process
+            // all components in the view (PartialViewContext.isExecuteAll() returns false)
             //section 13.4.2 from the JSF2 spec also see https://issues.apache.org/jira/browse/MYFACES-2119
             if (pvc.isPartialRequest() && !pvc.isExecuteAll())
             {
                 pvc.processPartial(PhaseId.UPDATE_MODEL_VALUES);
             }
-            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
if one of the following conditions are met:
-            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components in the view (PartialViewContext.isExecuteAll() returns true)
+            // Perform full processing by calling UIComponentBase.processUpdates(javax.faces.context.FacesContext)
+            // if one of the following conditions are met:
+            // *   PartialViewContext.isPartialRequest() returns true and we have a request
to process all components
+            // in the view (PartialViewContext.isExecuteAll() returns true)
             // *   PartialViewContext.isPartialRequest() returns false
             else
             {
@@ -1468,7 +1509,8 @@ public class UIViewRoot extends UICompon
     /**
      * Agregates events for ANY_PHASE and current phase 
      */
-    private class Events {
+    private class Events
+    {
         
         private final List<FacesEvent> _anyPhase;
         



Mime
View raw message