You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2014/03/26 18:42:05 UTC

svn commit: r1581963 - in /myfaces/trinidad/trunk/trinidad-api/src/main: java-templates/org/apache/myfaces/trinidad/component/ java/org/apache/myfaces/trinidad/event/

Author: jwaldman
Date: Wed Mar 26 17:42:05 2014
New Revision: 1581963

URL: http://svn.apache.org/r1581963
Log:
TRINIDAD-2459 Addition of ValueUpdatedEvent + ValueUpdatedListener
Thanks to Ji Kim for the patch

Added:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedEvent.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedListener.java
Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java?rev=1581963&r1=1581962&r2=1581963&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXEditableValueTemplate.java Wed Mar 26 17:42:05 2014
@@ -36,6 +36,7 @@ import javax.faces.el.EvaluationExceptio
 import javax.faces.el.MethodBinding;
 import javax.faces.event.AbortProcessingException;
 import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
 import javax.faces.event.PostValidateEvent;
 import javax.faces.event.PreValidateEvent;
 import javax.faces.event.ValueChangeEvent;
@@ -48,6 +49,8 @@ import javax.validation.Validation;
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
 import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.event.ValueUpdatedListener;
+import org.apache.myfaces.trinidad.event.ValueUpdatedEvent;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidad.util.LabeledFacesMessage;
@@ -314,6 +317,21 @@ abstract public class UIXEditableValueTe
       requestContext.popCurrentComponent(context, this);
     }
   }
+  /**
+   * Adds a ValueUpdatedListener to the component to handle ValueUpdatedEvent which is queued 
+   * within updateModel method.
+   */
+  public void addValueUpdatedListener(ValueUpdatedListener listener) 
+  {
+    super.addFacesListener(listener);
+  }
+  /**
+   * Removes a ValueUpdatedListener from the component.
+   */
+  public void removeValueUpdatedListener(ValueUpdatedListener listener) 
+  {
+    super.removeFacesListener(listener);
+  }
 
   // TODO Better error messages when update model fails.
   public void updateModel(FacesContext context)
@@ -334,6 +352,7 @@ abstract public class UIXEditableValueTe
       expression.setValue(context.getELContext(), localValue);
       setValue(null);
       setLocalValueSet(false);
+	  (new ValueUpdatedEvent(this)).queue();
       if (_LOG.isFiner())
       {
         _LOG.finer("Wrote value {0} to model {1} in component {2}",

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedEvent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedEvent.java?rev=1581963&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedEvent.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedEvent.java Wed Mar 26 17:42:05 2014
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.trinidad.event;
+
+import javax.faces.component.UIComponent;
+
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/** 
+ * Event delivered when a value has been processed within UIXEditableValue.updateModel
+ * 
+ * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/event/ValueUpdatedEvent.java#0 $) $Date: 23-dev-2013.19:08:59 $
+ */
+public class ValueUpdatedEvent extends FacesEvent
+{
+  
+  public ValueUpdatedEvent(UIComponent source)
+  {
+    super(source);
+  }
+  
+  @Override
+  public void processListener(FacesListener listener)
+  {
+    ((ValueUpdatedListener) listener).processValueUpdated(this);
+  }
+
+  @Override
+  public boolean isAppropriateListener(FacesListener listener)
+  {
+    return (listener instanceof ValueUpdatedListener);
+  }
+  
+  private static final long serialVersionUID = 1L;
+}

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedListener.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedListener.java?rev=1581963&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedListener.java (added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/ValueUpdatedListener.java Wed Mar 26 17:42:05 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.trinidad.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * Listener for ValueUpdatedEvent.
+ * <p>
+ * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/event/ValueUpdatedListener.java#0 $) $Date: 23-dev-2013.19:08:59 $
+ */
+public interface ValueUpdatedListener extends FacesListener
+{
+  public void processValueUpdated(ValueUpdatedEvent event)
+      throws AbortProcessingException;
+}