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/09/29 21:44:53 UTC
svn commit: r1002826 - in /myfaces/trinidad/trunk/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: Wed Sep 29 19:44:53 2010
New Revision: 1002826
URL: http://svn.apache.org/viewvc?rev=1002826&view=rev
Log:
TRINIDAD-1927
Change places where Trinidad was calling encodeBegin/Children/End on child components to calling encodeAll
Modified:
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java?rev=1002826&r1=1002825&r2=1002826&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXGroupTemplate.java Wed Sep 29 19:44:53 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,7 +56,7 @@ abstract public class UIXGroupTemplate e
) throws IOException
{
cpContext.pushGroup();
-
+
try
{
setupVisitingContext(context);
@@ -85,7 +86,7 @@ abstract public class UIXGroupTemplate e
}
finally
{
- cpContext.popGroup();
+ cpContext.popGroup();
}
}
@@ -119,7 +120,7 @@ abstract public class UIXGroupTemplate e
{
for(UIComponent child : (List<UIComponent>)getChildren())
{
- __encodeRecursive(context, child);
+ child.encodeAll(context);
}
}
}
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java?rev=1002826&r1=1002825&r2=1002826&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java Wed Sep 29 19:44:53 2010
@@ -86,9 +86,9 @@ public abstract class UIXIteratorTemplat
{
// Mimic what would normally happen in the non-flattening case for encodeBegin():
__processFlattenedChildrenBegin();
-
+
setupChildrenVisitingContext(context);
-
+
try
{
Runner runner = new IndexedRunner(cpContext)
@@ -97,25 +97,25 @@ public abstract class UIXIteratorTemplat
protected void process(UIComponent kid, ComponentProcessingContext cpContext) throws IOException
{
kid.pushComponentToEL(context, null);
-
+
try
{
childProcessor.processComponent(context, cpContext, kid, callbackContext);
}
finally
{
- kid.popComponentFromEL(context);
+ kid.popComponentFromEL(context);
}
}
};
-
+
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);
@@ -130,7 +130,7 @@ public abstract class UIXIteratorTemplat
{
tearDownVisitingContext(context);
}
-
+
return processedChildren;
}
@@ -169,10 +169,12 @@ public abstract class UIXIteratorTemplat
Runner runner = new IndexedRunner()
{
@Override
- protected void process(UIComponent kid,
- ComponentProcessingContext cpContext) throws IOException
+ protected void process(
+ UIComponent kid,
+ ComponentProcessingContext cpContext
+ ) throws IOException
{
- __encodeRecursive(context, kid);
+ kid.encodeAll(context);
}
};
runner.run();
@@ -229,7 +231,7 @@ public abstract class UIXIteratorTemplat
}
return map.get(key);
}
-
+
@Override
public Set<Map.Entry<String, Object>> entrySet()
{
@@ -268,13 +270,13 @@ public abstract class UIXIteratorTemplat
};
runner.run();
}
-
+
// Extract the current row token from the clientId
private String _getClientToken(String clientIdPrefix, String cellClientId)
{
int tokenStartIndex = clientIdPrefix.length() + 1;
int tokenEndIndex = cellClientId.indexOf(':', tokenStartIndex);
-
+
if (tokenEndIndex != -1)
{
return cellClientId.substring(tokenStartIndex, tokenEndIndex);
@@ -284,21 +286,21 @@ public abstract class UIXIteratorTemplat
return null;
}
}
-
+
@Override
protected boolean visitData(
final VisitContext visitContext,
final VisitCallback visitCallback)
{
Collection<String> subtreeIds = visitContext.getSubtreeIdsToVisit(this);
-
+
// create a special VisitContext that doesn't visit the Facets
// of column components since they aren't visited on each row
final VisitContext noColumnFacetContext = new NoColumnFacetsVisitContext(visitContext);
// runner to use to process the rows
Runner runner;
-
+
if (VisitContext.ALL_IDS.equals(subtreeIds))
{
// we're processing all of the rows, so use the indexed runner (plus, we can't call size() on
@@ -318,26 +320,26 @@ public abstract class UIXIteratorTemplat
else
{
// We are only visiting a subset of the tree, so figure out which rows to visit
-
+
String ourClientIdPrefix = getClientId(visitContext.getFacesContext());
-
+
int subtreeIdCount = subtreeIds.size();
-
+
// build up a set of the row keys to visit rather than iterating
// and visiting every row
Set<String> rowsToVisit;
-
+
if (subtreeIdCount > 1)
{
rowsToVisit = new HashSet<String>(subtreeIdCount);
-
+
for (String currClientId : subtreeIds)
{
String clientToken = _getClientToken(ourClientIdPrefix, currClientId);
-
+
if (clientToken != null)
{
- rowsToVisit.add(clientToken);
+ rowsToVisit.add(clientToken);
}
}
}
@@ -345,7 +347,7 @@ public abstract class UIXIteratorTemplat
{
String clientToken = _getClientToken(ourClientIdPrefix,
subtreeIds.iterator().next());
-
+
if (clientToken != null)
{
rowsToVisit = Collections.singleton(clientToken);
@@ -355,7 +357,7 @@ public abstract class UIXIteratorTemplat
rowsToVisit = Collections.emptySet();
}
}
-
+
// we didn't visit any data
if (rowsToVisit.isEmpty())
return false;
@@ -376,7 +378,7 @@ public abstract class UIXIteratorTemplat
}
};
}
-
+
try
{
runner.run();
@@ -401,7 +403,7 @@ public abstract class UIXIteratorTemplat
{
_cpContext = cpContext;
}
-
+
public abstract boolean run();
/**
@@ -424,7 +426,7 @@ public abstract class UIXIteratorTemplat
catch (AbortProcessingException ape)
{
// we're done, so abort
- _exception = ape;
+ _exception = ape;
throw ape;
}
catch (Exception e)
@@ -432,7 +434,7 @@ public abstract class UIXIteratorTemplat
_exception = e;
}
}
-
+
public Exception getException()
{
return _exception;
@@ -450,7 +452,7 @@ public abstract class UIXIteratorTemplat
{
_exception = e;
}
-
+
private Exception _exception = null;
private final ComponentProcessingContext _cpContext;
@@ -470,12 +472,12 @@ public abstract class UIXIteratorTemplat
{
super(cpContext);
}
-
+
public final boolean run()
{
FacesContext context = FacesContext.getCurrentInstance();
ComponentProcessingContext cpContext = getComponentProcessingContext();
-
+
List<UIComponent> stamps = getStamps();
int oldIndex = getRowIndex();
int first = getFirst();
@@ -483,9 +485,9 @@ public abstract class UIXIteratorTemplat
int end = (rows <= 0) //show everything
? Integer.MAX_VALUE
: first + rows;
-
+
boolean processedChild = false;
-
+
try
{
for(int i=first; i<end; i++)
@@ -510,7 +512,7 @@ public abstract class UIXIteratorTemplat
{
setRowIndex(oldIndex);
}
-
+
return processedChild;
}
}
@@ -525,16 +527,16 @@ public abstract class UIXIteratorTemplat
super();
_clientKeys = clientKeys;
}
-
+
public final boolean run()
{
FacesContext context = FacesContext.getCurrentInstance();
-
+
List<UIComponent> stamps = getStamps();
int oldIndex = getRowIndex();
-
+
boolean processedChild = false;
-
+
try
{
// need to convert row key tokens to row keys
@@ -543,7 +545,7 @@ public abstract class UIXIteratorTemplat
for(String clientKey : _clientKeys)
{
Object rowKey = rowKeyManager.getRowKey(context, UIXIterator.this, clientKey);
-
+
if (rowKey != null)
{
setRowKey(rowKey);
@@ -563,13 +565,13 @@ public abstract class UIXIteratorTemplat
{
setRowIndex(oldIndex);
}
-
+
return processedChild;
}
-
+
private final Iterable<String> _clientKeys;
}
-
+
@Override
void __encodeBegin(FacesContext context) throws IOException
{
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java?rev=1002826&r1=1002825&r2=1002826&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSwitcherTemplate.java Wed Sep 29 19:44:53 2010
@@ -20,8 +20,6 @@ package org.apache.myfaces.trinidad.comp
import java.io.IOException;
-import java.util.Iterator;
-
import javax.faces.component.UIComponent;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
@@ -139,7 +137,9 @@ abstract public class UIXSwitcherTemplat
{
UIComponent facet = _getFacet();
if (facet != null)
- __encodeRecursive(context, facet);
+ {
+ facet.encodeAll(context);
+ }
}
/**
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=1002826&r1=1002825&r2=1002826&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Wed Sep 29 19:44:53 2010
@@ -41,7 +41,6 @@ import javax.faces.application.ProjectSt
import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.ExternalContext;
@@ -904,24 +903,6 @@ abstract public class UIXComponentBase e
}
}
- /**
- * Encodes a component and all of its children, whether
- * getRendersChildren() is true or false. When rendersChildren
- * is false, each child whose "rendered" property is true
- * will be sequentially rendered; facets will be ignored.
- */
- @Override
- public void encodeAll(FacesContext context) throws IOException
- {
- if (context == null)
- throw new NullPointerException();
-
- // This code ends up calling isRendered() once overall,
- // plus up to three times more for encodeBegin(),
- // encodeChildren(), and encodeEnd().
- __encodeRecursive(context, this);
- }
-
@Override
public void queueEvent(FacesEvent event)
{
@@ -1867,30 +1848,13 @@ abstract public class UIXComponentBase e
/**
* render a component. this is called by renderers whose
* getRendersChildren() return true.
+ * @deprecated {@link UIComponent#encodeAll(FacesContext)} should be used instead of this method
*/
+ @Deprecated
void __encodeRecursive(FacesContext context, UIComponent component)
throws IOException
{
- if (component.isRendered())
- {
- component.encodeBegin(context);
- if (component.getRendersChildren())
- {
- component.encodeChildren(context);
- }
- else
- {
- if (component.getChildCount() > 0)
- {
- for(UIComponent child : component.getChildren())
- {
- __encodeRecursive(context, child);
- }
- }
- }
-
- component.encodeEnd(context);
- }
+ component.encodeAll(context);
}
static private UIComponent _findInsideOf(
@@ -2085,7 +2049,7 @@ abstract public class UIXComponentBase e
return (_CLIENT_ID_CACHING == ClientIdCaching.DEBUG);
}
- // Warn if caching is disabled + production environment since this is
+ // Warn if caching is disabled + production environment since this is
// undesirable from a performance perspective.
private static void _warnClientIdCachingConfig(FacesContext context)
{
@@ -2145,13 +2109,13 @@ abstract public class UIXComponentBase e
return null;
}
-
+
private static ClientIdCaching _toClientIdCachingEnum(String cachingProperty)
{
try
{
- return Enum.valueOf(ClientIdCaching.class,
- (cachingProperty == null) ?
+ return Enum.valueOf(ClientIdCaching.class,
+ (cachingProperty == null) ?
"ON" :
cachingProperty.toUpperCase());
}
Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java?rev=1002826&r1=1002825&r2=1002826&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java Wed Sep 29 19:44:53 2010
@@ -576,23 +576,7 @@ public class CoreRenderer extends Render
) throws IOException
{
assert(child.isRendered());
- child.encodeBegin(context);
- if (child.getRendersChildren())
- {
- child.encodeChildren(context);
- }
- else
- {
- if (child.getChildCount() > 0)
- {
- for(UIComponent subChild : (List<UIComponent>)child.getChildren())
- {
- RenderUtils.encodeRecursive(context, subChild);
- }
- }
- }
-
- child.encodeEnd(context);
+ child.encodeAll(context);
}
@SuppressWarnings("unchecked")
@@ -1069,9 +1053,9 @@ public class CoreRenderer extends Render
{
String compressedStyleClass = rc.getStyleClass(styleClass);
context.getResponseWriter().writeAttribute("class", compressedStyleClass, null);
-
+
if (Beans.isDesignTime())
- context.getResponseWriter().writeAttribute("rawClass", styleClass, null);
+ context.getResponseWriter().writeAttribute("rawClass", styleClass, null);
}
}
@@ -1125,9 +1109,9 @@ public class CoreRenderer extends Render
}
context.getResponseWriter().writeAttribute("class", value, null);
-
+
if (Beans.isDesignTime())
- {
+ {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < length; i++)
{
@@ -1144,9 +1128,9 @@ public class CoreRenderer extends Render
}
if (builder.length() > 0)
- context.getResponseWriter().writeAttribute("rawClass", builder.toString(), null);
+ context.getResponseWriter().writeAttribute("rawClass", builder.toString(), null);
}
-
+
}
// Heuristic guess of the maximum length of a typical compressed style