struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4909) List of Boolean is not populated in Action class
Date Tue, 16 Jan 2018 07:20:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326831#comment-16326831
] 

ASF GitHub Bot commented on WW-4909:
------------------------------------

yasserzamani closed pull request #202: WW-4909: Renames a constant and adds a test
URL: https://github.com/apache/struts/pull/202
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
index cb406b79b..242d09772 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
@@ -28,6 +28,7 @@
 import ognl.ListPropertyAccessor;
 import ognl.OgnlException;
 import ognl.PropertyAccessor;
+import org.apache.struts2.StrutsConstants;
 
 import java.util.Collection;
 import java.util.List;
@@ -49,12 +50,18 @@
     private ObjectTypeDeterminer objectTypeDeterminer;
     private OgnlUtil ognlUtil;
     private int autoGrowCollectionLimit = 255;
-    
+
+    @Deprecated()
     @Inject(value = "xwork.autoGrowCollectionLimit", required = false)
-	public void setAutoGrowCollectionLimit(String value) {
-		this.autoGrowCollectionLimit = Integer.valueOf(value);
-	}
+    public void setDeprecatedAutoGrowCollectionLimit(String value) {
+        this.autoGrowCollectionLimit = Integer.valueOf(value);
+    }
     
+    @Inject(value = StrutsConstants.STRUTS_OGNL_AUTO_GROWTH_COLLECTION_LIMIT, required =
false)
+    public void setAutoGrowCollectionLimit(String value) {
+        this.autoGrowCollectionLimit = Integer.parseInt(value);
+    }
+
     @Inject("java.util.Collection")
     public void setXWorkCollectionPropertyAccessor(PropertyAccessor acc) {
         this._sAcc = (XWorkCollectionPropertyAccessor) acc;
diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index 6ee09ffb6..d01e15088 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -328,4 +328,6 @@
     public static final String STRUTS_LOCALIZED_TEXT_PROVIDER = "struts.localizedTextProvider";
 
     public static final String STRUTS_DISALLOW_PROXY_MEMBER_ACCESS = "struts.disallowProxyMemberAccess";
+
+    public static final String STRUTS_OGNL_AUTO_GROWTH_COLLECTION_LIMIT = "struts.ognl.autoGrowthCollectionLimit";
 }
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
b/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
index 38a5838ea..542efda77 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
@@ -22,6 +22,8 @@
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ListHolder;
 import com.opensymphony.xwork2.util.ValueStack;
+import ognl.ListPropertyAccessor;
+import ognl.PropertyAccessor;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -61,4 +63,43 @@ public void testCanAccessListSizeProperty() {
         assertEquals(new Integer(myList.size()), vs.findValue("strings.size()"));
         assertEquals(new Integer(myList.size()), vs.findValue("strings.size"));
     }
+
+    public void testAutoGrowthCollectionLimit() {
+        PropertyAccessor accessor = container.getInstance(PropertyAccessor.class, ArrayList.class.getName());
+        ((XWorkListPropertyAccessor) accessor).setAutoGrowCollectionLimit("2");
+
+        List<String> myList = new ArrayList<>();
+        ListHolder listHolder = new ListHolder();
+        listHolder.setStrings(myList);
+
+        ValueStack vs = ActionContext.getContext().getValueStack();
+        vs.push(listHolder);
+
+        vs.setValue("strings[0]", "a");
+        vs.setValue("strings[1]", "b");
+        vs.setValue("strings[2]", "c");
+        vs.setValue("strings[3]", "d");
+
+        assertEquals(3, vs.findValue("strings.size()"));
+    }
+
+    public void testDeprecatedAutoGrowCollectionLimit() {
+        PropertyAccessor accessor = container.getInstance(PropertyAccessor.class, ArrayList.class.getName());
+        ((XWorkListPropertyAccessor) accessor).setDeprecatedAutoGrowCollectionLimit("2");
+
+        List<String> myList = new ArrayList<>();
+        ListHolder listHolder = new ListHolder();
+        listHolder.setStrings(myList);
+
+        ValueStack vs = ActionContext.getContext().getValueStack();
+        vs.push(listHolder);
+
+        vs.setValue("strings[0]", "a");
+        vs.setValue("strings[1]", "b");
+        vs.setValue("strings[2]", "c");
+        vs.setValue("strings[3]", "d");
+
+        assertEquals(3, vs.findValue("strings.size()"));
+    }
+
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> List of Boolean is not populated in Action class
> ------------------------------------------------
>
>                 Key: WW-4909
>                 URL: https://issues.apache.org/jira/browse/WW-4909
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.5.10.1
>            Reporter: Bouagal
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 2.5.15
>
>
> In my application, a user sends a request with this parameter : selectedLines[xx]=true
where xx is a number. Stuts 2 should convert this parameter into this property : List<Boolean>
selectedLines in my action class. The lenght of the list equals xx+1 and the list looks like
this [null,null,.....,true];
> Since I have upgraded Struts 2 to 2.5.10.1 From 2.3, that not works anymore if xx>256.
The list is empty.
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message