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:46:27 UTC
[myfaces-tobago] branch tobago-2.x updated: TOBAGO-1964:
"placeholder" attribute for
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch tobago-2.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/tobago-2.x by this push:
new 9e7cc37 TOBAGO-1964: "placeholder" attribute for <tc:file>
9e7cc37 is described below
commit 9e7cc37596508dca603644912075849f1a0a3ced
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Dec 5 16:46:14 2018 +0100
TOBAGO-1964: "placeholder" attribute for <tc:file>
(cherry picked from commit 3edd51d225a69782a734c1a6cf7522bf18ddff1c)
---
.../tobago/internal/component/AbstractUIFileDrop.java | 5 +++++
.../internal/taglib/extension/FileExtensionTag.java | 15 +++++++++++++++
.../src/main/webapp/content/40-upload/upload.xhtml | 2 +-
.../html/standard/standard/tag/FileRenderer.java | 3 +++
.../renderkit/html/standard/standard/tag/InRenderer.java | 6 ++----
5 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFileDrop.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFileDrop.java
index 2d8c0da..a6f1b04 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFileDrop.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFileDrop.java
@@ -67,4 +67,9 @@ public abstract class AbstractUIFileDrop extends AbstractUIFile implements Suppo
return (ActionListener[]) ((ActionListener[]) this.getFacesListeners(ActionListener.class));
}
+ // not a file drop attribute
+ @Override
+ public String getPlaceholder() {
+ return null;
+ }
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/FileExtensionTag.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/FileExtensionTag.java
index dd9a541..bc053de 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/FileExtensionTag.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/extension/FileExtensionTag.java
@@ -62,6 +62,7 @@ public class FileExtensionTag extends TobagoExtensionBodyTagSupport {
private MethodExpression validator;
private ValueExpression disabled;
private ValueExpression rendered;
+ private ValueExpression placeholder;
private ValueExpression multiple;
private ValueExpression tip;
private ValueExpression onchange;
@@ -130,6 +131,9 @@ public class FileExtensionTag extends TobagoExtensionBodyTagSupport {
if (label != null) {
fileTag.setLabel(label);
}
+ if (placeholder != null) {
+ fileTag.setPlaceholder(placeholder);
+ }
if (onchange != null) {
fileTag.setOnchange(onchange);
}
@@ -176,6 +180,7 @@ public class FileExtensionTag extends TobagoExtensionBodyTagSupport {
accessKey = null;
labelWidth = null;
tip = null;
+ placeholder = null;
onchange = null;
value = null;
rendered = null;
@@ -305,6 +310,16 @@ public class FileExtensionTag extends TobagoExtensionBodyTagSupport {
public void setTip(final ValueExpression tip) {
this.tip = tip;
}
+
+ /**
+ * Text value to display as placeholder.
+ */
+ @TagAttribute
+ @UIComponentTagAttribute()
+ public void setPlaceholder(final ValueExpression placeholder) {
+ this.placeholder = placeholder;
+ }
+
/**
* The width for the label component. Default: 'auto'.
* This value is used in the gridLayouts columns attribute.
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-upload/upload.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-upload/upload.xhtml
index 77bc80b..d573127 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/40-upload/upload.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-upload/upload.xhtml
@@ -33,7 +33,7 @@
<tc:gridLayout columns="*;auto"/>
</f:facet>
- <tx:file label="Upload file:" value="#{upload.file1}" tip="without extra validation"/>
+ <tx:file placeholder="please select a file" label="Upload file:" value="#{upload.file1}" tip="without extra validation"/>
<tc:button label="Submit" defaultCommand="true" action="#{upload.upload}"/>
<tx:file label="Upload image:" value="#{upload.file2}"
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FileRenderer.java b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FileRenderer.java
index 3473e0a..4cb2642 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FileRenderer.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FileRenderer.java
@@ -170,6 +170,9 @@ public class FileRenderer extends InputRendererBase {
writer.writeClassAttribute(getCssClasses(file, "pretty"));
writer.writeStyleAttribute(inputStyle);
writer.writeAttribute(HtmlAttributes.DISABLED, true);
+ if (!file.isDisabled() && !file.isReadonly()) {
+ writer.writeAttribute(HtmlAttributes.PLACEHOLDER, file.getPlaceholder(), true);
+ }
// TODO Focus
//HtmlRendererUtils.renderFocus(clientId, file.isFocus(), ComponentUtils.isError(file), facesContext, writer);
writer.endElement(HtmlElements.INPUT);
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java
index 616880f..717ee5f 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java
@@ -111,10 +111,8 @@ public class InRenderer extends InputRendererBase {
}
final Style style = new Style(facesContext, input);
writer.writeStyleAttribute(style);
-
- 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);
}
if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {