You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2011/10/10 15:43:59 UTC

svn commit: r1180955 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/event/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces...

Author: bommel
Date: Mon Oct 10 13:43:59 2011
New Revision: 1180955

URL: http://svn.apache.org/viewvc?rev=1180955&view=rev
Log:
(TOBAGO-1038)
ResetInputActionListener to reset all EditableValueHolder in a page or in a subform or a part of the component tree

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetFormActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ResetInputActionListenerTag.java
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/ResetInputActionListenerHandler.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractResetInputActionListener.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java
Modified:
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtilsEL.java

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetFormActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetFormActionListener.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetFormActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetFormActionListener.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,37 @@
+package org.apache.myfaces.tobago.event;
+
+/*
+ * 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.
+ */
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import java.io.Serializable;
+
+public class ResetFormActionListener extends AbstractResetInputActionListener implements Serializable{
+
+  public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
+    UIComponent component = actionEvent.getComponent();
+    while ((component = component.getParent()) != null) {
+      if (component instanceof UIForm) {
+        resetChildren(component);
+        return;
+      }
+    }
+  }
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,67 @@
+package org.apache.myfaces.tobago.event;
+
+/*
+ * 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.
+ */
+
+import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import java.util.Collection;
+
+public class ResetInputActionListener extends AbstractResetInputActionListener implements StateHolder {
+
+  private String [] clientIds;
+
+  public ResetInputActionListener(String[] clientIds) {
+    this.clientIds = clientIds;
+  }
+
+  public ResetInputActionListener(Collection<String> clientIds) {
+     this.clientIds = clientIds.toArray(new String[clientIds.size()]);
+  }
+
+  public void processAction(ActionEvent event) {
+    for (String clientId : clientIds) {
+      UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
+      if (component != null) {
+        resetChildren(component);
+      }
+    }
+  }
+
+  public boolean isTransient() {
+    return false;
+  }
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
+
+  public void restoreState(FacesContext context, Object state) {
+    Object[] values = (Object[]) state;
+    clientIds = (String[]) values[0];
+  }
+
+  public Object saveState(FacesContext context) {
+    Object[] values = new Object[1];
+    values[0] = clientIds;
+    return values;
+  }
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ResetInputActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ResetInputActionListenerTag.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ResetInputActionListenerTag.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ResetInputActionListenerTag.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,91 @@
+package org.apache.myfaces.tobago.internal.taglib.component;
+
+/*
+ * 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.
+ */
+
+import org.apache.myfaces.tobago.apt.annotation.BodyContent;
+import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.event.ResetFormActionListener;
+import org.apache.myfaces.tobago.event.ResetInputActionListener;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+/**
+ *  TODO document me!
+ */
+@Tag(name = "resetInputActionListener", bodyContent = BodyContent.EMPTY)
+@TagGeneration(className = "org.apache.myfaces.tobago.internal.taglib.ResetInputActionListenerTag")
+public abstract class ResetInputActionListenerTag extends TagSupport {
+
+  private static final long serialVersionUID = -8444689365088370011L;
+
+  /**
+   * The .
+   */
+  @TagAttribute(required = false, name = Attributes.EXECUTE)
+  public abstract String getExecuteValue();
+
+  public abstract boolean isExecuteLiteral();
+
+  public abstract Object getExecuteAsBindingOrExpression();
+
+  public abstract boolean isExecuteSet();
+
+  public int doStartTag() throws JspException {
+
+    // Locate our parent UIComponentTag
+    UIComponentTag tag =
+        UIComponentTag.getParentUIComponentTag(pageContext);
+    if (tag == null) {
+      // TODO Message resource i18n
+      throw new JspException("Not nested in faces tag");
+    }
+
+    if (!tag.getCreated()) {
+      return (SKIP_BODY);
+    }
+
+    UIComponent component = tag.getComponentInstance();
+    if (component == null) {
+      // TODO Message resource i18n
+      throw new JspException("Component Instance is null");
+    }
+    if (!(component instanceof ActionSource)) {
+      // TODO Message resource i18n
+      throw new JspException("Component " + component.getClass().getName() + " is not instanceof ActionSource");
+    }
+    ActionSource actionSource = (ActionSource) component;
+    if (!isExecuteSet()) {
+      actionSource.addActionListener(new ResetFormActionListener());
+    } else if (isExecuteLiteral()) {
+      actionSource.addActionListener(new ResetInputActionListener(ComponentUtils.splitList(getExecuteValue())));
+    } else {
+      FacesUtils.addBindingOrExpressionResetActionListener(actionSource, getExecuteAsBindingOrExpression());
+    }
+    return (SKIP_BODY);
+  }
+
+}

Modified: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java?rev=1180955&r1=1180954&r2=1180955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java Mon Oct 10 13:43:59 2011
@@ -29,6 +29,7 @@ public class AbstractTobagoTagLibrary  e
     addTagHandler("attribute", AttributeHandler.class);
     addTagHandler("tabChangeListener", TabChangeListenerHandler.class);
     addTagHandler("popupReference", PopupReferenceHandler.class);
+    addTagHandler("resetInputActionListener", ResetInputActionListenerHandler.class);
     addTagHandler("loadBundle", LoadBundleHandler.class);
     addTagHandler("converter", ConverterHandler.class);
     addTagHandler(Tags.GRID_LAYOUT_CONSTRAINT, GridLayoutConstraintHandler.class);

Added: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/ResetInputActionListenerHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/ResetInputActionListenerHandler.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/ResetInputActionListenerHandler.java (added)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/ResetInputActionListenerHandler.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,75 @@
+package org.apache.myfaces.tobago.facelets;
+
+/*
+ * 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.
+ */
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyValueBinding;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagException;
+import com.sun.facelets.tag.TagHandler;
+import com.sun.facelets.tag.jsf.ComponentSupport;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.event.ResetFormActionListener;
+import org.apache.myfaces.tobago.event.ResetInputActionListener;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacesVersion;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+
+public class ResetInputActionListenerHandler extends TagHandler {
+
+  private final TagAttribute execute;
+
+  public ResetInputActionListenerHandler(TagConfig config) {
+    super(config);
+    execute = getAttribute(Attributes.EXECUTE);
+  }
+
+  public void apply(FaceletContext faceletContext, UIComponent parent)
+      throws IOException, FacesException, ELException {
+    if (parent instanceof ActionSource) {
+      if (ComponentSupport.isNew(parent)) {
+        ActionSource actionSource = (ActionSource) parent;
+        if (execute == null) {
+          actionSource.addActionListener(new ResetFormActionListener());
+        } else if (execute.isLiteral())  {
+          actionSource.addActionListener(new ResetInputActionListener(ComponentUtils.splitList(execute.getValue())));
+        } else {
+          ValueExpression forValueExpression = execute.getValueExpression(faceletContext, String.class);
+          if (FacesVersion.supports12()) {
+            FacesUtils.addBindingOrExpressionResetActionListener(actionSource, forValueExpression);
+          } else {
+            FacesUtils.addBindingOrExpressionResetActionListener(actionSource,
+                new LegacyValueBinding(forValueExpression));
+          }
+        }
+      }
+    } else {
+      throw new TagException(tag, "Parent is not of type ActionSource, type is: " + parent);
+    }
+  }
+}
+
+

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=1180955&r1=1180954&r2=1180955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java Mon Oct 10 13:43:59 2011
@@ -19,6 +19,7 @@ package org.apache.myfaces.tobago.compat
 
 import org.apache.myfaces.tobago.event.TabChangeSource;
 import org.apache.myfaces.tobago.event.ValueBindingPopupActionListener;
+import org.apache.myfaces.tobago.event.ValueBindingResetInputActionListener;
 import org.apache.myfaces.tobago.event.ValueBindingTabChangeListener;
 import org.apache.myfaces.tobago.util.FacesVersion;
 import org.apache.myfaces.tobago.util.ValueBindingComparator;
@@ -274,6 +275,14 @@ public class FacesUtils {
     }
   }
 
+  public static void addBindingOrExpressionResetActionListener(ActionSource actionSource, Object bindingOrExpression) {
+    if (USE_BINDING) {
+      actionSource.addActionListener(new ValueBindingResetInputActionListener(bindingOrExpression));
+    } else {
+      FacesUtilsEL.addBindingOrExpressionResetActionListener(actionSource, bindingOrExpression);
+    }
+  }
+
   public static Map getFacesContextAttributes(FacesContext context) {
     if (FacesVersion.supports20()) {
       return context.getAttributes();

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtilsEL.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtilsEL.java?rev=1180955&r1=1180954&r2=1180955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtilsEL.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtilsEL.java Mon Oct 10 13:43:59 2011
@@ -19,6 +19,7 @@ package org.apache.myfaces.tobago.compat
 
 import org.apache.myfaces.tobago.event.TabChangeSource;
 import org.apache.myfaces.tobago.event.ValueExpressionPopupActionListener;
+import org.apache.myfaces.tobago.event.ValueExpressionResetInputActionListener;
 import org.apache.myfaces.tobago.event.ValueExpressionTabChangeListener;
 import org.apache.myfaces.tobago.util.ValueExpressionComparator;
 import org.slf4j.Logger;
@@ -211,4 +212,8 @@ public class FacesUtilsEL {
   public static void addBindingOrExpressionPopupActionListener(ActionSource actionSource, Object bindingOrExpression) {
     actionSource.addActionListener(new ValueExpressionPopupActionListener((ValueExpression) bindingOrExpression));
   }
+
+  public static void addBindingOrExpressionResetActionListener(ActionSource actionSource, Object bindingOrExpression) {
+    actionSource.addActionListener(new ValueExpressionResetInputActionListener((ValueExpression) bindingOrExpression));
+  }
 }

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractResetInputActionListener.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractResetInputActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractResetInputActionListener.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,44 @@
+package org.apache.myfaces.tobago.event;
+
+/*
+ * 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.
+ */
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionListener;
+import java.util.Iterator;
+
+public abstract class AbstractResetInputActionListener implements ActionListener {
+
+  protected void resetChildren(UIComponent component) {
+    Iterator it = component.getFacetsAndChildren();
+    while (it.hasNext()) {
+      UIComponent child = (UIComponent) it.next();
+      if (child instanceof EditableValueHolder) {
+        reset((EditableValueHolder) child);
+      }
+      resetChildren(child);
+    }
+  }
+
+  public static void reset(EditableValueHolder editableValueHolder) {
+    editableValueHolder.setValue(null);
+    editableValueHolder.setSubmittedValue(null);
+    editableValueHolder.setLocalValueSet(false);
+    editableValueHolder.setValid(true);
+  }
+}

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,81 @@
+package org.apache.myfaces.tobago.event;
+
+/*
+ * 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.
+ */
+
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+
+
+public class ValueBindingResetInputActionListener extends AbstractResetInputActionListener implements StateHolder {
+  private static final Logger LOG = LoggerFactory.getLogger(ValueBindingResetInputActionListener.class);
+
+  private ValueBinding clientIdsBinding;
+
+  public ValueBindingResetInputActionListener(Object binding) {
+    clientIdsBinding = (ValueBinding) binding;
+  }
+
+  public void processAction(ActionEvent event) {
+    Object obj = clientIdsBinding.getValue(FacesContext.getCurrentInstance());
+    String [] clientIds;
+    if (obj instanceof String[]) {
+      clientIds = (String[]) obj;
+    } else if (obj instanceof String) {
+      clientIds= StringUtils.split((String) obj, ", ");
+    } else {
+      LOG.error("Ignore unknown value of " + obj + " for reset.");
+      return;
+    }
+    for (String clientId : clientIds) {
+      UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
+      if (component != null) {
+        resetChildren(component);
+      }
+    }
+  }
+
+  public boolean isTransient() {
+    return false;
+  }
+
+  public void restoreState(FacesContext context, Object state) {
+    Object[] values = (Object[]) state;
+    clientIdsBinding = (ValueBinding) UIComponentBase.restoreAttachedState(context, values[0]);
+  }
+
+  public Object saveState(FacesContext context) {
+    Object[] values = new Object[1];
+    values[0] = UIComponentBase.saveAttachedState(context, clientIdsBinding);
+    return values;
+  }
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
+
+}

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java?rev=1180955&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java Mon Oct 10 13:43:59 2011
@@ -0,0 +1,81 @@
+package org.apache.myfaces.tobago.event;
+
+/*
+ * 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.
+ */
+
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+public class ValueExpressionResetInputActionListener extends AbstractResetInputActionListener implements StateHolder {
+  private static final Logger LOG = LoggerFactory.getLogger(ValueExpressionResetInputActionListener.class);
+
+  private ValueExpression clientIdsExpression;
+
+  public ValueExpressionResetInputActionListener(Object binding) {
+    clientIdsExpression = (ValueExpression) binding;
+  }
+
+  public void processAction(ActionEvent event) {
+    Object obj = clientIdsExpression.getValue(FacesContext.getCurrentInstance().getELContext());
+    String [] clientIds;
+    if (obj instanceof String[]) {
+      clientIds = (String[]) obj;
+    } else if (obj instanceof String) {
+      clientIds= StringUtils.split((String) obj, ", ");
+    } else {
+      LOG.error("Ignore unknown value of " + obj + " for reset.");
+      return;
+    }
+    for (String clientId : clientIds) {
+      UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
+      if (component != null) {
+        resetChildren(component);
+      }
+    }
+  }
+
+  public boolean isTransient() {
+    return false;
+  }
+
+  public void restoreState(FacesContext context, Object state) {
+    Object[] values = (Object[]) state;
+    clientIdsExpression = (ValueExpression) UIComponentBase.restoreAttachedState(context, values[0]);
+  }
+
+  public Object saveState(FacesContext context) {
+    Object[] values = new Object[1];
+    values[0] = UIComponentBase.saveAttachedState(context, clientIdsExpression);
+    return values;
+  }
+
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
+
+}