user2654788
user2654788

Reputation: 293

How to use <s:select> tag to multiselect with thousands of options in Struts 2?

I have the following multi-select block in JSP inside a <s:form> tag. When I submit the form, the action method works ok.

<s:select
  id="prodSelect"
  list="#application.actionForm.vtrProduct"
  name="repSearchProdVO.product"
  multiple="true"
  emptyOption="false"
  headerKey="-1"
  theme="simple"
  style="
    font-size: 14px;
    color: #000069;
    font-family: 'Arial, Helvetica, sans-serif';
    height: 20px;
    width: 240px;
  "
  value="#session.repSearchVO.product"
/>

However, the repSearchProdVO.product can only handle 890 options. I have more than 3000 options that need to be selected. When I choose 2000 options, it still returns 890 options.

Upvotes: 0

Views: 200

Answers (2)

user2654788
user2654788

Reputation: 293

I forgot to mention that the server is Tomcat 9.0.75. The maxParameterCount for the port 8080 in server.xml has a default value of 1000. I changed it to 10000 and everything worked as expected. This may help someone.

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           maxParameterCount="10000"
           /> 

Upvotes: 1

Roman C
Roman C

Reputation: 1

In Struts 2 there's no way to use <s:select> for a large datasets. Because it renders a simple HTML <select> which is limited by display size options. If you set more options they just be hidden behind od your display dimensions. If you need to choose multiple options in a large datasets then you can use a request with a query of the results.

For example <sj:autocompleter> can help you to query lage datasets by making remote https requests used by the searching term.

It has an multiselect attribute

Creates a multiple select. The tag will pre-select multiple values if the values are passed as an Array or a Collection(of appropriate types) via the value attribute. If one of the keys equals one of the values in the Collection or Array it will be selected.

You can find the example of the autocompleter widget in this answer.

Upvotes: 1

Related Questions