Author: nbelaevski
Date: 2008-05-02 20:11:59 -0400 (Fri, 02 May 2008)
New Revision: 8421
Modified:
trunk/ui/core/src/main/config/component/actionParameter.xml
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
Log:
http://jira.jboss.com/jira/browse/RF-3110
Modified: trunk/ui/core/src/main/config/component/actionParameter.xml
===================================================================
--- trunk/ui/core/src/main/config/component/actionParameter.xml 2008-05-02 19:34:22 UTC
(rev 8420)
+++ trunk/ui/core/src/main/config/component/actionParameter.xml 2008-05-03 00:11:59 UTC
(rev 8421)
@@ -89,6 +89,11 @@
<property hidden="true">
<name>assignToBinding</name>
</property>
- </component>
+ <property exist="true" el="true" elonly="true"
existintag="true">
+ <name>actionListener</name>
+ <classname>javax.el.MethodExpression</classname>
+ <methodargs>javax.faces.event.ActionEvent</methodargs>
+ </property>
+ </component>
</components>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java 2008-05-02
19:34:22 UTC (rev 8420)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java 2008-05-03
00:11:59 UTC (rev 8421)
@@ -22,6 +22,7 @@
package org.ajax4jsf.component;
import javax.el.ELContext;
+import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.UIComponentBase;
@@ -60,6 +61,21 @@
/** ********************************************************* */
/***************************************************************************
+ * Action listener to call after binding has been updated
+ */
+ private MethodExpression _actionListener = null;
+
+ public MethodExpression getActionListener() {
+ return _actionListener;
+ }
+
+ public void setActionListener(MethodExpression actionListener) {
+ this._actionListener = actionListener;
+ }
+
+ /** ********************************************************* */
+
+ /***************************************************************************
* Converter for update value with this parameter
*/
private Converter _converter = null;
@@ -156,7 +172,11 @@
}
if (null != requestValue) {
updateBinding.setValue(elContext, requestValue);
+ }
+ MethodExpression listener = getActionListener();
+ if (listener != null) {
+ listener.invoke(elContext, new Object[] {actionEvent});
}
}
}
@@ -196,7 +216,8 @@
_noEscape = (Boolean) values[2];
_converter = (Converter) UIComponentBase.restoreAttachedState(context,
values[3]);
- ;
+ _actionListener = (MethodExpression) UIComponentBase.restoreAttachedState(context,
+ values[4]);
}
@@ -206,13 +227,14 @@
* @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
*/
public Object saveState(FacesContext context) {
- Object values[] = new Object[4];
+ Object values[] = new Object[5];
values[0] = super.saveState(context);
// save fields values
values[1] = UIComponentBase
.saveAttachedState(context, _assignToBinding);
values[2] = _noEscape;
values[3] = UIComponentBase.saveAttachedState(context, _converter);
+ values[4] = UIComponentBase.saveAttachedState(context, _actionListener);
return ((Object) (values));
}
Modified:
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2008-05-02
19:34:22 UTC (rev 8420)
+++
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2008-05-03
00:11:59 UTC (rev 8421)
@@ -26,6 +26,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIActionParameter;
@@ -68,6 +69,8 @@
return new DynamicConverterMetadata(attribute);
}
+ } else if ("actionListener".equals(name)) {
+ return new ActionListenerMetadata(attribute);
}
}
@@ -119,10 +122,27 @@
}
}
+ final static class ActionListenerMetadata extends Metadata {
+ private static final Class[] SIGNATURE = new Class[] {ActionEvent.class};
+
+ private final TagAttribute attribute;
+
+ public ActionListenerMetadata(TagAttribute attribute) {
+ super();
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setActionListener(
+ attribute.getMethodExpression(ctx, null, SIGNATURE));
+ }
+ };
+
private TagAttribute _assignTo;
private TagAttribute _converter;
-
+ private TagAttribute _actionListener;
+
/**
* @param config
*/
@@ -130,12 +150,19 @@
super(config);
_assignTo = getAttribute("assignTo");
_converter = getAttribute("converter");
+ _actionListener = getAttribute("actionListener");
+
if(null != _assignTo) {
if (_assignTo.isLiteral()) {
throw new TagAttributeException(this.tag, this._assignTo,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
}
-
}
+
+ if (null != _actionListener) {
+ if (_actionListener.isLiteral()) {
+ throw new TagAttributeException(this.tag, this._actionListener,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
+ }
+ }
// TODO Auto-generated constructor stub
}
/*
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2008-05-02
19:34:22 UTC (rev 8420)
+++
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2008-05-03
00:11:59 UTC (rev 8421)
@@ -21,6 +21,7 @@
package org.ajax4jsf.taglib.html.jsp;
+import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
@@ -64,13 +65,17 @@
private ValueExpression _assignTo;
private ValueExpression _converter;
private ValueExpression _noEscape;
-
+ private MethodExpression _actionListener;
+
protected void setProperties(UIComponent component)
{
super.setProperties(component);
setStringProperty(component, "name", _name);
setBooleanProperty(component, "noEscape", _noEscape);
-
+ if (_actionListener != null) {
+ ((UIActionParameter) component).setActionListener(_actionListener);
+ }
+
//Find parent UIComponentTag
UIComponentClassicTagBase componentTag =
UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
@@ -134,6 +139,13 @@
{
this._assignTo = property;
}
+
+ /**
+ * @param property The property to set.
+ */
+ public void setActionListener(MethodExpression listener) {
+ this._actionListener = listener;
+ }
/* (non-Javadoc)
* @see org.apache.myfaces.taglib.UIComponentTagBase#release()
@@ -144,6 +156,7 @@
_assignTo = null;
_converter = null;
_noEscape = null;
+ _actionListener = null;
super.release();
}