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 2024/01/07 10:37:22 UTC
(struts) branch fix/WW-5365-radio-value created (now 55ca7a5b3)
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a change to branch fix/WW-5365-radio-value
in repository https://gitbox.apache.org/repos/asf/struts.git
at 55ca7a5b3 WW-5365 Reverts changes introduced in WW-5192 to allow evaluate the value attribute
This branch includes the following new commits:
new 55ca7a5b3 WW-5365 Reverts changes introduced in WW-5192 to allow evaluate the value attribute
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(struts) 01/01: WW-5365 Reverts changes introduced in WW-5192 to allow evaluate the value attribute
Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch fix/WW-5365-radio-value
in repository https://gitbox.apache.org/repos/asf/struts.git
commit 55ca7a5b345b00898f43e7dd5af61ea9268beba0
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sun Jan 7 11:37:10 2024 +0100
WW-5365 Reverts changes introduced in WW-5192 to allow evaluate the value attribute
---
.../java/org/apache/struts2/components/Radio.java | 8 -----
.../test/java/org/apache/struts2/TestAction.java | 9 ++++++
.../org/apache/struts2/views/jsp/ui/RadioTest.java | 37 ++++++++++++++++++++--
.../org/apache/struts2/views/jsp/ui/Radio-11.txt | 4 +++
4 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/core/src/main/java/org/apache/struts2/components/Radio.java b/core/src/main/java/org/apache/struts2/components/Radio.java
index 7ef81000a..5c59e70ec 100644
--- a/core/src/main/java/org/apache/struts2/components/Radio.java
+++ b/core/src/main/java/org/apache/struts2/components/Radio.java
@@ -66,10 +66,6 @@ public class Radio extends ListUIBean {
return TEMPLATE;
}
- public void evaluateExtraParams() {
- super.evaluateExtraParams();
- }
-
/**
* Radio tag requires lazy evaluation as list of tags is dynamically generated using <s:iterator/>
*
@@ -80,8 +76,4 @@ public class Radio extends ListUIBean {
return true;
}
- protected Class<?> getValueClassType() {
- return String.class;
- }
-
}
diff --git a/core/src/test/java/org/apache/struts2/TestAction.java b/core/src/test/java/org/apache/struts2/TestAction.java
index 5543b4462..77f784a61 100644
--- a/core/src/test/java/org/apache/struts2/TestAction.java
+++ b/core/src/test/java/org/apache/struts2/TestAction.java
@@ -53,6 +53,7 @@ public class TestAction extends ActionSupport {
private Long id;
private List<SomeEnum> enumList;
private List<Integer> intList;
+ private Boolean someBool;
private final Map<String, String> texts = new HashMap<>();
@@ -254,4 +255,12 @@ public class TestAction extends ActionSupport {
public void setIntList(List<Integer> intList) {
this.intList = intList;
}
+
+ public Boolean getSomeBool() {
+ return someBool;
+ }
+
+ public void setSomeBool(Boolean someBool) {
+ this.someBool = someBool;
+ }
}
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java
index 72e4cbf06..47a5caad7 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/RadioTest.java
@@ -64,6 +64,37 @@ public class RadioTest extends AbstractUITagTest {
strutsBodyTagsAreReflectionEqual(tag, freshTag));
}
+ public void testMapWithBooleanAsKeyWithoutForceValue() throws Exception {
+ TestAction testAction = (TestAction) action;
+
+ Map<Boolean, String> map = new LinkedHashMap<>();
+ map.put(Boolean.TRUE, "male");
+ map.put(Boolean.FALSE, "female");
+ testAction.setMap(map);
+
+ testAction.setSomeBool(false);
+
+ RadioTag tag = new RadioTag();
+ tag.setPageContext(pageContext);
+ tag.setLabel("mylabel");
+ tag.setName("myname");
+ tag.setValue("someBool");
+ tag.setList("map");
+ tag.setTheme("simple");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(RadioTag.class.getResource("Radio-11.txt"));
+
+ // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
+ RadioTag freshTag = new RadioTag();
+ freshTag.setPageContext(pageContext);
+ assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
+ "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
+ strutsBodyTagsAreReflectionEqual(tag, freshTag));
+ }
+
public void testMapWithBooleanAsKey_clearTagStateSet() throws Exception {
TestAction testAction = (TestAction) action;
@@ -165,12 +196,13 @@ public class RadioTest extends AbstractUITagTest {
List<SomeEnum> enumList = new ArrayList<>(Arrays.asList(SomeEnum.values()));
testAction.setEnumList(enumList);
+ testAction.setStatus(SomeEnum.INIT);
RadioTag tag = new RadioTag();
tag.setTheme("simple");
tag.setPageContext(pageContext);
tag.setName("status");
- tag.setValue("INIT");
+ tag.setValue("status");
tag.setList("enumList");
tag.doStartTag();
@@ -191,13 +223,14 @@ public class RadioTest extends AbstractUITagTest {
List<SomeEnum> enumList = new ArrayList<>(Arrays.asList(SomeEnum.values()));
testAction.setEnumList(enumList);
+ testAction.setStatus(SomeEnum.INIT);
RadioTag tag = new RadioTag();
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
tag.setTheme("simple");
tag.setPageContext(pageContext);
tag.setName("status");
- tag.setValue("INIT");
+ tag.setValue("status");
tag.setList("enumList");
tag.doStartTag();
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-11.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-11.txt
new file mode 100644
index 000000000..8f591387b
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Radio-11.txt
@@ -0,0 +1,4 @@
+<input type="radio" name="myname" id="mynametrue" value="true"/>
+<label for="mynametrue">male</label>
+<input type="radio" name="myname" id="mynamefalse" checked="checked" value="false"/>
+<label for="mynamefalse">female</label>