myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r906185 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets: el/LegacyMethodBinding.java tag/jsf/ActionSourceRule.java
Date Wed, 03 Feb 2010 19:14:41 GMT
Author: lu4242
Date: Wed Feb  3 19:14:41 2010
New Revision: 906185

URL: http://svn.apache.org/viewvc?rev=906185&view=rev
Log:
MYFACES-2530 ActionSourceRule does not deal with jsf 1.1 ActionSouce instances

Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/LegacyMethodBinding.java
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ActionSourceRule.java

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/LegacyMethodBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/LegacyMethodBinding.java?rev=906185&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/LegacyMethodBinding.java
(added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/LegacyMethodBinding.java
Wed Feb  3 19:14:41 2010
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.el;
+
+import java.io.Serializable;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+
+/**
+ * For legacy ActionSources
+ * 
+ * @author Jacob Hookom
+ * @version $Id: LegacyMethodBinding.java,v 1.7 2008/07/13 19:01:43 rlubke Exp $
+ * @deprecated
+ */
+public final class LegacyMethodBinding extends MethodBinding implements
+        Serializable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final MethodExpression m;
+
+    public LegacyMethodBinding(MethodExpression m)
+    {
+        this.m = m;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
+     */
+    public Class getType(FacesContext context) throws MethodNotFoundException
+    {
+        try
+        {
+            return m.getMethodInfo(context.getELContext()).getReturnType();
+        }
+        catch (javax.el.MethodNotFoundException e)
+        {
+            throw new MethodNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext,
+     *      java.lang.Object[])
+     */
+    public Object invoke(FacesContext context, Object[] params)
+            throws EvaluationException, MethodNotFoundException
+    {
+        try
+        {
+            return m.invoke(context.getELContext(), params);
+        }
+        catch (javax.el.MethodNotFoundException e)
+        {
+            throw new MethodNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public String getExpressionString()
+    {
+        return m.getExpressionString();
+    }
+}
\ No newline at end of file

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ActionSourceRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ActionSourceRule.java?rev=906185&r1=906184&r2=906185&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ActionSourceRule.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ActionSourceRule.java
Wed Feb  3 19:14:41 2010
@@ -30,6 +30,7 @@
 import javax.faces.view.facelets.TagAttribute;
 
 import org.apache.myfaces.view.facelets.AbstractFaceletContext;
+import org.apache.myfaces.view.facelets.el.LegacyMethodBinding;
 
 /**
  * 
@@ -42,6 +43,21 @@
 
     public final static Class<?>[] ACTION_LISTENER_SIG = new Class<?>[] { ActionEvent.class
};
 
+    final static class ActionMapper extends Metadata {
+
+        private final TagAttribute attr;
+
+        public ActionMapper(TagAttribute attr) {
+            this.attr = attr;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance) {
+            ((ActionSource) instance).setAction(new LegacyMethodBinding(
+                    this.attr.getMethodExpression(ctx, String.class,
+                            ActionSourceRule.ACTION_SIG)));
+        }
+    }
+    
     final static class ActionMapper2 extends Metadata
     {
         private final TagAttribute _attr;
@@ -58,6 +74,23 @@
         }
     }
 
+    final static class ActionListenerMapper extends Metadata {
+
+        private final TagAttribute attr;
+
+        public ActionListenerMapper(TagAttribute attr) {
+            this.attr = attr;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance) {
+            ((ActionSource) instance)
+                    .setActionListener(new LegacyMethodBinding(this.attr
+                            .getMethodExpression(ctx, null,
+                                    ActionSourceRule.ACTION_LISTENER_SIG)));
+        }
+
+    }
+
     final static class ActionListenerMapper2 extends Metadata
     {
         private final TagAttribute _attr;
@@ -94,12 +127,26 @@
         {
             if ("action".equals(name))
             {
-                return new ActionMapper2(attribute);
+                if (meta.isTargetInstanceOf(ActionSource2.class))
+                {
+                    return new ActionMapper2(attribute);
+                }
+                else
+                {
+                    return new ActionMapper(attribute);
+                }
             }
 
             if ("actionListener".equals(name))
             {
-                return new ActionListenerMapper2(attribute);
+                if (meta.isTargetInstanceOf(ActionSource2.class))
+                {
+                    return new ActionListenerMapper2(attribute);
+                }
+                else
+                {
+                    return new ActionListenerMapper(attribute);
+                }
             }
         }
         



Mime
View raw message