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 2018/12/05 15:07:22 UTC

[myfaces-tobago] branch tobago-4.x updated (44cec7c -> 63ff932)

This is an automated email from the ASF dual-hosted git repository.

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


    from 44cec7c  TOBAGO-1961: bootstrap.min.js.map is missing
     new 19ae9c1  TOBAGO-1963: "confirmation" attribute
     new 63ff932  TOBAGO-1964: "placeholder" attribute for <tc:file>

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../tobago/internal/component/AbstractUIFile.java     |  2 ++
 .../myfaces/tobago/internal/renderkit/Command.java    | 19 +------------------
 .../internal/renderkit/renderer/FileRenderer.java     | 16 +++++++++++-----
 .../internal/renderkit/renderer/InRenderer.java       |  6 ++----
 .../renderer/TobagoClientBehaviorRenderer.java        |  3 ++-
 .../internal/taglib/component/FileTagDeclaration.java |  3 ++-
 .../apache/myfaces/tobago/util/ComponentUtils.java    | 19 +++++++++++++++++++
 7 files changed, 39 insertions(+), 29 deletions(-)


[myfaces-tobago] 02/02: TOBAGO-1964: "placeholder" attribute for

Posted by lo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 63ff932a6c80eab981833a028010cf4ff59b3815
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Dec 5 15:57:56 2018 +0100

    TOBAGO-1964: "placeholder" attribute for <tc:file>
    
    (cherry picked from commit 3edd51d225a69782a734c1a6cf7522bf18ddff1c)
---
 .../tobago/internal/component/AbstractUIFile.java        |  2 ++
 .../tobago/internal/renderkit/renderer/FileRenderer.java | 16 +++++++++++-----
 .../tobago/internal/renderkit/renderer/InRenderer.java   |  6 ++----
 .../internal/taglib/component/FileTagDeclaration.java    |  3 ++-
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFile.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFile.java
index 0ae94ac..c0d57a4 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFile.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFile.java
@@ -68,6 +68,8 @@ public abstract class AbstractUIFile extends UIInput implements SupportsLabelLay
 
   public abstract Integer getTabIndex();
 
+  public abstract String getPlaceholder();
+
   @Override
   public String getFieldId(final FacesContext facesContext) {
     return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "real";
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
index e01226e..83dcac0 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
@@ -121,6 +121,8 @@ public class FileRenderer extends MessageLayoutRendererBase implements Component
     final String fieldId = file.getFieldId(facesContext);
     final String accept = createAcceptFromValidators(file);
     final boolean multiple = file.isMultiple() && !file.isRequired();
+    final boolean disabled = file.isDisabled();
+    final boolean readonly = file.isReadonly();
     if (file.isMultiple() && file.isRequired()) {
       LOG.warn("Required multiple file upload is not supported."); //TODO TOBAGO-1930
     }
@@ -145,8 +147,12 @@ public class FileRenderer extends MessageLayoutRendererBase implements Component
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT);
     writer.writeAttribute(HtmlAttributes.ACCEPT, accept, true);
     writer.writeAttribute(HtmlAttributes.TABINDEX, -1);
-    writer.writeAttribute(HtmlAttributes.DISABLED, file.isDisabled() || file.isReadonly());
-    writer.writeAttribute(HtmlAttributes.READONLY, file.isReadonly());
+    writer.writeAttribute(HtmlAttributes.DISABLED, disabled || readonly);
+    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
+    if (!disabled && !readonly) {
+      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, file.getPlaceholder(), true);
+    }
+
     writer.writeClassAttribute(
         TobagoClass.FILE__PRETTY,
         BootstrapClass.FORM_CONTROL,
@@ -167,8 +173,8 @@ public class FileRenderer extends MessageLayoutRendererBase implements Component
     final String multiFormat = TobagoResourceBundle.getString(facesContext, "tobago.file.multiFormat");
     writer.writeAttribute(DataAttributes.dynamic("tobago-file-multi-format"), multiFormat, true);
     // readonly seems not making sense in browsers.
-    writer.writeAttribute(HtmlAttributes.DISABLED, file.isDisabled() || file.isReadonly());
-    writer.writeAttribute(HtmlAttributes.READONLY, file.isReadonly());
+    writer.writeAttribute(HtmlAttributes.DISABLED, disabled || readonly);
+    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
     writer.writeAttribute(HtmlAttributes.REQUIRED, file.isRequired());
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, file);
     if (title != null) {
@@ -185,7 +191,7 @@ public class FileRenderer extends MessageLayoutRendererBase implements Component
     writer.writeAttribute(HtmlAttributes.TABINDEX, file.getTabIndex());
     writer.writeClassAttribute(BootstrapClass.BTN, BootstrapClass.BTN_SECONDARY);
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
-    writer.writeAttribute(HtmlAttributes.DISABLED, file.isDisabled() || file.isReadonly());
+    writer.writeAttribute(HtmlAttributes.DISABLED, disabled || readonly);
     writer.startElement(HtmlElements.I);
     writer.writeClassAttribute(Icons.FA, Icons.FOLDER_OPEN);
     writer.endElement(HtmlElements.I);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
index ab8a20e..caf411b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
@@ -133,10 +133,8 @@ public class InRenderer extends MessageLayoutRendererBase {
     writer.writeAttribute(HtmlAttributes.READONLY, readonly);
     writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
     writer.writeAttribute(HtmlAttributes.TABINDEX, input.getTabIndex());
-
-    final String placeholder = input.getPlaceholder();
-    if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
-      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
+    if (!disabled && !readonly) {
+      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, input.getPlaceholder(), true);
     }
 
     writer.writeClassAttribute(
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FileTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FileTagDeclaration.java
index 7cef08c..923989f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FileTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FileTagDeclaration.java
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.internal.taglib.declaration.HasConverterMessage
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasLabel;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasLabelLayout;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasPlaceholder;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasRequiredMessage;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasTabIndex;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
@@ -79,7 +80,7 @@ import javax.faces.component.UIInput;
 public interface FileTagDeclaration
     extends HasValidator, HasValidatorMessage, HasRequiredMessage, HasConverterMessage,
     HasValueChangeListener, HasIdBindingAndRendered, IsDisabled, IsFocus, IsMultiple,
-    HasLabel, HasLabelLayout, HasAccessKey, HasTip, IsReadonly, IsRequired, HasTabIndex, IsVisual {
+    HasLabel, HasLabelLayout, HasAccessKey, HasTip, IsReadonly, IsRequired, HasTabIndex, IsVisual, HasPlaceholder {
 
   /**
    * Value binding expression pointing to a


[myfaces-tobago] 01/02: TOBAGO-1963: "confirmation" attribute

Posted by lo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 19ae9c12e9cab8efc9fc2cd7c76e1cf28333d4fb
Author: Udo Schnurpfeil <lo...@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>
    
    (cherry picked from commit 5a758f88ab9fe22552575353875a82aa9f6402b0)
---
 .../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;
+  }
 }