tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [23/35] git commit: Rename ControlGroup mixin to FieldGroup
Date Fri, 23 Aug 2013 01:20:03 GMT
Rename ControlGroup mixin to FieldGroup


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/580dbf6d
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/580dbf6d
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/580dbf6d

Branch: refs/heads/master
Commit: 580dbf6dc42ad8d5338fa13a3cd963af5926e516
Parents: 6accb5f
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Thu Aug 22 17:37:52 2013 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Thu Aug 22 17:37:52 2013 -0700

----------------------------------------------------------------------
 54_RELEASE_NOTES.txt                            |  2 +-
 .../tapestry5/corelib/mixins/FormGroup.java     | 65 ++++++++++++++++++++
 .../src/test/app1/AutocompleteDemo.tml          |  2 +-
 tapestry-core/src/test/app1/DisabledFields.tml  | 62 ++++++++++---------
 tapestry-core/src/test/app1/SelectZoneDemo.tml  |  6 +-
 5 files changed, 102 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/580dbf6d/54_RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/54_RELEASE_NOTES.txt b/54_RELEASE_NOTES.txt
index 90bc175..b242cc9 100644
--- a/54_RELEASE_NOTES.txt
+++ b/54_RELEASE_NOTES.txt
@@ -60,7 +60,7 @@ is to allow for the checksum embedded into each URL, which breaks relative
refer
 Tapestry 5.4 introduces a new module, tapestry-wro4j, that provides support for compiling
CoffeeScript into JavaScript,
 Less into CSS, and for minimizing CSS and JavaScript. All processing takes place at runtime.
 
-## ControlGroup Mixin
+## FieldGroup Mixin
 
 This new mixin for Field components adds the outer <div> and <label> elements
for a Field to layout correctly
 inside a Twitter Bootstrap form.

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/580dbf6d/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormGroup.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormGroup.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormGroup.java
new file mode 100644
index 0000000..51d2616
--- /dev/null
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormGroup.java
@@ -0,0 +1,65 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.corelib.mixins;
+
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.HeartbeatDeferred;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.dom.Element;
+
+/**
+ * Applied to a {@link org.apache.tapestry5.Field}, this provides the outer layers of markup
to correctly
+ * render text fields, selects, and textareas using Bootstrap:
+ * an outer {@code <div class="field-group">}, a {@code <label>}, and a
+ * {@code <div class="controls">} around the field itself. This control is not appropriate
+ * for radio buttons or check boxes, as those want to have the label element directly around
the control.
+ * As with the {@link org.apache.tapestry5.corelib.components.Label} component, the {@code
for} attribute is set (after the field itself
+ * renders).
+ * <p/>
+ * This component is not appropriate for radio buttons or checkboxes as they use a different
class on the outermost element
+ * ("radio" or "checkbox") and next the element inside the {@code <label>}.
+ *
+ * @tapestrydoc
+ * @since 5.4
+ */
+public class FormGroup
+{
+
+    @InjectContainer
+    private Field field;
+
+    private Element label;
+
+    void beginRender(MarkupWriter writer)
+    {
+        writer.element("div", "class", "form-group");
+        label = writer.element("label");
+        writer.end();
+        fillInLabelAttributes();
+    }
+
+    @HeartbeatDeferred
+    void fillInLabelAttributes()
+    {
+        label.attribute("for", field.getClientId());
+        label.text(field.getLabel());
+    }
+
+    void afterRender(MarkupWriter writer)
+    {
+        writer.end(); // div.form-group
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/580dbf6d/tapestry-core/src/test/app1/AutocompleteDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/AutocompleteDemo.tml b/tapestry-core/src/test/app1/AutocompleteDemo.tml
index 226b1f3..842f788 100644
--- a/tapestry-core/src/test/app1/AutocompleteDemo.tml
+++ b/tapestry-core/src/test/app1/AutocompleteDemo.tml
@@ -5,7 +5,7 @@
 
         <t:errors/>
 
-        <t:textfield t:id="title" t:mixins="autocomplete,controlgroup" tokens=",;" size="60"/>
+        <t:textfield t:id="title" t:mixins="autocomplete,fieldgroup" tokens=",;" size="60"/>
 
         <div class="form-actions">
             <input type="submit" class="btn btn-primary" value="Show Track"/>

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/580dbf6d/tapestry-core/src/test/app1/DisabledFields.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/DisabledFields.tml b/tapestry-core/src/test/app1/DisabledFields.tml
index 82ce557..a0ea6dc 100644
--- a/tapestry-core/src/test/app1/DisabledFields.tml
+++ b/tapestry-core/src/test/app1/DisabledFields.tml
@@ -1,47 +1,49 @@
 <html t:type="Border"
-      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
 
 
-    <h1>Disabled Fields Demo</h1>
+<h1>Disabled Fields Demo</h1>
 
-    <t:form>
+<t:form>
 
-        <t:textfield t:id="textfield" value="stringValue" disabled="true"/>
-        <br/>
-        <t:passwordfield t:id="passwordfield" value="stringValue" disabled="true"/>
-        <br/>
-        <t:textarea t:id="textarea" value="stringValue" disabled="true"/>
-        <br/>
-        <t:checkbox t:id="checkbox" value="flag" disabled="true"/>
-        <br/>
-        <t:select t:id="select" value="stringValue" disabled="true" model="literal:Up,Down,Strange,Charm,Bottom,Top"/>
-        <br/>
-        <t:radiogroup t:id="group1" value="stringValue" disabled="true">
+    <t:textfield t:id="textfield" value="stringValue" disabled="true"/>
+    <t:passwordfield t:id="passwordfield" value="stringValue" disabled="true"/>
+    <t:textarea t:id="textarea" value="stringValue" disabled="true"/>
+    <t:checkbox t:id="checkbox" value="flag" disabled="true"/>
+    <t:select t:id="select" value="stringValue" disabled="true" model="literal:Up,Down,Strange,Charm,Bottom,Top"/>
+
+    <t:radiogroup t:id="group1" value="stringValue" disabled="true">
+        <label>
             <t:radio t:id="radio1" value="literal:Right"/>
-        </t:radiogroup>
+            Disabled Radio #1
+        </label>
+    </t:radiogroup>
 
-        <br/>
+    <br/>
 
-        <t:radiogroup t:id="group2" value="stringValue">
+    <t:radiogroup t:id="group2" value="stringValue">
+        <label>
             <t:radio t:id="radio2" disabled="true" value="literal:Left"/>
-        </t:radiogroup>
+            Disabled Radio #2
+        </label>
+    </t:radiogroup>
 
-        <br/>
+    <br/>
 
-        <t:datefield t:id="datefield" value="date" disabled="true"/>
+    <t:datefield t:id="datefield" value="date" disabled="true"/>
 
-        <br/>
+    <br/>
 
-        <t:palette t:id="palette" selected="values" disabled="true" encoder="encoder"
-                   model="literal:Fred,Barney,Wilma,Betty"/>
+    <t:palette t:id="palette" selected="values" disabled="true" encoder="encoder"
+               model="literal:Fred,Barney,Wilma,Betty"/>
 
-        <br/>
+    <br/>
 
-        <t:submit t:id="submit" disabled="true" value="Disabled Submit"/>
-        <input type="submit" value="Continue"/>
-    </t:form>
+    <t:submit t:id="submit" disabled="true" value="Disabled Submit"/>
+    <input class="btn btn-default" type="submit" value="Continue"/>
+</t:form>
 
-    <p>
-        Submit id: ${submit.clientId}
-    </p>
+<p>
+    Submit id: ${submit.clientId}
+</p>
 </html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/580dbf6d/tapestry-core/src/test/app1/SelectZoneDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/SelectZoneDemo.tml b/tapestry-core/src/test/app1/SelectZoneDemo.tml
index 6928ae6..540980c 100644
--- a/tapestry-core/src/test/app1/SelectZoneDemo.tml
+++ b/tapestry-core/src/test/app1/SelectZoneDemo.tml
@@ -1,4 +1,4 @@
-<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
 
     <div class="well">
         <dl class="dl-horizontal">
@@ -12,7 +12,7 @@
     <t:form class="well">
         <t:errors/>
 
-        <t:select t:id="carMaker" validate="required" t:mixins="controlgroup"
+        <t:select t:id="carMaker" validate="required" t:mixins="fieldgroup"
                   model="makeModel" zone="modelZone" encoder="makeEncoder"/>
 
 
@@ -24,7 +24,7 @@
 
         <t:block id="modelBlock">
             <t:select t:id="carModel" model="availableModels" validate="required" blankOption="always"
-                      t:mixins="controlgroup"/>
+                      t:mixins="fieldgroup"/>
         </t:block>
 
         <div class="form-actions">


Mime
View raw message