Spring AutoPopulatingList max size?

java, spring, spring-mvc

Solution

Ok, so I dug a little more into Spring's internals and found that by default, 256 is the limit.

The limit is given by the BeanWrapperImpl#autoGrowCollectionLimit attribute. Spring's WebDataBinder default configuration sets this to 256.

The proper way to raise this limit is to define a @InitBinder annotated method in your controller :

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.setAutoGrowCollectionLimit(1024);
}

and then everything works as expected.

I did not try to find a way to modify this limit globally.

HTH

Problem

I have a problem with the Spring AutoPopulatingList. My use case is the following : manage the list of users that can access an application. On the GUI side, I use an autocomplete field to search and add users to a table on the right. Users can also be removed from the table. When the GUI user submits, the GUI dynamically builds a form with fields for the users : selectedUsers[1], ..., selectedUsers[N]. My problem is that the AutoPopulatingList in my "backing" bean seems to grow only to 256 items, and then stops. So I get the following error : [myapp.web.controller.admin.form.ApplicationForm]: Invalid list index in property path 'selectedUsers[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256 Do you know if there is the actual limit ? If it is, is there a way to raise it ? If not, can you think of a workaround for this problem ? Thanks in advance for your help

Original source