You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/05/06 11:04:47 UTC
struts git commit: Fixes label positioning
Repository: struts
Updated Branches:
refs/heads/master 3a78fd1a1 -> 8b688cc38
Fixes label positioning
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8b688cc3
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8b688cc3
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8b688cc3
Branch: refs/heads/master
Commit: 8b688cc38d589c787c091a2c7c3574e5c3619484
Parents: 3a78fd1
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri May 6 13:04:30 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri May 6 13:04:30 2016 +0200
----------------------------------------------------------------------
.../template/xhtml/controlheader-core.ftl | 4 +-
.../struts2/views/jsp/ui/TextfieldTest.java | 56 ++++++++++++++++++++
.../struts2/views/jsp/ui/Textfield-12.txt | 11 ++++
.../struts2/views/jsp/ui/Textfield-13.txt | 11 ++++
4 files changed, 80 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/8b688cc3/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 302442d..31df869 100644
--- a/core/src/main/resources/template/xhtml/controlheader-core.ftl
+++ b/core/src/main/resources/template/xhtml/controlheader-core.ftl
@@ -62,11 +62,11 @@
class="label"<#t/>
</#if>
><#t/>
-<#if parameters.required!false && parameters.requiredPosition!"right" != 'right'>
+<#if (parameters.required!false) && ((parameters.requiredPosition!"right") != 'right')>
<span class="required">*</span><#t/>
</#if>
${parameters.label?html}<#t/>
-<#if parameters.required!false && parameters.requiredPosition!"right" == 'right'>
+<#if (parameters.required!false) && ((parameters.requiredPosition!"right") == 'right')>
<span class="required">*</span><#t/>
</#if>
${parameters.labelseparator!":"?html}<#t/>
http://git-wip-us.apache.org/repos/asf/struts/blob/8b688cc3/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
index d61aae8..d814308 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java
@@ -239,6 +239,62 @@ public class TextfieldTest extends AbstractUITagTest {
verify(TextFieldTag.class.getResource("Textfield-9.txt"));
}
+ public void testRequiredLabelPositionDefault() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ TextFieldTag tag = new TextFieldTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myId");
+ tag.setLabel("mylabel");
+ tag.setName("foo");
+ tag.setValue("bar");
+ tag.setRequiredLabel("true");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(TextFieldTag.class.getResource("Textfield-12.txt"));
+ }
+
+ public void testRequiredLabelPositionRight() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ TextFieldTag tag = new TextFieldTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myId");
+ tag.setLabel("mylabel");
+ tag.setName("foo");
+ tag.setValue("bar");
+ tag.setRequiredLabel("true");
+ tag.setRequiredPosition("right");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(TextFieldTag.class.getResource("Textfield-12.txt"));
+ }
+
+ public void testRequiredLabelPositionLeft() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ TextFieldTag tag = new TextFieldTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myId");
+ tag.setLabel("mylabel");
+ tag.setName("foo");
+ tag.setValue("bar");
+ tag.setRequiredLabel("true");
+ tag.setRequiredPosition("left");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(TextFieldTag.class.getResource("Textfield-13.txt"));
+ }
+
public void testErrorPositionBottomCssXhtmlTheme() throws Exception {
TestAction testAction = (TestAction) action;
testAction.setFoo("bar");
http://git-wip-us.apache.org/repos/asf/struts/blob/8b688cc3/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-12.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-12.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-12.txt
new file mode 100644
index 0000000..9a3155d
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-12.txt
@@ -0,0 +1,11 @@
+<tr>
+ <td class="tdLabel">
+ <label for="myId" class="label">
+ mylabel
+ <span class="required">*</span>:
+ </label>
+ </td>
+ <td>
+ <input type="text" name="foo" value="bar" id="myId"/>
+ </td>
+</tr>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/8b688cc3/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-13.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-13.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-13.txt
new file mode 100644
index 0000000..e5e6e92
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-13.txt
@@ -0,0 +1,11 @@
+<tr>
+ <td class="tdLabel">
+ <label for="myId" class="label">
+ <span class="required">*</span>
+ mylabel:
+ </label>
+ </td>
+ <td>
+ <input type="text" name="foo" value="bar" id="myId"/>
+ </td>
+</tr>
\ No newline at end of file