tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thiag...@apache.org
Subject git commit: TAP5-2182: BeanEditor should be more flexible in the markup it generates (was BeanEditor doesn't look as good in T5.4 as in T5.3)
Date Thu, 31 Oct 2013 18:31:00 GMT
Updated Branches:
  refs/heads/master a663b5838 -> 9d91c20a4


TAP5-2182: BeanEditor should be more flexible in the markup it generates
(was BeanEditor doesn't look as good in T5.4 as in T5.3)

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

Branch: refs/heads/master
Commit: 9d91c20a4277730c64f830aa5f5b5245a40c496c
Parents: a663b58
Author: Thiago H. de Paula Figueiredo <thiagohp@apache.org>
Authored: Thu Oct 31 16:30:43 2013 -0200
Committer: Thiago H. de Paula Figueiredo <thiagohp@apache.org>
Committed: Thu Oct 31 16:30:43 2013 -0200

----------------------------------------------------------------------
 .../org/apache/tapestry5/SymbolConstants.java   | 58 +++++++++++++++++++
 .../tapestry5/corelib/base/AbstractField.java   |  5 ++
 .../tapestry5/corelib/components/DateField.java |  2 +-
 .../corelib/components/PasswordField.java       |  2 +-
 .../tapestry5/corelib/components/Select.java    |  2 +-
 .../tapestry5/corelib/components/TextArea.java  |  2 +-
 .../tapestry5/corelib/components/TextField.java |  2 +-
 .../tapestry5/corelib/mixins/FormGroup.java     | 60 ++++++++++++++++++--
 .../tapestry5/modules/TapestryModule.java       |  7 +++
 .../BeanEditorWithOverridenCssClassesDemo.tml   | 10 ++++
 tapestry-core/src/test/app3/Login.tml           |  3 +
 ...eanEditorWithOverridenCssClassesTests.groovy | 38 +++++++++++++
 .../integration/app1/BeanEditorTests.java       | 20 +++++++
 .../BeanEditorWithOverridenCssClassesDemo.java  | 60 ++++++++++++++++++++
 .../integration/app3/services/AppModule.java    | 17 ++++++
 15 files changed, 279 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
index 0299ee9..dcf4a44 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
@@ -14,6 +14,10 @@
 
 package org.apache.tapestry5;
 
+import org.apache.tapestry5.corelib.base.AbstractField;
+import org.apache.tapestry5.corelib.components.BeanEditForm;
+import org.apache.tapestry5.corelib.components.BeanEditor;
+import org.apache.tapestry5.corelib.mixins.FormGroup;
 import org.apache.tapestry5.internal.services.AssetDispatcher;
 import org.apache.tapestry5.services.assets.AssetPathConstructor;
 import org.apache.tapestry5.services.assets.ResourceMinimizer;
@@ -421,5 +425,59 @@ public class SymbolConstants
      * @see https://issues.apache.org/jira/browse/TAP5-2169
      */
     public static final String INCLUDE_CORE_STACK = "tapestry.include-core-stack";
+    
+    /**
+     * Defines the CSS class that will be given to HTML element (usually a div) &lt;div&gt;
generated by
+     * the {@linkplain FormGroup} mixin and the 
+     * {@linkplain BeanEditForm} and {@linkplain BeanEditor}
+     * components surrounding the label and the field. The default value is <code>form-group</code>.
+     * 
+     * @since 5.4
+     * @see https://issues.apache.org/jira/browse/TAP5-2182
+     */
+    public static final String FORM_GROUP_WRAPPER_CSS_CLASS = "tapestry.form-group-wrapper-css-class";
+    
+    /**
+     * Defines the name of the HTML element that will surround the HTML form field generated
by
+     * the {@linkplain FormGroup} mixin and the {@linkplain BeanEditForm} and {@linkplain
BeanEditor}.
+     * If this symbol is null or an empty string, no element will be generated surrouding
the
+     * form field. The default value is the empty string (no wrapping).
+     * 
+     * @since 5.4
+     * @see https://issues.apache.org/jira/browse/TAP5-2182
+     * @see #FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS
+     */
+    public static final String FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME = "tapestry.form-group-form-field-wrapper-element-name";
+
+    /**
+     * Defines the CSS class of the HTML element generated by
+     * the {@linkplain FormGroup} mixin and the {@linkplain BeanEditForm} and {@linkplain
BeanEditor}.
+     * when {@linkplain FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME} is not set to null or
the empty string.
+     * The default value is the empty string (no CSS class added).
+     * 
+     * @since 5.4
+     * @see https://issues.apache.org/jira/browse/TAP5-2182
+     */
+    public static final String FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS = "tapestry.form-group-form-field-wrapper-element-css-class";
+
+    /**
+     * Defines the CSS class that will be given to &lt;label&gt; element generated
by
+     * the {@linkplain FormGroup} mixin and the 
+     * {@linkplain BeanEditForm} and {@linkplain BeanEditor}
+     * components. The default value is <code>control-label</code>.
+     * 
+     * @since 5.4
+     * @see https://issues.apache.org/jira/browse/TAP5-2182
+     */
+    public static final String FORM_GROUP_LABEL_CSS_CLASS = "tapestry.form-group-label-css-class";
+
+    /**
+     * Defines the CSS class that will be given to form field components which are
+     * {@linkplain AbstractField} subclasses. The default value is <code>form-control</code>.
+     * 
+     * @since 5.4
+     * @see https://issues.apache.org/jira/browse/TAP5-2182
+     */
+    public static final String FORM_FIELD_CSS_CLASS = "tapestry.form-field-css-class";
 
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractField.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractField.java
index 35e65bd..7600709 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractField.java
@@ -21,6 +21,7 @@ import org.apache.tapestry5.corelib.mixins.RenderInformals;
 import org.apache.tapestry5.internal.BeanValidationContext;
 import org.apache.tapestry5.internal.InternalComponentResources;
 import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.ComponentDefaultProvider;
 import org.apache.tapestry5.services.Environment;
 import org.apache.tapestry5.services.FormSupport;
@@ -64,6 +65,10 @@ public abstract class AbstractField implements Field
 
     @Inject
     protected Environment environment;
+    
+    @Inject
+    @Symbol(SymbolConstants.FORM_FIELD_CSS_CLASS)
+    protected String cssClass;
 
     static class Setup implements ComponentAction<AbstractField>, Serializable
     {

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
index 96db67d..aebb4a6 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
@@ -217,7 +217,7 @@ public class DateField extends AbstractField
 
                 "type", hideTextField ? "hidden" : "text",
 
-                "class", "form-control",
+                "class", cssClass,
 
                 "name", getControlName(),
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PasswordField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PasswordField.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PasswordField.java
index edd779b..d64694f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PasswordField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PasswordField.java
@@ -40,7 +40,7 @@ public class PasswordField extends AbstractTextField
 
                        "type", "password",
 
-                        "class", "form-control",
+                        "class", cssClass,
 
                        "name", getControlName(),
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
index abe41bd..d5e3ff2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
@@ -206,7 +206,7 @@ public class Select extends AbstractField
         writer.element("select",
                 "name", getControlName(),
                 "id", getClientId(),
-                "class", "form-control");
+                "class", cssClass);
 
         putPropertyNameIntoBeanValidationContext("value");
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextArea.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextArea.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextArea.java
index bf0310f..e46ee37 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextArea.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextArea.java
@@ -41,7 +41,7 @@ public class TextArea extends AbstractTextField
 
                 "name", getControlName(),
 
-                "class", "form-control",
+                "class", cssClass,
 
                 "id", getClientId(),
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
index 2c1c40c..ddf9f2f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
@@ -48,7 +48,7 @@ public class TextField extends AbstractTextField
 
                        "name", getControlName(),
 
-                    "class", "form-control",
+                       "class", cssClass,
 
                        "id", getClientId(),
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/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
index d75d046..424fc5a 100644
--- 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
@@ -16,47 +16,96 @@ package org.apache.tapestry5.corelib.mixins;
 
 import org.apache.tapestry5.Field;
 import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ValidationDecorator;
 import org.apache.tapestry5.annotations.Environmental;
 import org.apache.tapestry5.annotations.HeartbeatDeferred;
 import org.apache.tapestry5.annotations.InjectContainer;
 import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 
 /**
- * Applied to a {@link org.apache.tapestry5.Field}, this provides the outer layers of markup
to correctly
+ * <p>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">} containing a {@code <label class="control-label">}
and the field itself.
+ * Actually, the class attribute of the div is defined by the  
+ * {@link SymbolConstants#FORM_GROUP_WRAPPER_CSS_CLASS} and
+ * the class attribute of label is defined by the {@link SymbolConstants#FORM_GROUP_LABEL_CSS_CLASS}.
+ * <code>field-group</code> and <code>control-label</code> are the
default values. 
  * As with the {@link org.apache.tapestry5.corelib.components.Label} component, the {@code
for} attribute is set (after the field itself
  * renders).
- * <p/>
+ * </p>
+ * <p>
+ * You can also use the {@link SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME}
symbol
+ * to optionally wrap the input field in an element and {@link SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS}
+ * to give it a CSS class. This is useful for Bootstrap form-horizontal forms.
+ * Setting {@link SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME} to <code>div</code>,
+ * {@link SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS} to <code>col-sm-10</code>
+ * and {@link SymbolConstants#FORM_GROUP_LABEL_CSS_CLASS} to <code>col-sm-2</code>
+ * will generate labels 2 columns wide and form fields 10 columns wide.
+ * </p>
+ * <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>}.
+ * </p>
  *
  * @tapestrydoc
  * @since 5.4
+ * @see SymbolConstants#FORM_GROUP_WRAPPER_CSS_CLASS
+ * @see SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME
+ * @see SymbolConstants#FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS
+ * @see SymbolConstants#FORM_GROUP_LABEL_CSS_CLASS
+ * @see SymbolConstants#FORM_FIELD_CSS_CLASS
  */
 public class FormGroup
 {
     @InjectContainer
     private Field field;
+    
+    @Inject
+    @Symbol(SymbolConstants.FORM_GROUP_LABEL_CSS_CLASS)
+    private String labelCssClass;
+    
+    @Inject
+    @Symbol(SymbolConstants.FORM_GROUP_WRAPPER_CSS_CLASS)
+    private String divCssClass;
+    
+    @Inject
+    @Symbol(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME)
+    private String fieldWrapperElementName;
+
+    @Inject
+    @Symbol(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS)
+    private String fieldWrapperElementCssClass;
 
     private Element label;
+    
+    private Element fieldWrapper;
 
     @Environmental
     private ValidationDecorator decorator;
 
     void beginRender(MarkupWriter writer)
     {
-        writer.element("div", "class", "form-group");
+        writer.element("div", "class", divCssClass);
 
         decorator.beforeLabel(field);
 
-        label = writer.element("label", "class", "control-label");
+        label = writer.element("label", "class", labelCssClass);
         writer.end();
 
         fillInLabelAttributes();
 
         decorator.afterLabel(field);
+        
+        if (fieldWrapperElementName.length() > 0) {
+            fieldWrapper = writer.element(fieldWrapperElementName);
+            if (fieldWrapperElementCssClass.length() > 0) {
+                fieldWrapper.attribute("class", fieldWrapperElementCssClass);
+            }
+        }
+        
     }
 
     @HeartbeatDeferred
@@ -68,6 +117,9 @@ public class FormGroup
 
     void afterRender(MarkupWriter writer)
     {
+        if (fieldWrapper != null) {
+            writer.end(); // field wrapper
+        }
         writer.end(); // div.form-group
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index 6848cb2..fd578b7 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -2121,6 +2121,13 @@ public final class TapestryModule
         
         // TAP5-2197
         configuration.add(SymbolConstants.INCLUDE_CORE_STACK, true);
+        
+        // TAP5-2182
+        configuration.add(SymbolConstants.FORM_GROUP_WRAPPER_CSS_CLASS, "form-group");
+        configuration.add(SymbolConstants.FORM_GROUP_LABEL_CSS_CLASS, "control-label");
+        configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME, "");
+        configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS,
"");
+        configuration.add(SymbolConstants.FORM_FIELD_CSS_CLASS, "form-control");
 
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/app3/BeanEditorWithOverridenCssClassesDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app3/BeanEditorWithOverridenCssClassesDemo.tml b/tapestry-core/src/test/app3/BeanEditorWithOverridenCssClassesDemo.tml
new file mode 100644
index 0000000..a50b4e1
--- /dev/null
+++ b/tapestry-core/src/test/app3/BeanEditorWithOverridenCssClassesDemo.tml
@@ -0,0 +1,10 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <head>
+        <title>BeanDisplay Global Override Demo</title>
+    </head>
+    <body>
+    	<t:form class="form-horizontal">
+        	<t:beaneditor object="this"/>
+        </t:form>
+    </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/app3/Login.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app3/Login.tml b/tapestry-core/src/test/app3/Login.tml
index cfb459b..9fba45c 100644
--- a/tapestry-core/src/test/app3/Login.tml
+++ b/tapestry-core/src/test/app3/Login.tml
@@ -19,6 +19,9 @@
             <li>
                 <t:pagelink page="consoledemo">Console demo</t:pagelink>
             </li>
+            <li>
+                <t:pagelink page="BeanEditorWithOverridenCssClassesDemo">BeanEditor
with overriden CSS classes demo</t:pagelink>
+            </li>
         </ul>
 
     </body>

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app3/BeanEditorWithOverridenCssClassesTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app3/BeanEditorWithOverridenCssClassesTests.groovy
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app3/BeanEditorWithOverridenCssClassesTests.groovy
new file mode 100644
index 0000000..92d4463
--- /dev/null
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app3/BeanEditorWithOverridenCssClassesTests.groovy
@@ -0,0 +1,38 @@
+package org.apache.tapestry5.integration.app3
+
+import org.apache.tapestry5.integration.app3.services.AppModule
+import org.apache.tapestry5.corelib.components.BeanEditForm
+import org.apache.tapestry5.corelib.components.BeanEditor
+import org.apache.tapestry5.integration.TapestryCoreTestCase
+import org.apache.tapestry5.integration.app1.data.RegistrationData
+import org.apache.tapestry5.integration.app3.services.AppModule
+import org.apache.tapestry5.test.TapestryTestConfiguration
+import org.testng.annotations.Test
+
+/**
+ * Tests for the {@link BeanEditor} component CSS overrides
+ */
+@TapestryTestConfiguration(webAppFolder = "src/test/app3")
+@Test
+public class BeanEditorTestsWithOverridenCssClassesTests extends TapestryCoreTestCase
+{
+    
+    /** TAP5-2182 */
+    public void bean_editor_overriden_markup() {
+
+        final String formGroupLocator = String.format("//form[@id='form']/div[@class='%s']",
AppModule.FORM_GROUP_WRAPPER_CSS_CLASS_VALUE)
+        final String divCssLocator = formGroupLocator + "/@class"
+        final String labelCssLocator = formGroupLocator + "/label/@class"
+        final String inputCssLocator = formGroupLocator + String.format("/%s[@class='%s']/input/@class",
+            AppModule.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME_VALUE, 
+            AppModule.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS_VALUE)
+        
+        open("/beaneditorwithoverridencssclassesdemo")
+        
+        assertEquals(AppModule.FORM_GROUP_WRAPPER_CSS_CLASS_VALUE, getAttribute(divCssLocator))
+        assertEquals(AppModule.FORM_GROUP_LABEL_CSS_CLASS_VALUE, getAttribute(labelCssLocator))
+        assertEquals(AppModule.FORM_FIELD_CSS_CLASS_VALUE, getAttribute(inputCssLocator))
+        
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
index fd89b34..3dd1e69 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
@@ -17,12 +17,15 @@ package org.apache.tapestry5.integration.app1;
 import org.apache.tapestry5.corelib.components.BeanEditForm;
 import org.apache.tapestry5.corelib.components.BeanEditor;
 import org.apache.tapestry5.integration.app1.data.RegistrationData;
+import org.apache.tapestry5.test.TapestryTestConfiguration;
 import org.testng.annotations.Test;
 
 /**
  * Tests for the {@link BeanEditor} component, often embedded inside
  * a {@link BeanEditForm} component.
  */
+@TapestryTestConfiguration(webAppFolder = "src/test/app1", browserStartCommand = "*googlechrome")
+@Test
 public class BeanEditorTests extends App1TestCase
 {
     /**
@@ -219,4 +222,21 @@ public class BeanEditorTests extends App1TestCase
 
         assertTextPresent("Name: abcdef", "Age: 10");
     }
+    
+    /** TAP5-2182 */
+    public void bean_editor_default_markup() {
+
+        final String formGroupLocator = "//form[@id='form']/div[@class='form-group'][2]";
+        final String wrapperCssLocator = formGroupLocator + "/@class";
+        final String labelCssLocator = formGroupLocator + "/label/@class";
+        final String inputCssLocator = formGroupLocator + "/input/@class";
+        
+        openLinks("BeanEditor Demo");
+        
+        assertEquals("form-group", getAttribute(wrapperCssLocator));
+        assertEquals("control-label", getAttribute(labelCssLocator));
+        assertEquals("form-control", getAttribute(inputCssLocator));
+        
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/BeanEditorWithOverridenCssClassesDemo.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/BeanEditorWithOverridenCssClassesDemo.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/BeanEditorWithOverridenCssClassesDemo.java
new file mode 100644
index 0000000..f1f23f5
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/BeanEditorWithOverridenCssClassesDemo.java
@@ -0,0 +1,60 @@
+// Copyright 2013 Thiago H. de Paula Figueiredo
+//
+// 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.
+// Copyright 2013 Thiago H. de Paula Figueiredo
+//
+// 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.integration.app3.pages;
+
+/**
+ * @author Thiago H. de Paula Figueiredo (http://machina.com.br/thiago)
+ *
+ */
+public class BeanEditorWithOverridenCssClassesDemo
+{
+    
+    private String string;
+    
+    private int integer;
+
+    public String getString()
+    {
+        return string;
+    }
+
+    public void setString(String string)
+    {
+        this.string = string;
+    }
+
+    public int getInteger()
+    {
+        return integer;
+    }
+
+    public void setInteger(int integer)
+    {
+        this.integer = integer;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d91c20a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
index a675bef..2f4a73d 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
@@ -28,6 +28,16 @@ import org.apache.tapestry5.services.security.WhitelistAnalyzer;
 
 public class AppModule
 {
+    public static final String FORM_GROUP_LABEL_CSS_CLASS_VALUE = "control-label col-sm-2";
+    
+    public static final String FORM_GROUP_WRAPPER_CSS_CLASS_VALUE = "something form-group";
+    
+    public static final String FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME_VALUE = "div";
+    
+    public static final String FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS_VALUE = "col-sm-10";
+    
+    public static final String FORM_FIELD_CSS_CLASS_VALUE = "form-control control-form";
+
     public static void contributeBeanBlockOverrideSource(Configuration<Object> configuration)
     {
         configuration.add(new DisplayBlockContribution("boolean", "PropertyDisplayBlockOverrides",
"boolean"));
@@ -40,6 +50,13 @@ public class AppModule
         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
 
         configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "jquery");
+        
+        configuration.add(SymbolConstants.FORM_GROUP_LABEL_CSS_CLASS, FORM_GROUP_LABEL_CSS_CLASS_VALUE);
+        configuration.add(SymbolConstants.FORM_GROUP_WRAPPER_CSS_CLASS, FORM_GROUP_WRAPPER_CSS_CLASS_VALUE);
+        configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME, FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME_VALUE);
+        configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS,
FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS_VALUE);
+        configuration.add(SymbolConstants.FORM_FIELD_CSS_CLASS, FORM_FIELD_CSS_CLASS_VALUE);
+        
     }
 
     @Contribute(Compatibility.class)


Mime
View raw message