myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjhow...@apache.org
Subject svn commit: r811058 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/ impl/src/main/java/org/apache/myfaces/config/ impl/src/main/java/org/apache/myfaces/config/impl/digester/ impl/src/main/java/org/apache/myfaces/config/impl/digester/...
Date Thu, 03 Sep 2009 17:48:07 GMT
Author: cjhoward
Date: Thu Sep  3 17:48:06 2009
New Revision: 811058

URL: http://svn.apache.org/viewvc?rev=811058&view=rev
Log:
MYFACES-2340 - bugs with CC attributes, state saving

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
(original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
Thu Sep  3 17:48:06 2009
@@ -244,6 +244,17 @@
                 ValueExpression ve = _component.getValueExpression((String) key);
                 if (ve != null)
                 {
+                    if (getUnderlyingMap().get ("org.apache.myfaces.COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION")
!= null)
+                    {
+                        // FIXME: this is "technically" a hack for the composite component
attribute
+                        // EL resolver.  #{cc.attrs} is supposed to wrap this map and call
getValue()
+                        // and setValue() on the ValueExpressions it returns... but the spec
says that
+                        // this method always needs to evaluate ValueExpressions, and therefore
the EL
+                        // resolver never even gets to see ValuExpressions.
+                        
+                        return ve;
+                    }
+                    
                     value = ve.getValue(FacesContext.getCurrentInstance().getELContext());
                 }
                 else

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
Thu Sep  3 17:48:06 2009
@@ -269,4 +269,9 @@
      * @return the partial traversal class name
      */
     public String getPartialTraversal ();
+    
+    /**
+     * @return Faces application version.
+     */
+    public String getFacesVersion ();
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
Thu Sep  3 17:48:06 2009
@@ -1765,7 +1765,8 @@
         {
             runtimeConfig.addFacesConfigElResolver((ELResolver)ClassUtils.newInstance(className,
ELResolver.class));
         }
-
+        
+        runtimeConfig.setFacesVersion (dispenser.getFacesVersion());
     }
 
     private void removePurgedBeansFromSessionAndApplication(RuntimeConfig runtimeConfig)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java Thu
Sep  3 17:48:06 2009
@@ -57,7 +57,9 @@
     private boolean _navigationRulesChanged = false;
     private final Map<String, ResourceBundle> _resourceBundles = new HashMap<String,
ResourceBundle>();
     private final Map<String, ManagedBean> _oldManagedBeans = new HashMap<String,
ManagedBean>();
-
+    
+    private String _facesVersion;
+    
     private CompositeELResolver facesConfigElResolvers;
     private CompositeELResolver applicationElResolvers;
 
@@ -264,4 +266,14 @@
     {
         _oldManagedBeans.clear();
     }
+    
+    public String getFacesVersion ()
+    {
+        return _facesVersion;
+    }
+    
+    void setFacesVersion (String facesVersion)
+    {
+        _facesVersion = facesVersion;
+    }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
Thu Sep  3 17:48:06 2009
@@ -63,6 +63,7 @@
     private String defaultRenderKitId;
     private String messageBundle;
     private String partialTraversal;
+    private String facesVersion;
     
     private LocaleConfig localeConfig;
 
@@ -196,6 +197,7 @@
         lifecyclePhaseListeners.addAll(config.getLifecyclePhaseListener());
         managedBeans.addAll(config.getManagedBeans());
         navigationRules.addAll(config.getNavigationRules());
+        facesVersion = config.getVersion();
     }
 
     /**
@@ -603,4 +605,9 @@
     {
         return behaviors;
     }
+    
+    public String getFacesVersion ()
+    {
+        return facesVersion;
+    }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
Thu Sep  3 17:48:06 2009
@@ -48,6 +48,7 @@
         digester.addObjectCreate("faces-config", FacesConfig.class);
         // 2.0 specific start
         digester.addSetProperties("faces-config", "metadata-complete", "metadataComplete");
+        digester.addSetProperties("faces-config", "version", "version");
         // 2.0 specific end
         // 2.0 config ordering name start
         digester.addCallMethod("faces-config/name", "setName", 0);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
Thu Sep  3 17:48:06 2009
@@ -41,6 +41,7 @@
     private List<Behavior> behaviors = new ArrayList<Behavior>();
     
     private String metadataComplete;
+    private String version;
     //Ordering variables
     //This information are not merged, and helps
     //with preprocessing of faces-config files
@@ -187,4 +188,14 @@
     {
         this.metadataComplete = metadataComplete;
     }
+    
+    public String getVersion ()
+    {
+        return version;
+    }
+    
+    public void setVersion (String version)
+    {
+        this.version = version;
+    }
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
Thu Sep  3 17:48:06 2009
@@ -47,6 +47,8 @@
     
     private static final String COMPOSITE_COMPONENT_ATTRIBUTES_MAPS = 
         "org.apache.myfaces.COMPOSITE_COMPONENT_ATTRIBUTES_MAPS";
+    private static final String COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION =
+        "org.apache.myfaces.COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION";
     
     @Override
     public Class<?> getCommonPropertyType(ELContext context, Object base)
@@ -203,7 +205,7 @@
         @Override
         public ValueExpression getExpression(String name)
         {
-            Object valueExpr = _originalMap.get(name);
+            Object valueExpr = getAsValueExpression (name);
 
             // TODO: spec's not clear, I guess this is what we're supposed to do...
 
@@ -238,7 +240,7 @@
         @Override
         public Object get(Object key)
         {
-            Object obj = _originalMap.get(key);
+            Object obj = getAsValueExpression (key);
 
             // Per the spec, if the result is a ValueExpression, evaluate it and return the
value.
 
@@ -273,7 +275,29 @@
                 }
             }
         }
-
+        
+        private Object getAsValueExpression (Object key)
+        {
+            Object obj;
+            
+            // FIXME: this is a hack, but I think it's necessary.  The component attributes
map
+            // that this class wraps requires that all ValueExpressions be evaluated before
they're
+            // returned, but the get() and put() methods defined in this class rely on ValueExpressions
+            // being returned so the underlying beans (if specified) can be updated with
new values.
+            // This may be something to notify the EG about.
+            
+            // The presence of this attribute will tell the component attributes map not
to evaluate
+            // ValueExpressions.
+            
+            _originalMap.put (COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION, Boolean.TRUE);
+            
+            obj = _originalMap.get (key);
+            
+            _originalMap.remove (COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION);
+            
+            return obj;
+        }
+        
         @Override
         public boolean isEmpty()
         {
@@ -289,7 +313,7 @@
         @Override
         public Object put(String key, Object value)
         {
-            Object obj = _originalMap.get(key);
+            Object obj = getAsValueExpression (key);
 
             // Per the spec, if the result is a ValueExpression, call setValue().
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
Thu Sep  3 17:48:06 2009
@@ -104,11 +104,13 @@
         // Per the spec: build the view.
         
         try {
-            view = vdl.createView (context, viewId);
+            view = vdl.getViewMetadata (context, viewId).createMetadataView (context);
             
-            vdl.buildView (context, view);
+            context.setViewRoot (view); 
             
-            context.setViewRoot (view);
+            context.setProcessingEvents (true);
+            vdl.buildView (context, view);
+            context.setProcessingEvents (false);
         }
         
         catch (Throwable e) {
@@ -234,6 +236,11 @@
     private void restoreStateFromMap(final FacesContext context, final Map<String,Object>
states,
             final UIComponent component)
     {
+        if (states == null)
+        {
+            return;
+        }
+        
         //Restore view
         Object state = states.get(component.getClientId());
         if (state != null)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
Thu Sep  3 17:48:06 2009
@@ -78,6 +78,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.application.DefaultViewHandlerSupport;
 import org.apache.myfaces.application.ViewHandlerSupport;
+import org.apache.myfaces.config.RuntimeConfig;
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.myfaces.shared_impl.util.StringUtils;
 import org.apache.myfaces.view.ViewDeclarationLanguageBase;
@@ -1572,10 +1573,18 @@
 
     private void _initializeMode(ExternalContext context)
     {
+        String facesVersion = RuntimeConfig.getCurrentInstance(context).getFacesVersion();
+        boolean partialStateSavingDefault;
+        
+        // Per spec section 11.1.3, the default value for the partial state saving feature
needs
+        // to be true if 2.0, false otherwise.
+        
+        partialStateSavingDefault = facesVersion.equals ("2.0");
+        
         // In jsf 2.0 this code evolve as PartialStateSaving feature
         //_buildBeforeRestore = _getBooleanParameter(context, PARAM_BUILD_BEFORE_RESTORE,
false);
         _partialStateSaving = _getBooleanParameter(context, 
-                StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, null, false);
+                StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, null, partialStateSavingDefault);
         
         String [] viewIds = StringUtils.splitShortString(_getStringParameter(context,
                 StateManager.FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME, null), ',');
@@ -1630,8 +1639,13 @@
 
                 String viewId = getViewId();
                 UIViewRoot view = createView(context, viewId);
+                
+                // FIXME: spec doesn't say that this is necessary, but we blow up later if
+                // the viewroot isn't available from the FacesContext.
+                
+                context.setViewRoot(view);
                 buildView(context, view);
-
+                
                 return view;
             }
             catch (IOException ioe)

Modified: myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd?rev=811058&r1=811057&r2=811058&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
(original)
+++ myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
Thu Sep  3 17:48:06 2009
@@ -627,6 +627,7 @@
     <xsd:simpleType name="faces-config-versionType">
         <xsd:restriction base="xsd:token">
             <xsd:enumeration value="1.2"/>
+            <xsd:enumeration value="2.0"/>
         </xsd:restriction>
     </xsd:simpleType>
 



Mime
View raw message