Struts losing parameters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Struts losing parameters

allanjackson
We’re having a problem where struts (2.5.10.1) is losing parameters that were passed to an action from a form. Our form is submitting values for a list of checkboxes like this:

selected[0]: true
selected[1]: true
selected[2]: false
selected[3]: true
...
selected[499]: false
selected[500]: true

This corresponds to a variable in our action that looks like:
private List<Boolean> selected;
//getter() and setter() here.

The issue we’re having is that when we get into our action code, the “selected” list only ever has the first 256 items that we submitted. I manually pulled the list of parameters out of the ActionContext, and they were all there, so I think the problem is probably happening in the Params Interceptor.

I tried changing our List<> variable to an Array[5000], and then it populated everything correctly. So my best guess is that the interceptor is initializing a list with a size of 256, but then it doesn’t expand the size correctly once the initial list has filled up.

This same code was working fine a year or so ago, but I’m not sure when it stopped working or what version of struts we were on at the time.

Thanks for your help,
Allan Jackson
University of Kansas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Struts losing parameters

Lukasz Lenart
There is a hardcode limit to grow a collection but it looks like it
wasn't documented - feel free to open a ticket in JIRA.

https://github.com/apache/struts/blob/master/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java#L50
https://issues.apache.org/jira/browse/WW-4620

Define the following constant in struts.xml to increase the limit
<constant name="xwork.autoGrowCollectionLimit" value="1234"/>


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/


2017-04-13 15:55 GMT+02:00 Jackson, Allan <[hidden email]>:

> We’re having a problem where struts (2.5.10.1) is losing parameters that were passed to an action from a form. Our form is submitting values for a list of checkboxes like this:
>
> selected[0]: true
> selected[1]: true
> selected[2]: false
> selected[3]: true
> ...
> selected[499]: false
> selected[500]: true
>
> This corresponds to a variable in our action that looks like:
> private List<Boolean> selected;
> //getter() and setter() here.
>
> The issue we’re having is that when we get into our action code, the “selected” list only ever has the first 256 items that we submitted. I manually pulled the list of parameters out of the ActionContext, and they were all there, so I think the problem is probably happening in the Params Interceptor.
>
> I tried changing our List<> variable to an Array[5000], and then it populated everything correctly. So my best guess is that the interceptor is initializing a list with a size of 256, but then it doesn’t expand the size correctly once the initial list has filled up.
>
> This same code was working fine a year or so ago, but I’m not sure when it stopped working or what version of struts we were on at the time.
>
> Thanks for your help,
> Allan Jackson
> University of Kansas

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...