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 2017/09/14 08:58:28 UTC

[myfaces-tobago] 01/03: TOBAGO-1786: Selector to address UIStyle

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

commit 793d30cceb53be73de42fcc3f73609c1b2ff889b
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Sep 13 19:57:16 2017 +0200

    TOBAGO-1786: Selector to address UIStyle
---
 .../tobago/internal/util/HtmlRendererUtils.java    |  8 +--
 .../070-tab/02-server/tab-server.xhtml             |  9 +++
 .../10-collapsible-popup/collapsible-popup.xhtml   | 76 ++++------------------
 3 files changed, 25 insertions(+), 68 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlRendererUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlRendererUtils.java
index c511b3c..4419f7d 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlRendererUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlRendererUtils.java
@@ -242,10 +242,10 @@ public final class HtmlRendererUtils {
                 .createComponent(facesContext, UIStyle.COMPONENT_TYPE, RendererTypes.Style.name());
             style.setTransient(true);
             style.setBackgroundImage(image);
-
-            // XXX here we add the style to a component, but this is not the component the style must be affected.
-            // The right one is <option>, but there is no UIComponent for <option>, so we need an other solution.
-            // May be a "for" or a "selector" attribute in UIStyle. See also TOBAGO-1777
+            style.setSelector(
+                StyleRenderUtils.encodeIdSelector(component.getClientId(facesContext))
+                    + " option[value=" + formattedValue + "]");
+            // XXX This works not in common browsers...
             component.getChildren().add(style);
           }
         }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
index 06b3be7..383fdef 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
@@ -36,11 +36,20 @@
     <tc:link label="&lt;tc:tabChangeListener/>" image="#{request.contextPath}/image/feather-leaf.png"
              link="#{demoBundle.tagDocUrl}/#{info.stableVersion}/tld/tc/tabChangeListener.html"/></p>
 
+  <tc:popup id="xy" collapsed="false">
+    <tc:button label="close">
+      <tc:operation name="hide" for="xy"/>
+    </tc:button>
+  </tc:popup>
+
   <tc:section label="Basics">
     <p>A simple tabgroup. The second tab is disabled.</p>
     <tc:tabGroup id="tg1" switchType="reloadPage">
       <tc:tab id="t11" label="One">
         First tab.
+        <tc:button label="open">
+          <tc:operation name="show" for=":::xy"/>
+        </tc:button>
       </tc:tab>
       <tc:tab id="t12" label="Two" disabled="true">
         Second tab.
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
index 5a80a92..1e03bf2 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
@@ -26,71 +26,19 @@
     <tc:link label="#{demoBundle.popup}" outcome="/content/20-component/060-popup/popup.xhtml"/> page
     in the components section for more details.</p>
 
-  <tc:section label="Simple Popup">
-    <tc:form id="simple">
-      <p>A popup opened with the help of a controller. The popup contain a required inputfield.
-        The attribute <code>collapsedMode="absent"</code> is set,
-        so the 'Submit'-button outside the popup could be executed while popup is hidden.
-        Even if the required inputfield is empty.</p>
-      <tc:button id="open1" label="Open" action="#{collapsiblePopupController.open}"/>
-      <tc:button id="submitOnPage1" label="Submit"/>
-      <tc:popup id="controllerPopup" collapsed="#{collapsiblePopupController.collapsed}">
-        <tc:box label="Simple Popup">
-          <tc:in id="in1" label="Required" required="true"/>
-          <tc:button id="submitOnPopup1" label="Submit"/>
-          <tc:button id="close1" label="Close" immediate="true" action="#{collapsiblePopupController.close}"/>
-        </tc:box>
-      </tc:popup>
-    </tc:form>
-  </tc:section>
+  <tc:button label="click me"/>
 
-  <tc:section label="Full Server Request">
-    <tc:form id="server">
-      <p>Server sided popup with <code class="language-markup">&lt;tc:operation/></code>.
-        The attribute <code>collapsedMode="absent"</code> is set by default.
-        If you press the 'Submit'-button in the popup, the popup remains open,
-        because the server know the current state.</p>
-      <tc:button id="open2" label="Open">
-        <tc:operation name="show" for="fullServerRequestPopup"/>
-      </tc:button>
-      <tc:button id="submitOnPage2" label="Submit"/>
-      <tc:popup id="fullServerRequestPopup">
-        <tc:box label="Full Server Request">
-          <tc:in id="in2" label="Required" required="true"/>
-          <tc:button id="submitOnPopup2" label="Submit"/>
-          <tc:button id="close2" label="Close" immediate="true">
-            <tc:operation name="hide" for="fullServerRequestPopup"/>
-          </tc:button>
-        </tc:box>
-      </tc:popup>
-    </tc:form>
-  </tc:section>
+  <tc:button id="open3" label="Open" omit="true">
+    <tc:operation name="show" for="clientPopup"/>
+  </tc:button>
+
+  <tc:popup id="clientPopup" collapsedMode="hidden">
+    <tc:box label="Full Server Request">
 
-  <tc:section label="Client Sided">
-    <tc:form id="client">
-      <p>For the client sided popup the attribute <code>collapsedMode="hidden"</code> must be set.
-        So the hidden popup is already rendered on the site. Otherwise a client sided opened popup has no content.</p>
-      <p>This leads to the problem of violations of hidden content.
-        In this case you cannot press the 'Submit'-button if the required field is empty.
-        Even if the popup is hidden.</p>
-      <p>The 'Submit'-button in the popup will close the popup, because the server didn't know the current state.</p>
-      <p>To avoid server request, the attribute <code>omit="true"</code>
-        is added to the 'Open'-button and the 'Close'-button.</p>
-      <tc:button id="open3" label="Open" omit="true">
-        <tc:operation name="show" for="clientPopup"/>
+      <tc:button id="close3" label="Close" omit="true">
+        <tc:operation name="hide" for="clientPopup"/>
       </tc:button>
-      <tc:button id="submitOnPage3" label="Submit"/>
-      <tc:popup id="clientPopup" collapsedMode="hidden">
-        <tc:box label="Full Server Request">
-          <p>The opening of the popup is client sided.
-            Therefor the popup will be closed after pressing the 'Submit'-button which reload the page.</p>
-          <tc:in id="in3" label="Required" required="true"/>
-          <tc:button id="submitOnPopup3" label="Submit"/>
-          <tc:button id="close3" label="Close" omit="true">
-            <tc:operation name="hide" for="clientPopup"/>
-          </tc:button>
-        </tc:box>
-      </tc:popup>
-    </tc:form>
-  </tc:section>
+    </tc:box>
+  </tc:popup>
+
 </ui:composition>

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