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 2012/03/16 19:00:43 UTC
svn commit: r1301672 - in
/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets:
./ compiler/ impl/ tag/jsf/ tag/jsf/core/
Author: lu4242
Date: Fri Mar 16 18:00:42 2012
New Revision: 1301672
URL: http://svn.apache.org/viewvc?rev=1301672&view=rev
Log:
MYFACES-3502 components inside f:metadata are recreated when the whole view is processed
Modified:
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFacelet.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFacelet.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFacelet.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFacelet.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFacelet.java Fri Mar 16 18:00:42 2012
@@ -26,10 +26,8 @@ import javax.el.ExpressionFactory;
import javax.faces.FacesException;
import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.FaceletException;
-import org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory;
/**
* @author Leonardo Uribe (latest modification by $Author$)
@@ -47,11 +45,9 @@ public abstract class AbstractFacelet ex
public abstract ExpressionFactory getExpressionFactory();
/**
- * Used for delegation by the DefaultFaceletContext. First pulls the URL from {@link #getRelativePath(String)
- * getRelativePath(String)}, then calls {@link #include(FaceletContext, UIComponent, URL) include(FaceletContext,
- * UIComponent, URL)}.
+ * Used for delegation by the DefaultFaceletContext.
*
- * @see FaceletContext#includeFacelet(UIComponent, String)
+ * @see javax.faces.view.facelets.FaceletContext#includeFacelet(UIComponent, String)
* @param ctx
* FaceletContext to pass to the included Facelet
* @param parent
@@ -63,13 +59,13 @@ public abstract class AbstractFacelet ex
* @throws FaceletException
* @throws ELException
*/
- public abstract void include(AbstractFaceletContext ctx, UIComponent parent, String path) throws IOException, FacesException,
- FaceletException, ELException;
+ public abstract void include(AbstractFaceletContext ctx, UIComponent parent, String path)
+ throws IOException, FacesException, FaceletException, ELException;
/**
* Grabs a DefaultFacelet from referenced DefaultFaceletFacotry
*
- * @see DefaultFaceletFactory#getFacelet(URL)
+ * @see org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory#getFacelet(URL)
* @param ctx
* FaceletContext to pass to the included Facelet
* @param parent
@@ -81,8 +77,8 @@ public abstract class AbstractFacelet ex
* @throws FaceletException
* @throws ELException
*/
- public abstract void include(AbstractFaceletContext ctx, UIComponent parent, URL url) throws IOException, FacesException,
- FaceletException, ELException;
+ public abstract void include(AbstractFaceletContext ctx, UIComponent parent, URL url)
+ throws IOException, FacesException, FaceletException, ELException;
/**
* Return the alias name for error messages and logging
@@ -91,8 +87,19 @@ public abstract class AbstractFacelet ex
*/
public abstract String getAlias();
- public abstract void applyCompositeComponent(AbstractFaceletContext ctx, UIComponent parent, Resource resource) throws IOException, FacesException,
- FaceletException, ELException;
+ public abstract void applyCompositeComponent(AbstractFaceletContext ctx, UIComponent parent, Resource resource)
+ throws IOException, FacesException, FaceletException, ELException;
public abstract boolean isBuildingCompositeComponentMetadata();
+
+ /**
+ * Return an identifier used to derive an unique id per facelet instance. This
+ * value should be the same for viewMetadata and normal facelet instances.
+ *
+ * @return
+ */
+ public String getFaceletId()
+ {
+ return getAlias();
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java Fri Mar 16 18:00:42 2012
@@ -530,4 +530,46 @@ abstract public class FaceletComposition
return FaceletViewDeclarationLanguage.isBuildingViewMetadata(
FacesContext.getCurrentInstance());
}
+
+ /**
+ * Call this method to indicate a f:metadata section is about to be processed
+ *
+ * since 2.1.7, 2.0.13
+ * @return
+ */
+ public void startMetadataSection()
+ {
+ }
+
+ /**
+ * Call this method to indicate f:metadata section has been already processed
+ *
+ * since 2.1.7, 2.0.13
+ * @return
+ */
+ public void endMetadataSection()
+ {
+ }
+
+ /**
+ * Check if the component is created inside f:metadata section
+ *
+ * since 2.1.7, 2.0.13
+ * @return
+ */
+ public boolean isInMetadataSection()
+ {
+ return false;
+ }
+
+ /**
+ * Check if the section to be processed is being refreshed.
+ *
+ * since 2.1.7, 2.0.13
+ * @return
+ */
+ public boolean isRefreshingSection()
+ {
+ return isRefreshingTransientBuild() || (!isBuildingViewMetadata() && isInMetadataSection());
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java Fri Mar 16 18:00:42 2012
@@ -91,7 +91,7 @@ final class UIInstructionHandler extends
String componentId = mctx.generateUniqueComponentId();
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
c = ComponentSupport.findChildByTagId(parent, id);
}
@@ -152,12 +152,12 @@ final class UIInstructionHandler extends
mctx.finalizeForDeletion(c);
if (!componentFoundInserted)
{
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
ctx.getFacesContext().setProcessingEvents(false);
}
parent.getChildren().remove(c);
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
ctx.getFacesContext().setProcessingEvents(oldProcessingEvents);
}
@@ -165,12 +165,12 @@ final class UIInstructionHandler extends
}
if (!componentFoundInserted)
{
- if (componentFound && mctx.isRefreshingTransientBuild())
+ if (componentFound && mctx.isRefreshingSection())
{
ctx.getFacesContext().setProcessingEvents(false);
}
this.addComponent(ctx, parent, c);
- if (componentFound && mctx.isRefreshingTransientBuild())
+ if (componentFound && mctx.isRefreshingSection())
{
ctx.getFacesContext().setProcessingEvents(oldProcessingEvents);
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java Fri Mar 16 18:00:42 2012
@@ -68,6 +68,8 @@ final class DefaultFacelet extends Abstr
private final static String APPLIED_KEY = "org.apache.myfaces.view.facelets.APPLIED";
private final String _alias;
+
+ private final String _faceletId;
private final ExpressionFactory _elFactory;
@@ -88,28 +90,30 @@ final class DefaultFacelet extends Abstr
private final boolean _encodingHandler;
public DefaultFacelet(DefaultFaceletFactory factory, ExpressionFactory el, URL src, String alias,
- FaceletHandler root)
+ String faceletId, FaceletHandler root)
{
_factory = factory;
_elFactory = el;
_src = src;
_root = root;
_alias = alias;
+ _faceletId = faceletId;
_createTime = System.currentTimeMillis();
_refreshPeriod = _factory.getRefreshPeriod();
_relativePaths = new WeakHashMap<String, URL>();
_isBuildingCompositeComponentMetadata = false;
_encodingHandler = (root instanceof EncodingHandler);
}
-
+
public DefaultFacelet(DefaultFaceletFactory factory, ExpressionFactory el, URL src, String alias,
- FaceletHandler root, boolean isBuildingCompositeComponentMetadata)
+ String faceletId, FaceletHandler root, boolean isBuildingCompositeComponentMetadata)
{
_factory = factory;
_elFactory = el;
_src = src;
_root = root;
_alias = alias;
+ _faceletId = faceletId;
_createTime = System.currentTimeMillis();
_refreshPeriod = _factory.getRefreshPeriod();
_relativePaths = new WeakHashMap<String, URL>();
@@ -309,6 +313,11 @@ final class DefaultFacelet extends Abstr
{
return _alias;
}
+
+ public String getFaceletId()
+ {
+ return _faceletId;
+ }
/**
* Return this Facelet's ExpressionFactory instance
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java Fri Mar 16 18:00:42 2012
@@ -295,7 +295,7 @@ final class DefaultFaceletContext extend
for (int i = 0; i < _faceletHierarchy.size(); i++)
{
AbstractFacelet facelet = _faceletHierarchy.get(i);
- builder.append(facelet.getAlias());
+ builder.append(facelet.getFaceletId());
}
// Integer prefixInt = new Integer(builder.toString().hashCode());
@@ -321,8 +321,17 @@ final class DefaultFaceletContext extend
getFaceletCompositionContext().generateUniqueId(_uniqueIdBuilder);
_uniqueIdBuilder.append("_");
_uniqueIdBuilder.append(_prefix);
- _uniqueIdBuilder.append("_");
- _uniqueIdBuilder.append(base);
+ // Since two different facelets are used to build the metadata, it is necessary
+ // to trim the "base" part from the returned unique id, to ensure the components will be
+ // refreshed properly. Note the "base" part is the one that allows to ensure
+ // uniqueness between two different facelets with the same <f:metadata>, but since by
+ // spec view metadata sections cannot live on template client facelets, this case is
+ // just not possible.
+ if (!getFaceletCompositionContext().isInMetadataSection())
+ {
+ _uniqueIdBuilder.append("_");
+ _uniqueIdBuilder.append(base);
+ }
uniqueIdFromIterator = _uniqueIdBuilder.toString();
getFaceletCompositionContext().addUniqueId(uniqueIdFromIterator);
return uniqueIdFromIterator;
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java Fri Mar 16 18:00:42 2012
@@ -18,19 +18,10 @@
*/
package org.apache.myfaces.view.facelets.impl;
-import org.apache.myfaces.view.facelets.Facelet;
-import org.apache.myfaces.view.facelets.FaceletFactory;
-import org.apache.myfaces.view.facelets.compiler.Compiler;
-import org.apache.myfaces.view.facelets.util.ParameterCheck;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.faces.view.facelets.FaceletHandler;
-import javax.faces.view.facelets.ResourceResolver;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
@@ -39,6 +30,18 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.FaceletHandler;
+import javax.faces.view.facelets.ResourceResolver;
+
+import org.apache.myfaces.view.facelets.Facelet;
+import org.apache.myfaces.view.facelets.FaceletFactory;
+import org.apache.myfaces.view.facelets.compiler.Compiler;
+import org.apache.myfaces.view.facelets.util.ParameterCheck;
+
/**
* Default FaceletFactory implementation.
*
@@ -278,7 +281,7 @@ public final class DefaultFaceletFactory
try
{
FaceletHandler h = _compiler.compile(url, alias);
- DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias, h);
+ DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias, alias, h);
return f;
}
catch (FileNotFoundException fnfe)
@@ -296,7 +299,8 @@ public final class DefaultFaceletFactory
* @throws FacesException
* @throws ELException
*/
- private DefaultFacelet _createViewMetadataFacelet(URL url) throws IOException, FaceletException, FacesException, ELException
+ private DefaultFacelet _createViewMetadataFacelet(URL url)
+ throws IOException, FaceletException, FacesException, ELException
{
if (log.isLoggable(Level.FINE))
{
@@ -305,11 +309,13 @@ public final class DefaultFaceletFactory
// The alias is used later for informative purposes, so we append
// some prefix to identify later where the errors comes from.
- String alias = "/viewMetadata/" + _removeFirst(url.getFile(), _baseUrl.getFile());
+ String faceletId = "/"+ _removeFirst(url.getFile(), _baseUrl.getFile());
+ String alias = "/viewMetadata" + faceletId;
try
{
FaceletHandler h = _compiler.compileViewMetadata(url, alias);
- DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias, h);
+ DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias,
+ faceletId, h);
return f;
}
catch (FileNotFoundException fnfe)
@@ -328,7 +334,8 @@ public final class DefaultFaceletFactory
* @throws FacesException
* @throws ELException
*/
- private DefaultFacelet _createCompositeComponentMetadataFacelet(URL url) throws IOException, FaceletException, FacesException, ELException
+ private DefaultFacelet _createCompositeComponentMetadataFacelet(URL url)
+ throws IOException, FaceletException, FacesException, ELException
{
if (log.isLoggable(Level.FINE))
{
@@ -341,7 +348,8 @@ public final class DefaultFaceletFactory
try
{
FaceletHandler h = _compiler.compileCompositeComponentMetadata(url, alias);
- DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias, h, true);
+ DefaultFacelet f = new DefaultFacelet(this, _compiler.createExpressionFactory(), url, alias,
+ alias, h, true);
return f;
}
catch (FileNotFoundException fnfe)
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java Fri Mar 16 18:00:42 2012
@@ -131,6 +131,12 @@ public class FaceletCompositionContextIm
private Iterator<String> _uniqueIdsIterator;
private int _level;
+ private int _isInMetadataSection;
+ private SectionUniqueIdCounter _sectionUniqueMetadataIdCounter;
+ private SectionUniqueIdCounter _sectionUniqueNormalIdCounter;
+ private SectionUniqueIdCounter _sectionUniqueComponentMetadataIdCounter;
+ private SectionUniqueIdCounter _sectionUniqueComponentNormalIdCounter;
+
public FaceletCompositionContextImpl(FaceletFactory factory, FacesContext facesContext)
{
super();
@@ -160,9 +166,12 @@ public class FaceletCompositionContextIm
{
_sectionUniqueComponentIdCounter = new SectionUniqueIdCounter("_");
}
+ _sectionUniqueNormalIdCounter = _sectionUniqueIdCounter;
+ _sectionUniqueComponentNormalIdCounter = _sectionUniqueComponentIdCounter;
_uniqueIdsList = null;
_uniqueIdsIterator = null;
_level = 0;
+ _isInMetadataSection = 0;
}
@Override
@@ -182,7 +191,7 @@ public class FaceletCompositionContextIm
@Override
public void addUniqueId(String uniqueId)
{
- if (_uniqueIdsList != null && _level == 0)
+ if (_uniqueIdsList != null && _level == 0 && !(_isInMetadataSection > 0))
{
_uniqueIdsList.add(uniqueId);
}
@@ -191,7 +200,8 @@ public class FaceletCompositionContextIm
@Override
public String getUniqueIdFromIterator()
{
- if (_uniqueIdsIterator != null && _uniqueIdsIterator.hasNext() && _level == 0)
+ if (_uniqueIdsIterator != null && _uniqueIdsIterator.hasNext() &&
+ _level == 0 && !(_isInMetadataSection > 0))
{
return _uniqueIdsIterator.next();
}
@@ -891,6 +901,50 @@ public class FaceletCompositionContextIm
_sectionUniqueComponentIdCounter.endUniqueIdSection();
}
+ @Override
+ public void startMetadataSection()
+ {
+ if (_isInMetadataSection == 0)
+ {
+ if (_sectionUniqueMetadataIdCounter == null)
+ {
+ _sectionUniqueMetadataIdCounter = new SectionUniqueIdCounter("__md_");
+ }
+ if (_sectionUniqueComponentMetadataIdCounter == null)
+ {
+ _sectionUniqueComponentMetadataIdCounter = new SectionUniqueIdCounter("__md_");
+ }
+ //Replace the counter with metadata counter
+ _sectionUniqueIdCounter = _sectionUniqueMetadataIdCounter;
+ _sectionUniqueComponentIdCounter = _sectionUniqueComponentMetadataIdCounter;
+ }
+ _isInMetadataSection++;
+ }
+
+ @Override
+ public void endMetadataSection()
+ {
+ _isInMetadataSection--;
+ if (_isInMetadataSection == 0)
+ {
+ //Use normal id counter again
+ _sectionUniqueIdCounter = _sectionUniqueNormalIdCounter;
+ _sectionUniqueComponentIdCounter = _sectionUniqueComponentNormalIdCounter;
+ }
+ }
+
+ @Override
+ public boolean isInMetadataSection()
+ {
+ return _isInMetadataSection > 0;
+ }
+
+ @Override
+ public boolean isRefreshingSection()
+ {
+ return isRefreshingTransientBuild() || (!isBuildingViewMetadata() && isInMetadataSection());
+ }
+
private static class KeyEntryIterator<K, V> implements Iterator<K>
{
private Iterator<Map.Entry<K, V>> _delegateIterator;
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Fri Mar 16 18:00:42 2012
@@ -19,7 +19,6 @@
package org.apache.myfaces.view.facelets.tag.jsf;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -46,7 +45,6 @@ import javax.faces.view.facelets.Facelet
import javax.faces.view.facelets.MetaRuleset;
import javax.faces.view.facelets.TagAttribute;
import javax.faces.view.facelets.TagException;
-import javax.faces.view.facelets.TagHandler;
import javax.faces.view.facelets.TagHandlerDelegate;
import javax.faces.view.facelets.ValidatorHandler;
@@ -69,7 +67,6 @@ import org.apache.myfaces.view.facelets.
*/
public class ComponentTagHandlerDelegate extends TagHandlerDelegate
{
- //private final static Logger log = Logger.getLogger("facelets.tag.component");
private final static Logger log = Logger.getLogger(ComponentTagHandlerDelegate.class.getName());
private final ComponentHandler _delegate;
@@ -153,21 +150,24 @@ public class ComponentTagHandlerDelegate
* <ol>
* <li>First determines this UIComponent's id by calling {@link #getId(FaceletContext) getId(FaceletContext)}.</li>
* <li>Search the parent for an existing UIComponent of the id we just grabbed</li>
- * <li>If found, {@link #FaceletCompositionContext.markForDeletion(UIComponent) mark} its children for deletion.</li>
+ * <li>If found, {@link FaceletCompositionContext#markForDeletion(UIComponent) mark} its children for deletion.</li>
* <li>If <i>not</i> found, call {@link #createComponent(FaceletContext) createComponent}.
* <ol>
- * <li>Only here do we apply {@link TagHandler#setAttributes(FaceletCompositionContext, Object) attributes}</li>
+ * <li>Only here do we apply
+ * {@link javax.faces.view.facelets.TagHandler#setAttributes(FaceletCompositionContext, Object) attributes}</li>
* <li>Set the UIComponent's id</li>
* <li>Set the RendererType of this instance</li>
* </ol>
* </li>
* <li>Now apply the nextHandler, passing the UIComponent we've created/found.</li>
* <li>Now add the UIComponent to the passed parent</li>
- * <li>Lastly, if the UIComponent already existed (found), then {@link #finalizeForDeletion(FaceletCompositionContext, UIComponent) finalize}
+ * <li>Lastly, if the UIComponent already existed (found),
+ * then {@link #finalizeForDeletion(FaceletCompositionContext, UIComponent) finalize}
* for deletion.</li>
* </ol>
*
- * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
+ * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext,
+ * javax.faces.component.UIComponent)
*
* @throws TagException
* if the UIComponent parent is null
@@ -203,7 +203,7 @@ public class ComponentTagHandlerDelegate
//another component.
UIComponent oldParent = parent;
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
if (_relocatableResourceHandler != null)
{
@@ -213,48 +213,6 @@ public class ComponentTagHandlerDelegate
{
c = ComponentSupport.findChildByTagId(parent, id);
}
-
- // Check if the component was relocated using
- // composite:insertChildren or composite:insertFacet
- /*
- if (c == null && UIComponent.isCompositeComponent(parent))
- {
- if (facetName == null)
- {
- String targetClientId = (String) parent.getAttributes().get(InsertChildrenHandler.INSERT_CHILDREN_TARGET_ID);
- if (targetClientId != null)
- {
- UIComponent targetComponent = parent.findComponent(targetClientId.substring(parent.getClientId().length()+1));
- if (targetComponent != null)
- {
- c = ComponentSupport.findChildByTagId(targetComponent, id);
- }
- }
- if (c != null)
- {
- c.getAttributes().put(InsertChildrenHandler.USES_INSERT_CHILDREN, Boolean.TRUE);
- componentFoundInserted = true;
- }
- }
- else
- {
- String targetClientId = (String) parent.getAttributes().get(InsertFacetHandler.INSERT_FACET_TARGET_ID+facetName);
- if (targetClientId != null)
- {
- UIComponent targetComponent = parent.findComponent(targetClientId.substring(parent.getClientId().length()+1));
- if (targetComponent != null)
- {
- c = ComponentSupport.findChildByTagId(targetComponent, id);
- if (c != null)
- {
- c.getAttributes().put(InsertFacetHandler.USES_INSERT_FACET, Boolean.TRUE);
- componentFoundInserted = true;
- }
- }
- }
- }
- }
- */
}
boolean componentFound = false;
if (c != null)
@@ -340,7 +298,7 @@ public class ComponentTagHandlerDelegate
//if (!componentFoundInserted)
//{
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
facesContext.setProcessingEvents(false);
if (_relocatableResourceHandler != null &&
@@ -358,52 +316,13 @@ public class ComponentTagHandlerDelegate
{
ComponentSupport.removeFacet(ctx, parent, c, facetName);
}
- if (mctx.isRefreshingTransientBuild())
+ if (mctx.isRefreshingSection())
{
facesContext.setProcessingEvents(oldProcessingEvents);
}
//}
}
-
- /*
- if (mctx.isRefreshingTransientBuild() &&
- UIComponent.isCompositeComponent(parent))
- {
- // Save the child structure behind this component, so it can be
- // used later by InsertChildrenHandler and InsertFacetHandler
- // to update components correctly.
- if (facetName != null)
- {
- if (parent.getAttributes().containsKey(InsertFacetHandler.INSERT_FACET_TARGET_ID+facetName))
- {
- List<String> ordering = (List<String>) parent.getAttributes().get(
- InsertFacetHandler.INSERT_FACET_ORDERING+facetName);
- if (ordering == null)
- {
- ordering = new ArrayList<String>();
- parent.getAttributes().put(InsertFacetHandler.INSERT_FACET_ORDERING+facetName, ordering);
- }
- ordering.remove(id);
- ordering.add(id);
- }
- }
- else
- {
- if (parent.getAttributes().containsKey(InsertChildrenHandler.INSERT_CHILDREN_TARGET_ID))
- {
- List<String> ordering = (List<String>) parent.getAttributes().get(
- InsertChildrenHandler.INSERT_CHILDREN_ORDERING);
- if (ordering == null)
- {
- ordering = new ArrayList<String>();
- parent.getAttributes().put(InsertChildrenHandler.INSERT_CHILDREN_ORDERING, ordering);
- }
- ordering.remove(id);
- ordering.add(id);
- }
- }
- }
- */
+
if (!componentFound)
{
@@ -429,44 +348,23 @@ public class ComponentTagHandlerDelegate
_delegate.onComponentPopulated(ctx, c, oldParent);
- //if (!componentFoundInserted)
- //{
- // 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);
- }
- else
- {
- ComponentSupport.addFacet(ctx, parent, c, facetName);
- }
- if (componentFound && mctx.isRefreshingTransientBuild())
- {
- facesContext.setProcessingEvents(oldProcessingEvents);
- }
- //}
- /*
+ if (componentFound && mctx.isRefreshingSection())
+ {
+ facesContext.setProcessingEvents(false);
+ }
+ if (facetName == null)
+ {
+ parent.getChildren().add(c);
+ }
else
{
- if (facetName != null)
- {
- if (UIComponent.isCompositeComponent(parent))
- {
- UIComponent facet = parent.getFacet(facetName);
- if (Boolean.TRUE.equals(facet.getAttributes().get(ComponentSupport.FACET_CREATED_UIPANEL_MARKER)))
- {
- facet.getAttributes().put(InsertFacetHandler.USES_INSERT_FACET, Boolean.TRUE);
- }
- }
- }
- }*/
-
+ ComponentSupport.addFacet(ctx, parent, c, facetName);
+ }
+ if (componentFound && mctx.isRefreshingSection())
+ {
+ facesContext.setProcessingEvents(oldProcessingEvents);
+ }
+
if (c instanceof UniqueIdVendor)
{
mctx.popUniqueIdVendorToStack();
@@ -609,11 +507,14 @@ public class ComponentTagHandlerDelegate
* @param mctx the AbstractFaceletContext
* @param component The EditableValueHolder to which the validators should be added
*/
- private void addEnclosingAndDefaultValidators(FaceletContext ctx, FaceletCompositionContext mctx, FacesContext context,
+ private void addEnclosingAndDefaultValidators(FaceletContext ctx,
+ FaceletCompositionContext mctx,
+ FacesContext context,
EditableValueHolder component)
{
// add all enclosing validators, because they have precedence over default validators.
- Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds = mctx.getEnclosingValidatorIdsAndHandlers();
+ Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds =
+ mctx.getEnclosingValidatorIdsAndHandlers();
if (enclosingValidatorIds != null)
{
while (enclosingValidatorIds.hasNext())
@@ -759,7 +660,8 @@ public class ComponentTagHandlerDelegate
}
}
}*/
- Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds = mctx.getEnclosingValidatorIdsAndHandlers();
+ Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds =
+ mctx.getEnclosingValidatorIdsAndHandlers();
if (enclosingValidatorIds != null)
{
while (enclosingValidatorIds.hasNext())
@@ -768,7 +670,8 @@ public class ComponentTagHandlerDelegate
boolean validatorIdAvailable = entry.getKey() != null && !"".equals(entry.getKey());
if (validatorIdAvailable && entry.getKey().equals(validatorId))
{
- if (((ValidatorHandler)((FacesWrapper<ValidatorHandler>)entry.getValue()).getWrapped()).isDisabled(ctx))
+ if (((ValidatorHandler)((FacesWrapper<ValidatorHandler>)entry.getValue()).getWrapped())
+ .isDisabled(ctx))
{
return false;
}
@@ -796,7 +699,8 @@ public class ComponentTagHandlerDelegate
}
private void addEnclosingValidator(FaceletContext ctx, FaceletCompositionContext mctx, FacesContext context,
- EditableValueHolder component, String validatorId, EditableValueHolderAttachedObjectHandler attachedObjectHandler)
+ EditableValueHolder component, String validatorId,
+ EditableValueHolderAttachedObjectHandler attachedObjectHandler)
{
if (shouldAddEnclosingValidator(mctx, context, component, validatorId))
{
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java?rev=1301672&r1=1301671&r2=1301672&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java Fri Mar 16 18:00:42 2012
@@ -23,14 +23,13 @@ import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
import javax.faces.component.UIViewRoot;
-import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.TagConfig;
import javax.faces.view.facelets.TagException;
import javax.faces.view.facelets.TagHandler;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage;
+import org.apache.myfaces.view.facelets.FaceletCompositionContext;
import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
/**
@@ -60,8 +59,8 @@ public final class ViewMetadataHandler e
{
throw new TagException(this.tag, "Parent UIComponent "+parent.getId()+" should be instance of UIViewRoot");
}
- if (FaceletViewDeclarationLanguage.
- isBuildingViewMetadata(ctx.getFacesContext()))
+ FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
+ if (mctx.isBuildingViewMetadata())
{
UIComponent metadataFacet = parent.getFacet(UIViewRoot.METADATA_FACET_NAME);
if (metadataFacet == null)
@@ -78,12 +77,14 @@ public final class ViewMetadataHandler e
// (The only tag that needs to do something special is f:event, because in this case
// ComponentHandler.isNew(parent) does not work for UIViewRoot.)
parent.getAttributes().put(FacetHandler.KEY, UIViewRoot.METADATA_FACET_NAME);
+ mctx.startMetadataSection();
try
{
this.nextHandler.apply(ctx, parent);
}
finally
{
+ mctx.endMetadataSection();
parent.getAttributes().remove(FacetHandler.KEY);
}
}