You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/05/10 07:22:22 UTC

svn commit: r1743109 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java

Author: lofwyr
Date: Tue May 10 07:22:21 2016
New Revision: 1743109

URL: http://svn.apache.org/viewvc?rev=1743109&view=rev
Log:
TOBAGO-1524: Use standard AJAX mechanism
* hack to mark the correct "form" in case of sheet
[developed by hnoeth]

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java
    myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java?rev=1743109&r1=1743108&r2=1743109&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIForm.java Tue May 10 07:22:21 2016
@@ -21,6 +21,7 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.myfaces.tobago.component.Form;
 import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacesVersion;
 import org.apache.myfaces.tobago.util.TobagoCallback;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -109,7 +110,24 @@ public abstract class AbstractUIForm ext
 
   @Override
   public void queueEvent(FacesEvent event) {
-    if (event instanceof AjaxBehaviorEvent) {
+
+    Class<?> wrapper = null;
+
+    try {
+      if (FacesVersion.isMyfaces()) {
+        // XXX hack for MyFaces
+        wrapper = Class.forName("javax.faces.component.UIData$FacesEventWrapper");
+      } else if (FacesVersion.isMojarra()) {
+        // XXX hack for Mojarra
+        wrapper = Class.forName("javax.faces.component.WrapperEvent");
+      } else {
+        LOG.warn("Can't identify JSF implementation. Events in sheet may not work.");
+      }
+    } catch (ClassNotFoundException e) {
+      LOG.error("Can't find specific wrapper class.", e);
+    }
+
+    if (event instanceof AjaxBehaviorEvent || (wrapper != null && wrapper.equals(event.getClass()))) {
       if (LOG.isDebugEnabled()) {
         LOG.debug("event={}", event);
       }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java?rev=1743109&r1=1743108&r2=1743109&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java Tue May 10 07:22:21 2016
@@ -19,6 +19,10 @@
 
 package org.apache.myfaces.tobago.example.data;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.faces.event.AjaxBehaviorEvent;
 import javax.swing.tree.DefaultMutableTreeNode;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -29,6 +33,8 @@ import java.util.Map;
 
 public class SolarObject {
 
+  private static final Logger LOG = LoggerFactory.getLogger(SolarObject.class);
+
   private String name;
 
   private String number;
@@ -70,6 +76,10 @@ public class SolarObject {
     return name;
   }
 
+  public void update(AjaxBehaviorEvent event) {
+    LOG.info("AjaxBehaviorEvent called. New value: '{}' event: {}", name, event);
+  }
+
   public void setName(final String name) {
     this.name = name;
   }