You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2019/12/02 09:29:49 UTC

[myfaces-tobago] 12/19: Tobago-1999: placeholder on selectOneChoice

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

weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit d2230b639957043074b89b2b930c48da9adb890a
Author: Volker Weber <v....@inexso.de>
AuthorDate: Tue Aug 27 17:46:40 2019 +0200

    Tobago-1999: placeholder on selectOneChoice
---
 .../src/main/webapp/content/25-select/00-select2/select2.xhtml   | 9 ++++-----
 .../html/standard/standard/tag/SelectOneChoiceRenderer.java      | 6 +++++-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
index 7a6efab..7dad3ba 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
@@ -63,11 +63,11 @@
           <tc:selectItem itemLabel="Fax" itemValue="fax"/>
         </tc:selectOneChoice>
 
-        <tc:label value="Suppressed filter input " for="one_2"/>
+        <tc:label value="Suppressed filter input with placeholder" for="one_2"/>
         <tc:selectOneChoice id="one_2"
                             minimumResultsForSearch="10"
-                            value=""
-                            select2="true">
+                            placeholder="Please select message type"
+                            value="">
 
           <tc:selectItem itemLabel="Letter" itemValue="letter"/>
           <tc:selectItem itemLabel="Phone" itemValue="phone"/>
@@ -80,8 +80,7 @@
                             allowCustom="true"
                             placeholder="Custom input allowed"
                             allowClear="true"
-                            value=""
-                            select2="true">
+                            value="">
 
           <tc:selectItem itemLabel="Letter" itemValue="letter"/>
           <tc:selectItem itemLabel="Phone" itemValue="phone"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
index 6894df1..6fe0360 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
@@ -99,7 +99,11 @@ public class SelectOneChoiceRenderer extends SelectOneRendererBase {
     }
     HtmlRendererUtils.renderCommandFacet(select, facesContext , writer);
     HtmlRendererUtils.renderFocus(id, select.isFocus(), ComponentUtils.isError(select), facesContext, writer);
-    
+    if (renderAsSelect2 && select.getPlaceholder() != null && select.getPlaceholder().length() > 0) {
+     writer.startElement(HtmlElements.OPTION, null);
+     writer.endElement(HtmlElements.OPTION);
+    }
+
     HtmlRendererUtils.renderSelectItems(select, items, select.getValue(), (String) select.getSubmittedValue(), writer,
         facesContext);