Author: nbelaevski
Date: 2008-07-24 14:32:32 -0400 (Thu, 24 Jul 2008)
New Revision: 9777
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxContainerBaseRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/MethodExpressionAjaxListener.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxComponentHandler.java
Log:
https://jira.jboss.org/jira/browse/RF-3927
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxComponentHandler.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxComponentHandler.java 2008-07-24
18:32:28 UTC (rev 9776)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxComponentHandler.java 2008-07-24
18:32:32 UTC (rev 9777)
@@ -23,6 +23,8 @@
import javax.faces.component.ActionSource;
+import org.ajax4jsf.component.AjaxContainerBase;
+
import com.sun.facelets.tag.MetaRuleset;
import com.sun.facelets.tag.jsf.ComponentConfig;
import com.sun.facelets.tag.jsf.ComponentHandler;
@@ -51,6 +53,9 @@
if (ActionSource.class.isAssignableFrom(type)) {
metaRules.addRule(AjaxActionsRule.instance);
}
+ if (AjaxContainerBase.class.isAssignableFrom(type)) {
+ metaRules.addRule(AjaxContainerBaseRule.instance);
+ }
metaRules.addRule(AjaxReRendrRule.instance);
return metaRules;
}
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxContainerBaseRule.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxContainerBaseRule.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxContainerBaseRule.java 2008-07-24
18:32:32 UTC (rev 9777)
@@ -0,0 +1,78 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import org.ajax4jsf.component.AjaxContainerBase;
+import org.ajax4jsf.event.AjaxEvent;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:21 $
+ *
+ */
+public class AjaxContainerBaseRule extends MetaRule {
+
+ public final static Class[] AJAX_LISTENER_SIG = new Class[] { AjaxEvent.class };
+
+ public final static class AjaxListenerMapper extends Metadata {
+
+ private final TagAttribute attr;
+
+ public AjaxListenerMapper(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AjaxContainerBase) instance)
+ .setAjaxListener(this.attr
+ .getMethodExpression(ctx, null,
+ AJAX_LISTENER_SIG));
+ }
+
+ }
+
+ public final static AjaxContainerBaseRule instance = new AjaxContainerBaseRule();
+
+ public AjaxContainerBaseRule() {
+ super();
+ }
+
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AjaxContainerBase.class)) {
+
+
+ if ("ajaxListener".equals(name)) {
+ return new AjaxListenerMapper(attribute);
+ }
+
+ }
+ return null;
+ }
+
+}
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/MethodExpressionAjaxListener.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/MethodExpressionAjaxListener.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/taglib/MethodExpressionAjaxListener.java 2008-07-24
18:32:32 UTC (rev 9777)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.taglib;
+
+import javax.el.MethodExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.2.2
+ */
+
+public class MethodExpressionAjaxListener implements AjaxListener, StateHolder {
+
+ private MethodExpression expression;
+
+ public MethodExpressionAjaxListener() {
+ super();
+ }
+
+ public MethodExpressionAjaxListener(MethodExpression expression) {
+ super();
+ this.expression = expression;
+ }
+
+ public MethodExpression getExpression() {
+ return expression;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.event.AjaxListener#processAjax(org.ajax4jsf.event.AjaxEvent)
+ */
+ public void processAjax(AjaxEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ expression.invoke(facesContext.getELContext(), new Object[] {event});
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ this.expression = (MethodExpression) UIComponentBase.restoreAttachedState(context,
state);
+ }
+
+ public Object saveState(FacesContext context) {
+ return UIComponentBase.saveAttachedState(context, this.expression);
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ if (newTransientValue) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+}