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 2016/05/27 17:08:12 UTC

svn commit: r1745775 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ tobago-example/tobago-example-demo/src/main/webapp/content/20...

Author: lofwyr
Date: Fri May 27 17:08:12 2016
New Revision: 1745775

URL: http://svn.apache.org/viewvc?rev=1745775&view=rev
Log:
TOBAGO-1564: Bootstrap input groups
* first impl

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.xhtml
      - copied, changed from r1745771, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.xhtml
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java?rev=1745775&r1=1745774&r2=1745775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java Fri May 27 17:08:12 2016
@@ -21,7 +21,9 @@ package org.apache.myfaces.tobago.compon
 
 public enum Facets {
 
+  after,
   action,
+  before,
   brand,
   change,
   checkbox,
@@ -49,7 +51,9 @@ public enum Facets {
   sorter,
   toolBar;
 
+  public static final String AFTER = "after";
   public static final String ACTION = "action";
+  public static final String BEFORE = "before";
   public static final String BRAND = "brand";
   public static final String CHANGE = "change";
   public static final String CHECKBOX = "checkbox";

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java?rev=1745775&r1=1745774&r2=1745775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/InTagDeclaration.java Fri May 27 17:08:12 2016
@@ -66,7 +66,13 @@ import javax.faces.component.UIInput;
     facets = {
     @Facet(name = Facets.CHANGE,
         description =
-            "This facet can contain a UICommand that is invoked in a case of a change event from the component")
+            "This facet can contain a UICommand that is invoked in a case of a change event from the component"),
+    @Facet(name = Facets.BEFORE,
+        description =
+            "This facet can contain a part for input groups."),
+    @Facet(name = Facets.AFTER,
+        description =
+            "This facet can contain a part for input groups.")
         })
 public interface InTagDeclaration
     extends HasIdBindingAndRendered, HasConverter, IsReadonly, IsDisabled, IsRequired, HasTip, IsPassword,

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.xhtml (from r1745771, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.xhtml?p2=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.xhtml&r1=1745771&r2=1745775&rev=1745775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/10-in/in.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/group.xhtml Fri May 27 17:08:12 2016
@@ -22,61 +22,50 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core">
-  <ui:param name="title" value="#{overviewBundle.in} &lt;tc:in&gt;"/>
-  <p>The <code class="language-markup">&lt;tc:in/&gt;</code> tag create a classic inputfield.</p>
-  <tc:link label="Tag Library Documentation" image="image/feather-leaf.png" link="#{overviewBundle.tagDocUrl}/in.html"/>
-  <tc:section label="Basics">
-    <p>In most cases, a label should be placed in front of every inputfield. Use the attribute
-      <code>label</code>.</p>
-    <pre><code class="language-markup">&lt;tc:in label="Input" value="Some Text"/&gt;</code></pre>
-    <tc:in id="i1" label="Input" value="Some Text"/>
-    <tc:in id="i2" label="Read Only" readonly="true" value="Some Text"/>
-    <tc:in id="i3" label="Disabled" disabled="true" value="Some Text"/>
-    <tc:in id="i4" value="Input without a label"/>
-  </tc:section>
 
-  <tc:section label="Focus">
-    <p>The following inputfield should be selected after reloading the page. Use the <code>focus</code> attribute.</p>
-    <pre><code class="language-markup">&lt;tc:in label="Input (focus)" focus="true" value="Some Text"/&gt;</code></pre>
-    <tc:in id="i5" label="Input (focus)" focus="true" value="Some Text"/>
-  </tc:section>
+  <tc:section label="Input Groups">
 
-  <tc:section label="Required">
-    <p>An inputfield can be set as required with the <code>required</code> attribute.
-      Such an inputfield must contain a value, otherwise a submit is not possible.
-      Leave the field blank and press 'submit' to see the errormessage.</p>
-    <pre><code class="language-markup">&lt;tc:in label="Input (required)" required="true"/></code></pre>
-    <tc:in id="ireq" label="Input (required)" required="true"/>
-    <tc:button label="Submit"/>
-  </tc:section>
+    <tc:in id="nogroup" label="No group"/>
 
-  <tc:section label="Password">
-    <p>To create an inputfield for passwords, set the
-      <code>password</code> attribute to 'true'. It will hide the text as shown in the following example.</p>
-        <pre><code id="c3"
-                   class="language-markup">&lt;tc:in label="Password" password="true" value="password"/&gt;</code></pre>
-    <tc:in id="i6" label="Password" password="true" value="password"/>
-  </tc:section>
+    <tc:in id="group" label="Group">
+      <f:facet name="before">
+        <i class="fa fa-money"/>
+      </f:facet>
+      <f:facet name="after">€</f:facet>
+    </tc:in>
 
-  <tc:section label="Placeholder">
-    <p>A <code>placeholder</code> attribute can be used for explaining a user the meaning of a field.</p>
-    <p>The text of the placeholder is only shown if the value is an empty string.</p>
-    <pre><code class="language-markup">&lt;tc:in label="Placeholder" placeholder="Grey Text"/&gt;</code></pre>
-    <tc:in id="i7" label="Placeholder" placeholder="Short description of the field." value=""/>
-  </tc:section>
+    <tc:in id="links" label="Links">
+      <f:facet name="before">
+        <tc:link image="fa-money"/>
+      </f:facet>
+      <f:facet name="after">
+        Some text ...
+      </f:facet>
+    </tc:in>
 
-  <tc:section label="Ajax">
-    <p>The outputfield in this example, displays the given value on the server.
-      With <code class="language-markup">&lt;f:ajax render="outputfield" listener="\#{inController.update}"/></code>,
-      the outputfield will be rerendered, after the value has been changed.
-      This is because <code>outputfield</code> is the id of the <code>&lt;tc:out/></code> tag.
-      and the default event for <code class="language-markup">&lt;tc:in/></code> is <code>change</code>.
-
-      Additional, the <code>listener</code> attribute is set. The given method is called after the inputfield
-      loose focus.</p>
-    <tc:in id="i8" label="On Change" value="#{inController.changeValue}">
-      <f:ajax render="outputfield" listener="#{inController.update}"/>
+    <tc:in id="singleselect" label="Single Select">
+      <f:facet name="before">
+        <tc:link omit="true">
+          <tc:selectOneRadio value="#{clientConfigController.theme}">
+            <f:facet name="change">
+              <tc:command action="#{clientConfigController.submit}"/>
+            </f:facet>
+            <tc:selectItems value="#{clientConfigController.themeItems}"/>
+          </tc:selectOneRadio>
+        </tc:link>
+      </f:facet>
+      <f:facet name="after">
+        <tc:link omit="true">
+          <tc:selectOneRadio value="#{clientConfigController.theme}">
+            <f:facet name="change">
+              <tc:command action="#{clientConfigController.submit}"/>
+            </f:facet>
+            <tc:selectItems value="#{clientConfigController.themeItems}"/>
+          </tc:selectOneRadio>
+        </tc:link>
+      </f:facet>
     </tc:in>
-    <tc:out id="outputfield" label="On Server" value="#{inController.changeValue}"/>
+
   </tc:section>
+
 </ui:composition>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java?rev=1745775&r1=1745774&r2=1745775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java Fri May 27 17:08:12 2016
@@ -118,6 +118,7 @@ public enum BootstrapClass implements Cs
   ICON_BAR("icon-bar"),
   INFO("info"),
   INPUT_GROUP("input-group"),
+  INPUT_GROUP_ADDON("input-group-addon"),
   INPUT_GROUP_BTN("input-group-btn"),
   INVISIBLE("invisible"),
   MODAL("modal"),

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java?rev=1745775&r1=1745774&r2=1745775&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/InRenderer.java Fri May 27 17:08:12 2016
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.internal.component.AbstractUIInput;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
@@ -65,6 +66,20 @@ public class InRenderer extends LabelLay
 
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
+    final UIComponent after = ComponentUtils.getFacet(input, Facets.after);
+    final UIComponent before = ComponentUtils.getFacet(input, Facets.before);
+
+    if (after != null || before != null) {
+      writer.startElement(HtmlElements.DIV);
+      writer.writeClassAttribute(BootstrapClass.INPUT_GROUP);
+    }
+    if (before != null) {
+      writer.startElement(HtmlElements.SPAN);
+      writer.writeClassAttribute(BootstrapClass.INPUT_GROUP_ADDON);
+      RenderUtils.encode(facesContext, before);
+      writer.endElement(HtmlElements.SPAN);
+    }
+
     writer.startElement(HtmlElements.INPUT);
 
     if (input.getAccessKey() != null) {
@@ -123,6 +138,16 @@ public class InRenderer extends LabelLay
     }
 
     writer.endElement(HtmlElements.INPUT);
+
+    if (after != null) {
+      writer.startElement(HtmlElements.SPAN);
+      writer.writeClassAttribute(BootstrapClass.INPUT_GROUP_ADDON);
+      RenderUtils.encode(facesContext, after);
+      writer.endElement(HtmlElements.SPAN);
+    }
+    if (after != null || before != null) {
+      writer.endElement(HtmlElements.DIV);
+    }
   }
 
   @Override