struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [12/31] git commit: WW-4283 Extends label position of <s:form> to propagate to elements
Date Sun, 06 Apr 2014 19:14:14 GMT
WW-4283 Extends label position of <s:form> to propagate to elements


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

Branch: refs/heads/feature/use-js-to-support-multiple-buttons
Commit: 5fb27ba7e75f501725ab65b96a31b2d3be98ce88
Parents: 94e20fe
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Thu Mar 27 18:41:52 2014 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Thu Mar 27 18:41:52 2014 +0100

----------------------------------------------------------------------
 .../resources/template/css_xhtml/checkbox.ftl   | 17 ++--
 .../template/css_xhtml/controlfooter.ftl        |  7 +-
 .../template/css_xhtml/controlheader-core.ftl   |  9 ++-
 .../template/css_xhtml/controlheader.ftl        |  7 +-
 .../main/resources/template/css_xhtml/reset.ftl |  9 ++-
 .../template/css_xhtml/submit-close.ftl         |  7 +-
 .../resources/template/css_xhtml/submit.ftl     |  7 +-
 .../main/resources/template/xhtml/checkbox.ftl  | 15 ++--
 .../template/xhtml/controlheader-core.ftl       |  9 ++-
 .../struts2/views/jsp/ui/FormTagTest.java       | 82 ++++++++++++++++++++
 .../apache/struts2/views/jsp/ui/Formtag-27.txt  | 10 +++
 .../apache/struts2/views/jsp/ui/Formtag-28.txt  | 10 +++
 12 files changed, 168 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/checkbox.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/checkbox.ftl b/core/src/main/resources/template/css_xhtml/checkbox.ftl
index a7ffc43..004f674 100644
--- a/core/src/main/resources/template/css_xhtml/checkbox.ftl
+++ b/core/src/main/resources/template/css_xhtml/checkbox.ftl
@@ -41,7 +41,12 @@ lables
 </#list>
 </div><#t/>
 </#if>
-<#if parameters.labelposition?default("") == 'left'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("") == 'left'>
 <span <#rt/>
 <#if parameters.id??>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl">
 <label<#t/>
@@ -57,7 +62,7 @@ lables
 </span>
 </#if>
 
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>
@@ -69,14 +74,14 @@ lables
 </#if>
 
 <#include "/${parameters.templateDir}/simple/checkbox.ftl" />
-<#if parameters.labelposition?default("") != 'left'>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("") != 'left'>
+<#if labelpos?default("top") == 'top'>
 </div> <#rt/>
 <#else>
 </span>  <#rt/>
 </#if>
 <#if parameters.label??>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>
@@ -95,7 +100,7 @@ lables
 </#if>
 </#if>
 <#if parameters.label??>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 </div> <#rt/>
 <#else>
 </span> <#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/controlfooter.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/controlfooter.ftl b/core/src/main/resources/template/css_xhtml/controlfooter.ftl
index 2f4c662..2783a0b 100644
--- a/core/src/main/resources/template/css_xhtml/controlfooter.ftl
+++ b/core/src/main/resources/template/css_xhtml/controlfooter.ftl
@@ -22,7 +22,12 @@
 -->
 ${parameters.after?if_exists}<#t/>
     <#lt/>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("top") == 'top'>
 </div> <#rt/>
 <#else>
 </span> <#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/controlheader-core.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/controlheader-core.ftl b/core/src/main/resources/template/css_xhtml/controlheader-core.ftl
index 902cda5..2a5c98b 100644
--- a/core/src/main/resources/template/css_xhtml/controlheader-core.ftl
+++ b/core/src/main/resources/template/css_xhtml/controlheader-core.ftl
@@ -43,8 +43,13 @@
 </#if>
 </#if>
 
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
 <#if parameters.label??>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>
@@ -66,7 +71,7 @@
         ${parameters.label?html}${parameters.labelseparator!":"?html}
 <#include "/${parameters.templateDir}/xhtml/tooltip.ftl" />
 	</label><#t/>
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 </div> <br /><#rt/>
 <#else>
 </span> <#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/controlheader.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/controlheader.ftl b/core/src/main/resources/template/css_xhtml/controlheader.ftl
index 4099c7a..9e47377 100644
--- a/core/src/main/resources/template/css_xhtml/controlheader.ftl
+++ b/core/src/main/resources/template/css_xhtml/controlheader.ftl
@@ -21,7 +21,12 @@
  */
 -->
 <#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader-core.ftl">
-<#if parameters.labelposition?default("top") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/reset.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/reset.ftl b/core/src/main/resources/template/css_xhtml/reset.ftl
index 790bcfc..6d7734f 100644
--- a/core/src/main/resources/template/css_xhtml/reset.ftl
+++ b/core/src/main/resources/template/css_xhtml/reset.ftl
@@ -20,7 +20,12 @@
  * under the License.
  */
 -->
-<#if parameters.labelposition?default("top") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>
@@ -33,7 +38,7 @@
 </#if>
 ><#t/>
 <#include "/${parameters.templateDir}/simple/reset.ftl" />
-<#if parameters.labelposition?default("top") == 'top'>
+<#if labelpos?default("top") == 'top'>
 </div> <#t/>
 <#else>
 </span> <#t/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/submit-close.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/submit-close.ftl b/core/src/main/resources/template/css_xhtml/submit-close.ftl
index 423c5d7..15c608a 100644
--- a/core/src/main/resources/template/css_xhtml/submit-close.ftl
+++ b/core/src/main/resources/template/css_xhtml/submit-close.ftl
@@ -1,5 +1,10 @@
 <#include "/${parameters.templateDir}/simple/submit-close.ftl" />
-<#if parameters.labelposition?default("top") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("top") == 'top'>
 </div> <#t/>
 <#else>
 </span> <#t/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/css_xhtml/submit.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/css_xhtml/submit.ftl b/core/src/main/resources/template/css_xhtml/submit.ftl
index 68b2a9c..ffb4df9 100644
--- a/core/src/main/resources/template/css_xhtml/submit.ftl
+++ b/core/src/main/resources/template/css_xhtml/submit.ftl
@@ -20,7 +20,12 @@
  * under the License.
  */
 -->
-<#if parameters.labelposition?default("top") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("top") == 'top'>
 <div <#rt/>
 <#else>
 <span <#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/xhtml/checkbox.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/xhtml/checkbox.ftl b/core/src/main/resources/template/xhtml/checkbox.ftl
index 878c632..4504b3f 100644
--- a/core/src/main/resources/template/xhtml/checkbox.ftl
+++ b/core/src/main/resources/template/xhtml/checkbox.ftl
@@ -34,7 +34,12 @@
 </tr>
 </#list>
 </#if>
-<#if parameters.labelposition?default("") == 'top'>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
+<#if labelpos?default("") == 'top'>
 <tr>
     <td colspan="2">
 <#if parameters.label??> <label<#t/>
@@ -68,7 +73,7 @@ ${parameters.label?html}<#t/>
 <#else>
 <tr>
 	<td valign="top" align="right">
-<#if parameters.labelposition?default("") == 'left'>
+<#if labelpos?default("") == 'left'>
 <#if parameters.label??> <label<#t/>
 <#if parameters.id??>
  for="${parameters.id?html}"<#rt/>
@@ -93,7 +98,7 @@ ${parameters.label?html}<#t/>
 </label><#t/>
 </#if>
 </#if>
-<#if parameters.labelposition?default("") == 'right'>
+<#if labelpos?default("") == 'right'>
     <#if parameters.required?default(false)>
         <span class="required">*</span><#t/>
     </#if>
@@ -104,10 +109,10 @@ ${parameters.label?html}<#t/>
     </td>
     <td valign="top" align="left">
 
-<#if parameters.labelposition?default("") != 'top'>
+<#if labelpos?default("") != 'top'>
                 	<#include "/${parameters.templateDir}/simple/checkbox.ftl" />
 </#if>                    
-<#if parameters.labelposition?default("") != 'top' && parameters.labelposition?default("")
!= 'left'>
+<#if labelpos?default("") != 'top' && labelpos?default("") != 'left'>
 <#if parameters.label??> <label<#t/>
 <#if parameters.id??>
  for="${parameters.id?html}"<#rt/>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/main/resources/template/xhtml/controlheader-core.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/xhtml/controlheader-core.ftl b/core/src/main/resources/template/xhtml/controlheader-core.ftl
index f909c89..7330270 100644
--- a/core/src/main/resources/template/xhtml/controlheader-core.ftl
+++ b/core/src/main/resources/template/xhtml/controlheader-core.ftl
@@ -36,12 +36,17 @@
 </#list>
 </#if>
 </#if>
+<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
+<#assign labelpos = parameters.form.labelposition/>
+<#elseif parameters.labelposition??>
+<#assign labelpos = parameters.labelposition/>
+</#if>
 <#--
 	if the label position is top,
 	then give the label it's own row in the table
 -->
 <tr>
-<#if parameters.labelposition?default("") == 'top'>
+<#if labelpos?default("") == 'top'>
     <td align="left" valign="top" colspan="2"><#rt/>
 <#else>
     <td class="tdLabel"><#rt/>
@@ -70,7 +75,7 @@ ${parameters.labelseparator?default(":")?html}<#t/>
 </#if>
     </td><#lt/>
 <#-- add the extra row -->
-<#if parameters.labelposition?default("") == 'top'>
+<#if labelpos?default("") == 'top'>
 </tr>
 <tr>
 </#if>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
index 77fac5d..c9427d1 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
@@ -622,6 +622,88 @@ public class FormTagTest extends AbstractUITagTest {
 
     }
 
+    public void testFormWithTopLabelPosition() throws Exception {
+        FormTag form = new FormTag();
+        form.setTheme("xhtml");
+        form.setAction("testAction");
+        form.setPageContext(pageContext);
+        form.setIncludeContext(false);
+        form.setLabelposition("top");
+
+        TextFieldTag text = new TextFieldTag();
+        text.setPageContext(pageContext);
+        text.setLabel("label");
+
+        form.doStartTag();
+        text.doStartTag();
+        text.doEndTag();
+        form.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-27.txt"));
+    }
+
+    public void testFormWithTopLabelPositionWithElementOverride() throws Exception {
+        FormTag form = new FormTag();
+        form.setTheme("xhtml");
+        form.setAction("testAction");
+        form.setPageContext(pageContext);
+        form.setIncludeContext(false);
+        form.setLabelposition("left");
+
+        TextFieldTag text = new TextFieldTag();
+        text.setPageContext(pageContext);
+        text.setLabel("label");
+        text.setLabelposition("top");
+
+        form.doStartTag();
+        text.doStartTag();
+        text.doEndTag();
+        form.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-27.txt"));
+    }
+    
+    public void testFormWithTopLabelPositionCssXhtml() throws Exception {
+        FormTag form = new FormTag();
+        form.setTheme("css_xhtml");
+        form.setAction("testAction");
+        form.setPageContext(pageContext);
+        form.setIncludeContext(false);
+        form.setLabelposition("top");
+
+        TextFieldTag text = new TextFieldTag();
+        text.setPageContext(pageContext);
+        text.setLabel("label");
+
+        form.doStartTag();
+        text.doStartTag();
+        text.doEndTag();
+        form.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-28.txt"));
+    }
+
+    public void testFormWithTopLabelPositionWithElementOverrideCssXhtml() throws Exception
{
+        FormTag form = new FormTag();
+        form.setTheme("css_xhtml");
+        form.setAction("testAction");
+        form.setPageContext(pageContext);
+        form.setIncludeContext(false);
+        form.setLabelposition("left");
+
+        TextFieldTag text = new TextFieldTag();
+        text.setPageContext(pageContext);
+        text.setLabel("label");
+        text.setLabelposition("top");
+
+        form.doStartTag();
+        text.doStartTag();
+        text.doEndTag();
+        form.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-28.txt"));
+    }
+    
     @Override
     protected void setUp() throws Exception {
         super.setUp();

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-27.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-27.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-27.txt
new file mode 100644
index 0000000..fab8cf3
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-27.txt
@@ -0,0 +1,10 @@
+<form id="testAction" name="testAction" action="/testAction.action" method="post">
+<table class="wwFormTable">
+    <tr>
+        <td align="left" valign="top" colspan="2"><label class="label">label:</label></td>
+    </tr>
+    <tr>
+        <td><input type="text" name=""/></td>
+    </tr>
+</table>
+</form>

http://git-wip-us.apache.org/repos/asf/struts/blob/5fb27ba7/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-28.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-28.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-28.txt
new file mode 100644
index 0000000..70f3e06
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-28.txt
@@ -0,0 +1,10 @@
+<form id="testAction" name="testAction" action="/testAction.action" method="post">
+<div class="wwgrp">
+    <div class="wwlbl">
+        <label class="label">label:</label>
+    </div><br />
+    <div class="wwctrl">
+        <input type="text" name=""/>
+    </div>
+</div>
+</form>


Mime
View raw message