myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mstar...@apache.org
Subject svn commit: r1087870 - in /myfaces/trinidad/trunk: trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
Date Fri, 01 Apr 2011 19:54:52 GMT
Author: mstarets
Date: Fri Apr  1 19:54:52 2011
New Revision: 1087870

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

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java?rev=1087870&r1=1087869&r2=1087870&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
Fri Apr  1 19:54:52 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/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java?rev=1087870&r1=1087869&r2=1087870&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/ViewDeclarationLanguageFactoryImpl.java
Fri Apr  1 19:54:52 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