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-1964: "placeholder" attribute for <tc:file>
Date Wed, 05 Dec 2018 14:58:11 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 3edd51d  TOBAGO-1964: "placeholder" attribute for <tc:file>
3edd51d is described below

commit 3edd51d225a69782a734c1a6cf7522bf18ddff1c
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Wed Dec 5 15:57:56 2018 +0100

    TOBAGO-1964: "placeholder" attribute for <tc:file>
---
 .../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 46ebb8c..f93d4fb 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 9032793..71c0973 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 = ResourceUtils.getString(facesContext, "file.selected");
     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


Mime
View raw message