Skip to content

Commit

Permalink
WW-4283 Extends label position of <s:form> to propagate to elements
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Mar 27, 2014
1 parent 94e20fe commit 5fb27ba
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 21 deletions.
17 changes: 11 additions & 6 deletions core/src/main/resources/template/css_xhtml/checkbox.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand All @@ -57,7 +62,7 @@ lables
</span>
</#if>

<#if parameters.labelposition?default("top") == 'top'>
<#if labelpos?default("top") == 'top'>
<div <#rt/>
<#else>
<span <#rt/>
Expand All @@ -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/>
Expand All @@ -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/>
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/resources/template/css_xhtml/controlfooter.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand All @@ -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/>
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/resources/template/css_xhtml/controlheader.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/resources/template/css_xhtml/reset.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand All @@ -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/>
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/resources/template/css_xhtml/submit-close.ftl
Original file line number Diff line number Diff line change
@@ -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/>
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/resources/template/css_xhtml/submit.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down
15 changes: 10 additions & 5 deletions core/src/main/resources/template/xhtml/checkbox.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down Expand Up @@ -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/>
Expand All @@ -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>
Expand All @@ -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/>
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/resources/template/xhtml/controlheader-core.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,88 @@ public void testFormWithActionAndExtension() throws Exception {

}

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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 5fb27ba

Please sign in to comment.