You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2010/07/19 16:03:25 UTC
svn commit: r965489 - in
/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main:
java-templates/org/apache/myfaces/trinidad/component/
java/org/apache/myfaces/trinidad/component/
java/org/apache/myfaces/trinidad/render/
Author: arobinson74
Date: Mon Jul 19 14:03:24 2010
New Revision: 965489
URL: http://svn.apache.org/viewvc?rev=965489&view=rev
Log:
Checkpoint
Modified:
myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java
myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java
myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
Modified: myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java?rev=965489&r1=965488&r2=965489&view=diff
==============================================================================
--- myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java (original)
+++ myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java Mon Jul 19 14:03:24 2010
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,6 +19,7 @@
package org.apache.myfaces.trinidad.component;
import java.io.IOException;
+
import java.util.List;
import javax.faces.component.UIComponent;
@@ -55,19 +56,37 @@ abstract public class UIXGroupTemplate e
) throws IOException
{
cpContext.pushGroup();
-
+
try
{
- // bump up the group depth and render all of the children
- return UIXComponent.processFlattenedChildren(context,
- cpContext,
- childProcessor,
- this.getChildren(),
- callBackContext);
+ setupVisitingContext(context);
+
+ try
+ {
+ setupChildrenVisitingContext(context);
+
+ try
+ {
+ // bump up the group depth and render all of the children
+ return UIXComponent.processFlattenedChildren(context,
+ cpContext,
+ childProcessor,
+ this.getChildren(),
+ callBackContext);
+ }
+ finally
+ {
+ tearDownChildrenVisitingContext(context);
+ }
+ }
+ finally
+ {
+ tearDownVisitingContext(context);
+ }
}
finally
{
- cpContext.popGroup();
+ cpContext.popGroup();
}
}
Modified: myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java?rev=965489&r1=965488&r2=965489&view=diff
==============================================================================
--- myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java (original)
+++ myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java Mon Jul 19 14:03:24 2010
@@ -84,25 +84,37 @@ public abstract class UIXIteratorTemplat
// Mimic what would normally happen in the non-flattening case for encodeBegin():
__processFlattenedChildrenBegin();
- Runner runner = new IndexedRunner(cpContext)
+ setupChildrenVisitingContext(context);
+
+ try
{
- @Override
- protected void process(UIComponent kid, ComponentProcessingContext cpContext) throws IOException
+ Runner runner = new IndexedRunner(cpContext)
{
- childProcessor.processComponent(context, cpContext, kid, callbackContext);
- }
- };
+ @Override
+ protected void process(
+ UIComponent kid,
+ ComponentProcessingContext cpContext
+ ) throws IOException
+ {
+ childProcessor.processComponent(context, cpContext, kid, callbackContext);
+ }
+ };
- processedChildren = runner.run();
- Exception exp = runner.getException();
- if (exp != null)
+ processedChildren = runner.run();
+ Exception exp = runner.getException();
+ if (exp != null)
+ {
+ if (exp instanceof RuntimeException)
+ throw (RuntimeException) exp;
+
+ if (exp instanceof IOException)
+ throw (IOException) exp;
+ throw new IllegalStateException(exp);
+ }
+ }
+ finally
{
- if (exp instanceof RuntimeException)
- throw (RuntimeException) exp;
-
- if (exp instanceof IOException)
- throw (IOException) exp;
- throw new IllegalStateException(exp);
+ tearDownChildrenVisitingContext(context);
}
}
finally
Modified: myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java?rev=965489&r1=965488&r2=965489&view=diff
==============================================================================
--- myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java (original)
+++ myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java Mon Jul 19 14:03:24 2010
@@ -81,16 +81,36 @@ abstract public class UIXSwitcherTemplat
final ComponentProcessor<S> childProcessor,
final S callbackContext) throws IOException
{
+ setupVisitingContext(context);
+
UIComponent facet = _getFacet();
- if (facet != null)
- return UIXComponent.processFlattenedChildren(context,
- cpContext,
- childProcessor,
- facet,
- callbackContext);
- else
- return false;
+ try
+ {
+ if (facet != null)
+ {
+ setupChildrenVisitingContext(context);
+
+ try
+ {
+ return UIXComponent.processFlattenedChildren(context,
+ cpContext,
+ childProcessor,
+ facet,
+ callbackContext);
+ }
+ finally
+ {
+ tearDownChildrenVisitingContext(context);
+ }
+ }
+ else
+ return false;
+ }
+ finally
+ {
+ tearDownChildrenVisitingContext(context);
+ }
}
/**
Modified: myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=965489&r1=965488&r2=965489&view=diff
==============================================================================
--- myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Mon Jul 19 14:03:24 2010
@@ -505,7 +505,33 @@ abstract public class UIXComponent exten
if (uixComponent != null)
{
- return uixComponent.visitChildren(visitContext, callback);
+ // setup any context needed for visiting the children of the component as opposed
+ // to the component itself
+ if (rc != null)
+ {
+ uixComponent.setupChildrenEncodingContext(facesContext, rc);
+ }
+ else
+ {
+ uixComponent.setupChildrenVisitingContext(facesContext);
+ }
+
+ try
+ {
+ return uixComponent.visitChildren(visitContext, callback);
+ }
+ finally
+ {
+ // teardown any context initialized above
+ if (rc != null)
+ {
+ uixComponent.tearDownChildrenEncodingContext(facesContext, rc);
+ }
+ else
+ {
+ uixComponent.tearDownChildrenVisitingContext(facesContext);
+ }
+ }
}
else
{
@@ -722,6 +748,23 @@ abstract public class UIXComponent exten
}
/**
+ * <p>Sets up the context necessary to visit or invoke the children of a component for all phases.
+ * </p>
+ * <p>The default implementation does nothing.</p>
+ * <p>If a subclass overrides this method, it should override
+ * <code>tearDownChildrenVisitingContext</code> as well.</p>
+ * <p>It is guaranteed that if <code>setupChildrenVisitingContext</code> completes
+ * <code>tearDownChildrenVisitingContext</code> will be called for this component</p>
+ * @param context FacesContext
+ * @see #visitChildren
+ * @see #tearDownChildrenVisitingContext
+ */
+ protected void setupChildrenVisitingContext(@SuppressWarnings("unused") FacesContext context)
+ {
+ // do nothing
+ }
+
+ /**
* <p>Tears down context created in order to visit or invoke the component
* for all phases.</p>
* <p>The default implementation does nothing.</p>
@@ -739,6 +782,23 @@ abstract public class UIXComponent exten
}
/**
+ * <p>Tears down context created in order to visit or invoke the children of a component
+ * for all phases.</p>
+ * <p>The default implementation does nothing.</p>
+ * <p>A subclass should only override this method if it overrode
+ * <code>setupChildrenVisitingContext</code> as well</p>
+ * <p>It is guaranteed that <code>tearDownChildrenVisitingContext</code> will be called only after
+ * <code>setupChildrenVisitingContext</code> has been called for this component</p>
+ * @param context FacesContext
+ * @see #setupChildrenVisitingContext
+ * @see #visitChildren
+ */
+ protected void tearDownChildrenVisitingContext(@SuppressWarnings("unused") FacesContext context)
+ {
+ // do nothing
+ }
+
+ /**
* <p>Sets up the context necessary to encode the component.</p>
* <p>The default implementation delegates to
* <code>CoreRenderer.setupEncodingContext</code> and then calls
@@ -767,6 +827,28 @@ abstract public class UIXComponent exten
}
/**
+ * Sets the context necessary to encode the children of a component.
+ * @param context The FacesContext
+ * @param rc RenderingContext to use for encoding
+ * @see #setupChildrenVisitingContext
+ * @see #tearDownChildrenEncodingContext
+ * @see org.apache.myfaces.trinidad.render.CoreRenderer#setupChildrenEncodingContext
+ */
+ public void setupChildrenEncodingContext(FacesContext context, RenderingContext rc)
+ {
+ setupChildrenVisitingContext(context);
+
+ Renderer renderer = getRenderer(context);
+
+ if (renderer instanceof CoreRenderer)
+ {
+ CoreRenderer coreRenderer = (CoreRenderer)renderer;
+
+ coreRenderer.setupChildrenEncodingContext(context, rc, this);
+ }
+ }
+
+ /**
* <p>Tears down the context created in order to encode the component</p>
* <p>The default implementation delegates to
* <code>CoreRenderer.tearDownEncodingContext</code> and then calls
@@ -802,6 +884,35 @@ abstract public class UIXComponent exten
}
/**
+ * Tears down the context necessary to encode the children of a component.
+ * @param context The FacesContext
+ * @param rc RenderingContext to use for encoding
+ * @see #setupChildrenVisitingContext
+ * @see #tearDownChildrenEncodingContext
+ * @see org.apache.myfaces.trinidad.render.CoreRenderer#setupChildrenEncodingContext
+ */
+ public void tearDownChildrenEncodingContext(
+ FacesContext context,
+ RenderingContext rc)
+ {
+ Renderer renderer = getRenderer(context);
+
+ try
+ {
+ if (renderer instanceof CoreRenderer)
+ {
+ CoreRenderer coreRenderer = (CoreRenderer)renderer;
+
+ coreRenderer.tearDownChildrenEncodingContext(context, rc, this);
+ }
+ }
+ finally
+ {
+ tearDownChildrenVisitingContext(context);
+ }
+ }
+
+ /**
* Returns the FacesBean used for storing the component's state.
*/
abstract public FacesBean getFacesBean();
Modified: myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java?rev=965489&r1=965488&r2=965489&view=diff
==============================================================================
--- myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java (original)
+++ myfaces/trinidad/branches/anrobins_1.2.12.3_visitTree/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java Mon Jul 19 14:03:24 2010
@@ -129,6 +129,27 @@ public class CoreRenderer extends Render
/**
* <p>
+ * Called before rendering the current component's children in order to set
+ * up any special context.
+ * </p>
+ * <p>If <code>setupChildrenEncodingContext</code> succeeds then
+ * <code>tearDownChildrenEncodingContext</code> will be called for the same component.
+ * </p>
+ * <p>The default implementation does nothing</p>
+ * @param context FacesContext for this request
+ * @param rc RenderingContext for this encoding pass
+ * @param component Component to encode using this Renderer
+ * @see #tearDownChildrenEncodingContext
+ */
+ public void setupChildrenEncodingContext(
+ @SuppressWarnings("unused") FacesContext context,
+ @SuppressWarnings("unused") RenderingContext rc,
+ @SuppressWarnings("unused") UIComponent component)
+ {
+ }
+
+ /**
+ * <p>
* Called after rendering the current component's children in order to tear
* down any special context.
* </p>
@@ -162,6 +183,28 @@ public class CoreRenderer extends Render
}
/**
+ * <p>
+ * Called after rendering the current component's children in order to tear
+ * down any special context.
+ * </p>
+ * <p>
+ * <code>tearDownChildrenEncodingContext</code> will be called on the component if
+ * <code>setupChildrenEncodingContext</code> succeeded.
+ * </p>
+ * <p>The default implementation does nothing</p>
+ * @param context FacesContext for this request
+ * @param rc RenderingContext for this encoding pass
+ * @param component Component to encode using this Renderer
+ * @see #setupChildrenEncodingContext
+ */
+ public void tearDownChildrenEncodingContext(
+ @SuppressWarnings("unused") FacesContext context,
+ @SuppressWarnings("unused") RenderingContext rc,
+ @SuppressWarnings("unused") UIComponent component)
+ {
+ }
+
+ /**
* Hook to allow the renderer to customize the visitation of the children components
* of a component during the visitation of a component during rendering.
*