• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Performance for Select field

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a page that fills a select field with certain xpaths from a List contained in a session object. In extreme cases the List contains around 15,000 xpath entries. This causes the page to load very slowly and takes nearly 4-5 mins. This is a huge bottleneck.

I've attached a sample JSP that simulates this behaviour. Is there any alternative way to approach this problem. i have heard of AJAX but since the data is present on the client side itself,i'm not sure it's applicable





<HTML>

<%@ page language="java" import="java.util.*"%>
<%List selectList=new ArrayList();

for(int i=0;i<15000;i++){
selectList.add(i,"/root/a["+i+"]");

}

%>

<script language="javascript">

function init(){

var mycars="<%=selectList.toString()%>";
var arr=mycars.split(",");
var a=arr[0];
arr[0]=a.substring(1,a.length);
var c=arr[arr.length-1];
arr[arr.length-1]=c.substring(0,c.length-1);

<%
for(int i = 0; i < selectList.size(); i++) {
%>
var opt = document.createElement('option');
var val ='<%=selectList.get(i)%>';
var text = '<%=selectList.get(i)%>';
lstidentificationfield = document.passiveConfig.xmlIdentificationField;
opt.value = val;
opt.text = text;
lstidentificationfield.options.add(opt);
<%
}

%>

}
</script>


<BODY onXoad="init()">

<form name="passiveConfig">
<select name="xmlIdentificationField" id="xmlIdentificationField" size="1" style='width:500px'>
<option value="0">Select XML Field</option>
</select>
</form>
</BODY>
</HTML>
[ December 22, 2006: Message edited by: gov kur ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a page that fills a select field with certain xpaths from a List contained in a session object. In extreme cases the List contains around 15,000 xpath entries.



'select' element does not look like the right approach to display 15000 entries, irrespective of how long it takes to load that 'select' list. Why would you want to display so many entries on the UI at any given time?
[ December 22, 2006: Message edited by: Jaikiran Pai ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ALL I can say is "I PITY THE FOOL" who would have to use a poorly designed web application.

There has to be a better way to limit the number of selections in that element. From use combo boxes to using autocomplete to using paging techniques.

You will not get good performance with script or with your users.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Information overload" is the usability term for the problem you have introduced. When confronted with so much data and so many choices, users are confused and befuddled. So even if the poerformance of the beast was acceptable, your app would have severe usability concerns.

As Eric pointed out, there are many concepts and patterns to address the problem.
 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok guys ...thanks for the input. Although i know it sounds like a poorly designed web app... its not .
Like Bear Bibeault said it's posibly a case of 'Information overload'. However this happens only if the end user (developer/tester) is in stress testing mode of his product and knowingly performs some extreme steps on this tool. Another thing is that these entries are insignificant in the overall execution and the user may choose to ignore it or simply use one or more of the entries but the assumption is that he would certainly expect to see those entries.
As far as the alternate techniques go i'm not quite sure what autocomplete is (not worked extensively on javascript) but using the paging technique would give the entries a importance in the configuration they don't deserve.
In that sense select seems appropriate for this functionality.

I have found a simpler solution for my problem. It's to use the scriptlet for loop at the select statement rather than at the javscript function. The speed in much more acceptable. thanks
[ December 22, 2006: Message edited by: gov kur ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by gov kur:
Although i know it sounds like a poorly designed web app... its not
...
I have found a simpler solution for my problem. It's to use the scriptlet for loop at the select statement rather than at the javscript function. The speed in much more acceptable. thanks :thumb:



You just contradicted yourself. any web app that uses scriplets these days is poorly designed. At the very least, use JSTL (c:forEach) rather than scriptlets.
 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok..thanks for that ....though i agree with you it would be hard to change it now since max of the jsps already have scriptlets in them ...and i am certainly not the guy to take that decision.

anyways i just wanted to share an alternate way in javascript to achieve the same.it makes use of a DIV tag.


var str="<SELECT ID='selUpdate'>";
for (var i=0; i<1000; i++)
{
str += "<OPTION>Item " + i + "</OPTION>";
}
str += "</SELECT>";
divUpdate.innerHTML = str;

This is the link::
http://msdn.microsoft.com/workshop/author/perf/dhtmlperf.asp#Expand_Your_Options_in_a_SELECT_Element


thanks
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic