Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I speed up Spring's form:options tag?

I'm using Spring 5.0.6.RELEASE. I'm trying to render SELECT menus for country and state on my page, so I have

<form:select path="countries[${vs.index}]" cssClass="country">
    <form:option value="" label="Select Country" />
    <form:options items="${countryList}" itemValue="id" itemLabel="name" /> 
</form:select> 

<form:select path="states[${vs.index}]" cssClass="state">
    <form:option value="" label="Select State" />
    <form:options items="${stateList[vs.index]}" itemValue="id" itemLabel="name" />
</form:select>

There are about 239 country options and 50 state options, but yet the above two functions take about 11 seconds to render. This is ridiculously slow, especially considering that data never changes. Is there a way to speed this up or somehow get my application to cache these fragments? I'm using Wildfly 11.0.0.Final and Java 8.

like image 261
Dave Avatar asked Dec 05 '18 22:12

Dave


1 Answers

Maybe it isn't what you are looking for, but why go to server for static list of countries (/states)?

You can easily write or use components for displaying such drop down in Javascript vanila or framework that will reduce network latency and also load.

Sending those list over network for every client every page loading seems awfully redundant and expansive.

like image 156
user7294900 Avatar answered Oct 10 '22 03:10

user7294900