myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1963: "confirmation" attribute
Date Wed, 05 Dec 2018 14:12:52 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a758f8  TOBAGO-1963: "confirmation" attribute
5a758f8 is described below

commit 5a758f88ab9fe22552575353875a82aa9f6402b0
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Wed Dec 5 15:12:11 2018 +0100

    TOBAGO-1963: "confirmation" attribute
    
    "confirmation" attribute doesn't works with <f:ajax> and <tc:event>
---
 .../myfaces/tobago/internal/renderkit/Command.java    | 19 +------------------
 .../renderer/TobagoClientBehaviorRenderer.java        |  3 ++-
 .../apache/myfaces/tobago/util/ComponentUtils.java    | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/Command.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/Command.java
index eca0f77..07cb7db 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/Command.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/Command.java
@@ -20,7 +20,6 @@
 package org.apache.myfaces.tobago.internal.renderkit;
 
 import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIForm;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.renderkit.renderer.TobagoClientBehaviorRenderer;
@@ -30,7 +29,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
 
 /**
@@ -81,7 +79,7 @@ public class Command {
         null,
         null,
         null,
-        getConfirmation(command),
+        ComponentUtils.getConfirmation(command),
         null,
         TobagoClientBehaviorRenderer.createCollapsible(facesContext, command),
         command.isOmit());
@@ -118,21 +116,6 @@ public class Command {
     }
   }
 
-  private static String getConfirmation(final AbstractUICommand command) {
-    final String confirmation = command.getConfirmation();
-    if (confirmation != null) {
-      return confirmation;
-    }
-    final UIComponent facet = ComponentUtils.getFacet(command, Facets.confirmation);
-    if (facet instanceof ValueHolder) {
-      final ValueHolder valueHolder = (ValueHolder) facet;
-      return "" + valueHolder.getValue();
-    } else if (facet != null) {
-      LOG.warn("The content of a confirmation facet must be a ValueHolder. Use e. g. <tc:out>.");
-    }
-    return null;
-  }
-
   public String getAction() {
     return action;
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
index 0626f14..5d7de1e 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
@@ -72,6 +72,7 @@ public class TobagoClientBehaviorRenderer extends javax.faces.render.ClientBehav
     String target = null;
     String actionId = null;
     boolean omit = false;
+    final String confirmation = ComponentUtils.getConfirmation(uiComponent);
     if (behavior instanceof AjaxBehavior) {
       final AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
       if (ajaxBehavior.isDisabled()) {
@@ -123,7 +124,7 @@ public class TobagoClientBehaviorRenderer extends javax.faces.render.ClientBehav
         executeIds,
         renderIds,
         null,
-        null, // getConfirmation(command), // todo
+        confirmation,
         null,
         collapse,
         omit);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
index 7635e9c..5c329be 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
@@ -899,4 +899,23 @@ public final class ComponentUtils {
       addLayoutChildren(child, result);
     }
   }
+
+  /**
+   * returns the "confirmation" attribute or the value of the "confirmation" facet of a component.
+   * @since Tobago 4.3.3
+   */
+  public static String getConfirmation(final UIComponent component) {
+    final String confirmation = getStringAttribute(component, Attributes.confirmation,null);
+    if (confirmation != null) {
+      return confirmation;
+    }
+    final UIComponent facet = ComponentUtils.getFacet(component, Facets.confirmation);
+    if (facet instanceof ValueHolder) {
+      final ValueHolder valueHolder = (ValueHolder) facet;
+      return "" + valueHolder.getValue();
+    } else if (facet != null) {
+      LOG.warn("The content of a confirmation facet must be a ValueHolder. Use e. g. <tc:out>.");
+    }
+    return null;
+  }
 }


Mime
View raw message