You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/02/13 09:47:58 UTC

svn commit: r1445504 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java

Author: lofwyr
Date: Wed Feb 13 08:47:58 2013
New Revision: 1445504

URL: http://svn.apache.org/r1445504
Log:
TOBAGO-1221: Remove JSF 1.1 and JDK 1.4 support

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java?rev=1445504&r1=1445503&r2=1445504&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtils.java Wed Feb 13 08:47:58 2013
@@ -21,10 +21,8 @@ package org.apache.myfaces.tobago.util;
 
 import org.apache.myfaces.tobago.context.ClientProperties;
 
-import javax.faces.application.Application;
+import javax.el.ELContext;
 import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.el.VariableResolver;
 
 public final class VariableResolverUtils {
 
@@ -36,15 +34,8 @@ public final class VariableResolverUtils
    * Returns the requested object configured in the faces-config or from library.
    */
   public static Object resolveVariable(FacesContext context, String variable) {
-// TODO: JSF 1.2
-//    if (FacesVersion.supports12()) {
-//      final ELContext elContext = context.getELContext();
-//      return elContext.getELResolver().getValue(elContext, null, variable);
-//    } else {
-      final Application application = context.getApplication();
-      final VariableResolver variableResolver = application.getVariableResolver();
-      return variableResolver.resolveVariable(context, variable);
-//    }
+    final ELContext elContext = context.getELContext();
+    return elContext.getELResolver().getValue(elContext, null, variable);
   }
 
   /**
@@ -61,14 +52,7 @@ public final class VariableResolverUtils
    * Also useful to enforce a new creation of a managed-bean.
    */
   public static void clearVariable(FacesContext context, String variable) {
-// TODO: JSF 1.2
-//    if (FacesVersion.supports12()) {
-//      final ELContext elContext = context.getELContext();
-//      elContext.getELResolver().setValue(elContext, null, variable, null);
-//    } else {
-      final Application application = context.getApplication();
-      final ValueBinding valueBinding = application.createValueBinding("#{" + variable + "}");
-      valueBinding.setValue(context, null);
-//    }
+    final ELContext elContext = context.getELContext();
+    elContext.getELResolver().setValue(elContext, null, variable, null);
   }
 }

Modified: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java?rev=1445504&r1=1445503&r2=1445504&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java Wed Feb 13 08:47:58 2013
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.facele
 
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.el.ELAdaptor;
-import com.sun.facelets.el.LegacyMethodBinding;
 import com.sun.facelets.el.TagMethodExpression;
 import com.sun.facelets.tag.TagAttribute;
 import com.sun.facelets.tag.TagConfig;
@@ -45,10 +44,14 @@ import javax.el.MethodExpression;
 import javax.el.ValueExpression;
 import javax.faces.FacesException;
 import javax.faces.component.ActionSource;
+import javax.faces.component.ActionSource2;
 import javax.faces.component.EditableValueHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.component.ValueHolder;
 import javax.faces.convert.Converter;
+import javax.faces.event.MethodExpressionActionListener;
+import javax.faces.event.MethodExpressionValueChangeListener;
+import javax.faces.validator.MethodExpressionValidator;
 import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
 
@@ -100,7 +103,7 @@ public final class AttributeHandler exte
           } else {
             result = StringUtils.isEmpty(expressionString);
           }
-          parent.getAttributes().put(name.getValue(), Boolean.valueOf(result));
+          parent.getAttributes().put(name.getValue(), result);
         } else if ("isSet".equals(mode.getValue())) {
           boolean result = true;
           String expressionString = value.getValue();
@@ -123,7 +126,7 @@ public final class AttributeHandler exte
           } else {
             result = StringUtils.isNotEmpty(expressionString);
           }
-          parent.getAttributes().put(name.getValue(), Boolean.valueOf(result));
+          parent.getAttributes().put(name.getValue(), result);
         } else if ("action".equals(mode.getValue())) {
           String expressionString = value.getValue();
           while (isSimpleExpression(expressionString)) {
@@ -148,8 +151,7 @@ public final class AttributeHandler exte
             ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
             MethodExpression action = new TagMethodExpression(value, expressionFactory.createMethodExpression(
                 faceletContext, expressionString, String.class, ComponentUtils.ACTION_ARGS));
-            // TODO jsf 1.2
-            ((ActionSource) parent).setAction(new LegacyMethodBinding(action));
+            ((ActionSource2) parent).setActionExpression(action);
           }
         } else if ("actionListener".equals(mode.getValue())) {
           String expressionString = value.getValue();
@@ -177,8 +179,7 @@ public final class AttributeHandler exte
             ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
             MethodExpression actionListener = new TagMethodExpression(value, expressionFactory.createMethodExpression(
                 faceletContext, expressionString, null, ComponentUtils.ACTION_LISTENER_ARGS));
-            // TODO jsf 1.2
-            ((ActionSource) parent).setActionListener(new LegacyMethodBinding(actionListener));
+            ((ActionSource) parent).addActionListener(new MethodExpressionActionListener(actionListener));
           }
         } else if ("actionFromValue".equals(mode.getValue())) {
           if (!value.isLiteral()) {
@@ -248,30 +249,27 @@ public final class AttributeHandler exte
         } else if (parent instanceof EditableValueHolder && Attributes.VALIDATOR.equals(nameValue)) {
           MethodExpression methodExpression = getMethodExpression(faceletContext, null, ComponentUtils.VALIDATOR_ARGS);
           if (methodExpression != null) {
-            // TODO jsf 1.2
-            ((EditableValueHolder) parent).setValidator(new LegacyMethodBinding(methodExpression));
+            ((EditableValueHolder) parent).addValidator(new MethodExpressionValidator(methodExpression));
           }
         } else if (parent instanceof EditableValueHolder
             && Attributes.VALUE_CHANGE_LISTENER.equals(nameValue)) {
           MethodExpression methodExpression =
               getMethodExpression(faceletContext, null, ComponentUtils.VALUE_CHANGE_LISTENER_ARGS);
           if (methodExpression != null) {
-            // TODO jsf 1.2
-            ((EditableValueHolder) parent).setValueChangeListener(new LegacyMethodBinding(methodExpression));
+            ((EditableValueHolder) parent).addValueChangeListener(
+                new MethodExpressionValueChangeListener(methodExpression));
           }
         } else if (parent instanceof ValueHolder && Attributes.CONVERTER.equals(nameValue)) {
           setConverter(faceletContext, parent, nameValue);
         } else if (parent instanceof ActionSource && Attributes.ACTION.equals(nameValue)) {
           MethodExpression action = getMethodExpression(faceletContext, String.class, ComponentUtils.ACTION_ARGS);
           if (action != null) {
-            // TODO jsf 1.2
-            ((ActionSource) parent).setAction(new LegacyMethodBinding(action));
+            ((ActionSource2) parent).setActionExpression(action);
           }
         } else if (parent instanceof ActionSource && Attributes.ACTION_LISTENER.equals(nameValue)) {
           MethodExpression action = getMethodExpression(faceletContext, null, ComponentUtils.ACTION_LISTENER_ARGS);
           if (action != null) {
-            // TODO jsf 1.2
-            ((ActionSource) parent).setActionListener(new LegacyMethodBinding(action));
+            ((ActionSource) parent).addActionListener(new MethodExpressionActionListener(action));
           }
         } else if (!parent.getAttributes().containsKey(nameValue)) {
           if (value.isLiteral()) {