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 2012/10/05 19:14:16 UTC

svn commit: r1394660 - in /myfaces/trinidad/trunk: trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/

Author: arobinson74
Date: Fri Oct  5 17:14:16 2012
New Revision: 1394660

URL: http://svn.apache.org/viewvc?rev=1394660&view=rev
Log:
TRINIDAD-1940

Fix issues introduced with the Trinidad EL resolver

Modified:
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx?rev=1394660&r1=1394659&r2=1394660&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx Fri Oct  5 17:14:16 2012
@@ -81,7 +81,11 @@
                                partialTriggers="reorderLink simpleLink pprLink updatesLink nestedLink">
             <tr:switcher defaultFacet="home" facetName="#{forEachBean.currentExample}">
               <f:facet name="home">
-                <tr:outputText value="Choose an example from the side panel."/>
+                <tr:panelGroupLayout layout="vertical">
+                  <tr:outputText value="Choose an example from the side panel."/>
+                  <tr:outputText value="Note: due to a bug in the MyFaces core code, this will only work with the Mojarra JSF implementation."
+                                 inlineStyle="display: block; padding-top: 12px;"/>
+                </tr:panelGroupLayout>
               </f:facet>
               <f:facet name="simple">
                 <tr:panelGroupLayout layout="vertical">

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java?rev=1394660&r1=1394659&r2=1394660&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java Fri Oct  5 17:14:16 2012
@@ -23,6 +23,7 @@ import java.beans.FeatureDescriptor;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+
 import java.util.List;
 import java.util.Map;
 
@@ -30,8 +31,6 @@ import javax.el.ELContext;
 import javax.el.ELResolver;
 
 import org.apache.myfaces.trinidad.context.RequestContext;
-import org.apache.myfaces.trinidad.model.CollectionModel;
-
 
 /**
  * ELResolver implementation for Trinidad.  Serves up:
@@ -53,10 +52,8 @@ public class TrinidadELResolver
   {
   }
 
-  public Object getValue(
-    ELContext elContext,
-    Object    base,
-    Object    property)
+  public Object getValue(ELContext elContext, Object base, 
+                         Object property)
   {
     if (base == null)
     {
@@ -74,22 +71,12 @@ public class TrinidadELResolver
         return RequestContext.getCurrentInstance().getPageFlowScope();
       }
     }
-    else if (base != null && base instanceof CollectionModel)
-    {
-      elContext.setPropertyResolved(true);
-      CollectionModel model = (CollectionModel)base;
-      return (property instanceof Integer) ?
-        model.getRowData(((Integer)property).intValue()) :
-        model.getRowData(property);
-    }
     
     return null;
   }
 
-  public Class<?> getType(
-    ELContext elContext,
-    Object    base,
-    Object    property)
+  public Class<?> getType(ELContext elContext, Object base, 
+                          Object property)
   {
     if (base == null)
     {
@@ -107,11 +94,6 @@ public class TrinidadELResolver
         return Map.class;
       }
     }
-    else if (base != null && base instanceof CollectionModel)
-    {
-      elContext.setPropertyResolved(true);
-      return Object.class;
-    }
     
     return null;
   }
@@ -128,16 +110,9 @@ public class TrinidadELResolver
     }
   }
 
-  public boolean isReadOnly(
-    ELContext elContext,
-    Object    base,
-    Object    property)
+  public boolean isReadOnly(ELContext elContext, Object base, 
+                            Object property)
   {
-    if (base != null && base instanceof CollectionModel)
-    {
-      return true;
-    }
-
     return false;
   }
 
@@ -150,60 +125,14 @@ public class TrinidadELResolver
         _featureDescriptorList = _createFeatureDescriptorList();
       return _featureDescriptorList.iterator();
     }
-    else if (base != null && base instanceof CollectionModel)
-    {
-      CollectionModel model = (CollectionModel)base;
-      int rowCount = model.getRowCount();
-
-      List<FeatureDescriptor> list = rowCount == -1 ?
-        new ArrayList<FeatureDescriptor>() :
-        new ArrayList<FeatureDescriptor>(rowCount);
-
-      Object origRowKey = model.getRowKey();
-      try
-      {
-        for (int rowIndex = 0; model.isRowAvailable(rowIndex); ++rowIndex)
-        {
-          model.setRowIndex(rowIndex);
-
-          String name = Integer.toString(rowIndex);
-          FeatureDescriptor descriptor = new FeatureDescriptor();
-
-          descriptor.setName(name);
-          descriptor.setDisplayName(name);
-          descriptor.setShortDescription("");
-          descriptor.setExpert(false);
-          descriptor.setHidden(false);
-          descriptor.setPreferred(true);
-          descriptor.setValue("type", Integer.class);
-          descriptor.setValue("resolvableAtDesignTime", Boolean.TRUE);
-
-          list.add(descriptor);
-        }
-      }
-      finally
-      {
-        model.setRowKey(origRowKey);
-      }
-
-      return list.iterator();
-    }
     
     return null;
   }
 
-  public Class<?> getCommonPropertyType(
-    ELContext elContext,
-    Object    base)
+  public Class<?> getCommonPropertyType(ELContext elContext, Object base)
   {
     if (base == null)
-    {
       return String.class;
-    }
-    else if (base != null && base instanceof CollectionModel)
-    {
-      return Object.class;
-    }
     
     return null;
   }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java?rev=1394660&r1=1394659&r2=1394660&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java Fri Oct  5 17:14:16 2012
@@ -31,6 +31,7 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.el.ELContext;
+import javax.el.PropertyNotWritableException;
 import javax.el.ValueExpression;
 import javax.el.VariableMapper;
 
@@ -577,6 +578,13 @@ public class ForEachTag
       {
         return null;
       }
+      else if (items instanceof CollectionModel)
+      {
+        // We do not have an EL resolver for the CollectionModel to get values by row index
+        // or by row key. Therefore, we must just go after the value manually.
+        CollectionModel model = (CollectionModel)items;
+        return model.getRowData(_key);
+      }
 
       context.setPropertyResolved(false);
       return context.getELResolver().getValue(context, items, _key);
@@ -589,6 +597,12 @@ public class ForEachTag
 
       if (items != null)
       {
+        if (items instanceof CollectionModel)
+        {
+          // There is no support for setting row data on the collection model
+          throw new PropertyNotWritableException();
+        }
+
         context.setPropertyResolved(false);
         context.getELResolver().setValue(context, items, _key, value);
       }
@@ -602,6 +616,10 @@ public class ForEachTag
       {
         return true;
       }
+      else if (items instanceof CollectionModel)
+      {
+        return true;
+      }
 
       return context.getELResolver().isReadOnly(context, items, _key);
     }