You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/09/14 13:13:06 UTC

[myfaces-tobago] branch master updated: TOBAGO-1740 Images for tc:selectManyCheckbox * implement images for tc:selectManyCheckbox * add examples for images (tc:selectManyCheckbox and tc:selectOneRadio)

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

hnoeth 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 5cb9f01  TOBAGO-1740 Images for tc:selectManyCheckbox * implement images for tc:selectManyCheckbox * add examples for images (tc:selectManyCheckbox and tc:selectOneRadio)
5cb9f01 is described below

commit 5cb9f01e6208113644ef8a14ebb7b254f8e2a998
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Sep 14 14:36:37 2017 +0200

    TOBAGO-1740 Images for tc:selectManyCheckbox
    * implement images for tc:selectManyCheckbox
    * add examples for images (tc:selectManyCheckbox and tc:selectOneRadio)
---
 .../renderkit/renderer/SelectManyCheckboxRenderer.java       | 12 ++++++++++++
 .../030-select/30-selectOneRadio/selectOneRadio.xhtml        |  8 ++++++++
 .../50-selectManyCheckbox/selectManyCheckbox.xhtml           |  8 ++++++++
 3 files changed, 28 insertions(+)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java
index 5eacd73..a599986 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java
@@ -115,6 +115,18 @@ public class SelectManyCheckboxRenderer extends SelectManyRendererBase {
       writer.writeClassAttribute(TobagoClass.INPUT_PSEUDO);
       writer.endElement(HtmlElements.I);
 
+      if (item instanceof org.apache.myfaces.tobago.model.SelectItem) {
+        org.apache.myfaces.tobago.model.SelectItem tobagoItem = (org.apache.myfaces.tobago.model.SelectItem) item;
+        final String image = tobagoItem.getImage();
+
+        if (image != null) {
+          writer.startElement(HtmlElements.IMG);
+          writer.writeAttribute(HtmlAttributes.SRC, image, true);
+          writer.writeAttribute(HtmlAttributes.ALT, "", false);
+          writer.endElement(HtmlElements.IMG);
+        }
+      }
+
       final String label = item.getLabel();
       if (label != null) {
         writer.writeText(label);
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml
index 3b8daee..b362054 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/30-selectOneRadio/selectOneRadio.xhtml
@@ -69,6 +69,14 @@
     </tc:selectOneRadio>
   </tc:section>
 
+  <tc:section label="Images">
+    <tc:selectOneRadio>
+      <tc:selectItems value="#{demoController.currencyItems}"
+                      var="currency" itemValue="#{currency.currencyCode}" itemLabel="#{currency.displayName}"
+                      itemImage="#{request.contextPath}/data/#{currency.currencyCode}-14.png"/>
+    </tc:selectOneRadio>
+  </tc:section>
+
   <tc:section label="Simple Usage">
     <p>Add number1 to number2 or subtract number2 from number1.</p>
     <p>The radiobuttons are hardcoded with
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.xhtml
index bd5bd19..b10c9b4 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/030-select/50-selectManyCheckbox/selectManyCheckbox.xhtml
@@ -63,6 +63,14 @@
     </tc:selectManyCheckbox>
   </tc:section>
 
+  <tc:section label="Images">
+    <tc:selectManyCheckbox>
+      <tc:selectItems value="#{demoController.currencyItems}"
+                      var="currency" itemValue="#{currency.currencyCode}" itemLabel="#{currency.displayName}"
+                      itemImage="#{request.contextPath}/data/#{currency.currencyCode}-14.png"/>
+    </tc:selectManyCheckbox>
+  </tc:section>
+
   <tc:section label="Simple Usage">
     <p>Select an animal. The selection is shown in the outputfield, after pressing 'Submit'.</p>
     <p><code

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].