Author: dmorozov
Date: 2008-12-02 11:07:06 -0500 (Tue, 02 Dec 2008)
New Revision: 11491
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java
Log:
https://jira.jboss.org/jira/browse/RF-4473
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java 2008-12-02
16:03:29 UTC (rev 11490)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java 2008-12-02
16:07:06 UTC (rev 11491)
@@ -22,7 +22,9 @@
package org.ajax4jsf.webapp.taglib;
import javax.faces.component.ActionSource;
+import javax.faces.component.ActionSource2;
import javax.faces.event.ActionEvent;
+import javax.faces.event.MethodExpressionActionListener;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.el.LegacyMethodBinding;
@@ -30,6 +32,7 @@
import com.sun.facelets.tag.Metadata;
import com.sun.facelets.tag.MetadataTarget;
import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.util.FacesAPI;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
@@ -56,7 +59,23 @@
AjaxActionsRule.ACTION_SIG)));
}
}
+
+ final static class ActionMapper2 extends Metadata {
+ private final TagAttribute attr;
+
+ public ActionMapper2(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ActionSource2) instance).setActionExpression(this.attr
+ .getMethodExpression(ctx, String.class,
+ AjaxActionsRule.ACTION_SIG));
+ }
+
+ }
+
public final static class ActionListenerMapper extends Metadata {
private final TagAttribute attr;
@@ -73,7 +92,25 @@
}
}
+
+ final static class ActionListenerMapper2 extends Metadata {
+ private final TagAttribute attr;
+
+ public ActionListenerMapper2(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ActionSource2) instance)
+ .addActionListener(new MethodExpressionActionListener(
+ this.attr.getMethodExpression(ctx, null,
+ AjaxActionsRule.ACTION_LISTENER_SIG)));
+
+ }
+
+ }
+
public final static AjaxActionsRule instance = new AjaxActionsRule();
public AjaxActionsRule() {
@@ -83,14 +120,23 @@
public Metadata applyRule(String name, TagAttribute attribute,
MetadataTarget meta) {
if (meta.isTargetInstanceOf(ActionSource.class)) {
+ boolean elSupport = FacesAPI.getComponentVersion(meta.getTargetClass()) >=
12;
if ("action".equals(name)) {
- return new ActionMapper(attribute);
+ if (elSupport && meta.isTargetInstanceOf(ActionSource2.class)) {
+ return new ActionMapper2(attribute);
+ } else {
+ return new ActionMapper(attribute);
+ }
}
if ("actionListener".equals(name)) {
- return new ActionListenerMapper(attribute);
+ if (elSupport && meta.isTargetInstanceOf(ActionSource2.class)) {
+ return new ActionListenerMapper2(attribute);
+ } else {
+ return new ActionListenerMapper(attribute);
+ }
}
}
return null;