myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mstar...@apache.org
Subject svn commit: r1099243 - in /myfaces/trinidad/branches/2.0.0.1-branch: trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/re...
Date Tue, 03 May 2011 21:02:54 GMT
Author: mstarets
Date: Tue May  3 21:02:51 2011
New Revision: 1099243

URL: http://svn.apache.org/viewvc?rev=1099243&view=rev
Log:
TRINIDAD-2073 - Session based changes fail to apply for facelets VDL. Thanks Prakash Udupa
for the patch!

Modified:
    myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java
    myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
    myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
    myfaces/trinidad/branches/2.0.0.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java

Modified: myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java?rev=1099243&r1=1099242&r2=1099243&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java
(original)
+++ myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/change/RowKeySetAttributeChange.java
Tue May  3 21:02:51 2011
@@ -1,5 +1,7 @@
 package org.apache.myfaces.trinidad.change;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Map;
 
 import javax.el.ValueExpression;
@@ -9,6 +11,7 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.RowKeySet;
 
 /**
@@ -74,6 +77,21 @@ public final class RowKeySetAttributeCha
 
   private void _updateRowKeySetInPlace(UIComponent component, String attrName, RowKeySet
newValue)
   {
+    // Take a snapshot of the remembered keys, so we are insulated from any heayweight implementations
of RowKeySet 
+    Collection<Object> newKeySet = new HashSet<Object>();
+
+    try 
+    {
+      newKeySet.addAll(newValue);
+    }
+    // addAll() can raise a few exceptions, a behavior we can't reliably predict for different
possible implementations 
+    //  of RowKeySet during invokeOnComponent, we do not want to propogate either, gracefully
fail change attempt.
+    catch (Exception e) 
+    {
+      _LOG.warning("FAILED_ROWKEYSETATTRIBUTECHANGE", e.getClass());
+      return;
+    }
+
     ValueExpression oldExpression = component.getValueExpression(attrName);
     
     // due to bug in how the trinidad table and tree handle their RowKeySets, always use
@@ -85,7 +103,7 @@ public final class RowKeySetAttributeCha
     context.getViewRoot().invokeOnComponent(
       context,
       _clientId,
-      new GetOldValueAndUpdate(oldExpression, attrName, newValue));
+      new GetOldValueAndUpdate(oldExpression, attrName, newKeySet));
   }
     
   /**
@@ -93,11 +111,11 @@ public final class RowKeySetAttributeCha
    */
   private static final class GetOldValueAndUpdate implements ContextCallback
   {
-    public GetOldValueAndUpdate(ValueExpression expression, String attributeName, RowKeySet
newKeySet)
+    public GetOldValueAndUpdate(ValueExpression expression, String attributeName, Collection<Object>
newKeySet)
     {
       _expression = expression;
       _attributeName = attributeName;
-      _newKeySet  = newKeySet;
+      _newKeySet = newKeySet;
     }
     
     public void invokeContextCallback(FacesContext context,
@@ -143,10 +161,11 @@ public final class RowKeySetAttributeCha
     
     private final ValueExpression _expression;
     private final String _attributeName;
-    private final RowKeySet _newKeySet;
+    private final Collection<Object> _newKeySet;
   }
 
   private static final long serialVersionUID = 1L;
+  static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(RowKeySetAttributeChange.class);
   
   private final String _clientId;
 }

Modified: myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java?rev=1099243&r1=1099242&r2=1099243&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
(original)
+++ myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
Tue May  3 21:02:51 2011
@@ -35,17 +35,13 @@ import javax.el.ValueExpression;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
 import javax.faces.webapp.UIComponentELTag;
 
 import javax.servlet.jsp.JspException;
 
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
-import org.apache.myfaces.trinidad.change.ChangeManager;
 import org.apache.myfaces.trinidad.component.UIXComponent;
-import org.apache.myfaces.trinidad.component.UIXDocument;
 import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
@@ -79,28 +75,6 @@ abstract public class UIXComponentELTag 
   }
 
   @Override
-  public int doEndTag() throws JspException
-  {
-    UIComponent component = getComponentInstance();
-    
-    // Apply changes once we have a stable UIComponent subtree is completely 
-    //  created. End of document tag is a best bet.
-    if (component instanceof UIXDocument)
-    {
-      if (getCreated()) 
-      {
-        ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
-        // Used by SessionChangeManager to confirm that the state was not restored.
-        ec.getRequestMap().put(DOCUMENT_CREATED_KEY, Boolean.TRUE);
-      }
-      ChangeManager cm = RequestContext.getCurrentInstance().getChangeManager();
-      cm.applyComponentChangesForCurrentView(FacesContext.getCurrentInstance());
-    }
-    return super.doEndTag();
-  }
-
-
-  @Override
   protected final void setProperties(UIComponent component)
   {
     if (component instanceof UIViewRoot)
@@ -495,6 +469,8 @@ abstract public class UIXComponentELTag 
     return sdf;
   }
 
+  //  No more used anywhere in Trinidad code, so deprecate since 2.0.x.
+  @Deprecated
   public static final String DOCUMENT_CREATED_KEY = "org.apache.myfaces.trinidad.DOCUMENTCREATED";
 
   private MethodExpression  _attributeChangeListener;

Modified: myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=1099243&r1=1099242&r2=1099243&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
(original)
+++ myfaces/trinidad/branches/2.0.0.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
Tue May  3 21:02:51 2011
@@ -39,6 +39,9 @@
 <!-- CONVERSION_CLASS_TYPE -->
 <resource key="CONVERSION_CLASS_TYPE">Conversion class: {0} not of type {1}</resource>
 
+<!-- FAILED_ROWKEYSETATTRIBUTECHANGE -->
+<resource key="FAILED_ROWKEYSETATTRIBUTECHANGE">Failed to apply row key set attribute
change. Reason : {1}</resource>
+
 <!-- UNABLE_INSTANTIATE_CONVERTERCLASS -->
 <resource key="UNABLE_INSTANTIATE_CONVERTERCLASS">Unable to instantiate converterClass:
{0}</resource>
 

Modified: myfaces/trinidad/branches/2.0.0.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java?rev=1099243&r1=1099242&r2=1099243&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
(original)
+++ myfaces/trinidad/branches/2.0.0.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
Tue May  3 21:02:51 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.myfaces.trinidadinternal.application;
 
+import java.beans.BeanInfo;
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -30,18 +32,22 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.faces.application.Resource;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
+import javax.faces.view.StateManagementStrategy;
 import javax.faces.view.ViewDeclarationLanguage;
 import javax.faces.view.ViewDeclarationLanguageFactory;
+import javax.faces.view.ViewMetadata;
 
+import org.apache.myfaces.trinidad.change.ChangeManager;
 import org.apache.myfaces.trinidad.context.RequestContext;
-import org.apache.myfaces.trinidad.render.InternalView;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.render.InternalView;
+
 
 public class ViewDeclarationLanguageFactoryImpl
   extends ViewDeclarationLanguageFactory
@@ -76,7 +82,12 @@ public class ViewDeclarationLanguageFact
     // implementation
     viewId = _getPath(context, viewId);
     
-    return getWrapped().getViewDeclarationLanguage(viewId);
+    ViewDeclarationLanguage vdl = getWrapped().getViewDeclarationLanguage(viewId);
+    // Possiblity of nested VDLs of the same kind
+    if (vdl instanceof ChangeApplyingVDLWrapper) 
+      return vdl;
+
+    return new ChangeApplyingVDLWrapper(getWrapped().getViewDeclarationLanguage(viewId));
   }
   
   @Override
@@ -281,4 +292,70 @@ public class ViewDeclarationLanguageFact
   {
     public InternalView getInternalView(FacesContext context, String viewId);
   }
+  
+  /**
+   * The VDL implementation that wraps an underlying VDL and additionally applies component
changes based 
+   * customization (usually SessionChangeManager). Note that this works both for Facelets
and JSPs.
+   */
+  private static class ChangeApplyingVDLWrapper extends ViewDeclarationLanguage
+  {
+    ChangeApplyingVDLWrapper(ViewDeclarationLanguage wrapped)
+    {
+      _wrapped = wrapped;
+    }
+
+    @Override
+    public BeanInfo getComponentMetadata(FacesContext facesContext, Resource resource)
+    {
+      return _wrapped.getComponentMetadata(facesContext, resource);
+    }
+
+    @Override
+    public ViewMetadata getViewMetadata(FacesContext facesContext, String string)
+    {
+      return _wrapped.getViewMetadata(facesContext, string);
+    }
+
+    @Override
+    public Resource getScriptComponentResource(FacesContext facesContext, Resource resource)
+    {
+      return _wrapped.getScriptComponentResource(facesContext, resource);
+    }
+
+    @Override
+    public UIViewRoot createView(FacesContext facesContext, String string)
+    {
+      return _wrapped.createView(facesContext, string);
+    }
+
+    @Override
+    public UIViewRoot restoreView(FacesContext facesContext, String string)
+    {
+      return _wrapped.restoreView(facesContext, string);
+    }
+
+    @Override
+    public void buildView(FacesContext facesContext, UIViewRoot uiViewRoot)
+      throws IOException
+    {
+      _wrapped.buildView(facesContext, uiViewRoot);
+      ChangeManager cm = RequestContext.getCurrentInstance().getChangeManager();
+      cm.applyComponentChangesForCurrentView(FacesContext.getCurrentInstance());
+    }
+
+    @Override
+    public void renderView(FacesContext facesContext, UIViewRoot uiViewRoot)
+      throws IOException
+    {
+      _wrapped.renderView(facesContext, uiViewRoot);
+    }
+
+    @Override
+    public StateManagementStrategy getStateManagementStrategy(FacesContext facesContext,
String string)
+    {
+      return _wrapped.getStateManagementStrategy(facesContext, string);
+    }
+    
+    private final ViewDeclarationLanguage _wrapped;
+  }
 }



Mime
View raw message