0

Javascript : unresponsive script?

asked 2008-12-02 07:14:01 +0800

umanga gravatar image umanga
180 3

Greetings,
I am retrieving about 50K data in my application.So I implemented my listbox with the load-on-demand method explained at http://www.zkoss.org/smalltalks/loadondemand/

So now ,thers is only 100 records loaded into the listmodel (per page).But I am getting the js warning:

"Warning: unresponsive script
A script on this page maybe busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete."

Is theres anyway to remedy this situation?

thanks in advance.

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2008-12-02 07:50:16 +0800

umanga gravatar image umanga
180 3

Seems relate to the performance of the Browser.This gave the warnning on the IceWeasel 2.0 on Debian Etch (P-4 HT , 2Gb ram).
Worked well with the Firefox browser on Pentium Xeon(4Gbs ram) :)

So ,cant assume all have Xeons ?

Is there anyway to get rid of this warning mesasge?

Thanks in advance.

link publish delete flag offensive edit

answered 2008-12-02 16:04:31 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

could you provide the code shows how you render the list box (the list item,column)

link publish delete flag offensive edit

answered 2008-12-03 00:56:50 +0800

umanga gravatar image umanga
180 3

hi dennis,
Following is the function which invoked when user click on Paging button . (onPaging event).
If you see the code I have lots of Popup windows linked with so many cells.When I remove the popup windows ,the responce time was quite good.But I need the popups.. :) anyway heres the code , i have commented ** where i thought be important.Hope it understandable.

private void changePage(int startIndex, int recordSize) {

    markChanges(); //this method stores currently selected rows

    resultListbox.getItems().clear();	//clear the listbox	
    int endIndex = startIndex + recordSize;
    if (endIndex >= allResults.size())
	endIndex = allResults.size();
    if (endIndex < 0)
	endIndex = 0;

    //create the sublist for the page
    List<Sequence> pageList = allResults.subList(startIndex, endIndex);
 
    pageResults = pageList;
		
   //add  rows(list items)
   //**
   for (Sequence seq : pageList) {
	Listitem litem = new Listitem();
	litem.setValue(seq);
	litem.setSelected(seq.isSelected());

	// Add result rows
         int ind=0;
		for (String val : seq.getValues()) {
			boolean isSequence=false;
			Column col=colList.get(ind);
				
			String linkout=col.getLinkout();
			String linkmask=col.getLinkmask();
			
			if(sequenceCols.contains(new Integer(ind))){
				isSequence=true;
			}
                //**
		Listcell acell = new Listcell();
				
			Label lbl=new Label();

	   		  if (val.length() > 23) {					
					//**
					Popup popup = new Popup();										
					popup.setHeight("100px");
					Vbox vbox = new Vbox();
					Html html=new Html();
					if(isSequence){
					   String s=Common.generateColoredProtienHTML(val);
						html.setContent(s.toUpperCase());
					}
					else{
					  html.setContent("<span style='color:black;>"+val+"<span>");	
					}
					vbox.appendChild(html);
					popup.appendChild(vbox);					
					popup.setParent(getParent().getParent().getParent());						

					
					val = val.substring(0, 23) + "...";					
					
					acell.setContext(popup);				

				}
				
				//**add some Html code to cell
				if(isSequence){
					val=Common.generateColoredProtienHTML(val);
					Html html=new Html();
					html.setContent(val.toUpperCase());
										
					acell.appendChild(html);
				}else if(linkout!=null && (val!=null && !val.equals("") )){															
					String urlVal=new String(val);
					if (linkmask!=null && linkmask.equals("xxxx")){						
						urlVal=urlVal.substring(0,4);
					}
					
					String url=LinkoutUtils.processURL(linkout, urlVal);					
					String ss="<i><a style='font-size:10px' href='"+url+"' target='_blank'>"+val+"</a></i>";
					Html html=new Html();
					html.setContent(ss);					
					acell.appendChild(html);
				   
				}else{					
					lbl.setValue(val);
					acell.appendChild(lbl);					
				}
				
				//add PDB JMol link
                                //**
				if(col.getDispName().equalsIgnoreCase("pdb id")){
					addPDBButton(acell,val); //add a Button to cell
				}
				
				litem.appendChild(acell);
				ind++;
			}
			resultListbox.appendChild(litem);

		}
	}

link publish delete flag offensive edit

answered 2008-12-04 07:52:47 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

SO the bad performance was caused by adding huge number of popup and the contents of popup.

have you try to defer the loading of popup's content to onOpen (when the popup open, then load the content)

another solution: just a popup in the page, and listen the right click of each cell (cause you link popup with setContext)
in right click, you create/replace the content of popup and show it.

link publish delete flag offensive edit

answered 2008-12-05 05:55:33 +0800

umanga gravatar image umanga
180 3

Hi Dennis,

Thanks alot, I tried your second method..using one Popup.It worked well.Now not 100,but I have set 200 per page.
Thank you again,

Best regards

link publish delete flag offensive edit

answered 2008-12-18 08:06:29 +0800

umanga gravatar image umanga
180 3

Greetings,

I have implemented the popup (context menu) as dennis explained above.But now my popups give this strang behaviours:
please refer the screencast http://www.screencast.com/users/umanga/playlists/mysizouka

As you can seen when the listbox is scrolled to the right , the popup doesn't display in the correct location and when keep on right clicking on it, it move toward right and finally go out of the screen ?
Is there a way to fix this ?

Thanks

link publish delete flag offensive edit

answered 2008-12-18 09:21:45 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Hi,
how do you open a popup now?
could provide piece of code ?

/Dennis

link publish delete flag offensive edit

answered 2008-12-18 09:27:48 +0800

umanga gravatar image umanga
180 3

hi dennis,

I have added a EventListner to each Cell.

* using one Popup instance ( variable - thePopup )

ListCell acell;
.
.
.

acell.addEventListener("onRightClick", new EventListener() {

				public void onEvent(Event arg0) throws Exception {
						String bal = new String(innerVal);
						String s = Common.generateColoredProtienHTML(bal);

                                                /** Clear the content of the Popup
						thePopup.getChildren().clear();
                                                /***Addd some HTML code 

                                                if (innerIsSequence) {
								Html html = new Html();
								html.setContent("<pre>"+s.toUpperCase()+"</pre>");
								thePopup.appendChild(html);
							} else {
								thePopup.appendChild(new Label(bal));	
							}
							
                                                        //** open the Popup
							thePopup.open(acell);
							

						}
					});

link publish delete flag offensive edit

answered 2008-12-18 10:08:03 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

It is a bug probably, there are to many side effects in different runtime environment , browser, customized style.

maybe this work, please give it try

thePopup.open(((MouseEvent)evt).getX(),((MouseEvent)evt).getY());

link publish delete flag offensive edit

answered 2008-12-19 01:08:33 +0800

umanga gravatar image umanga
180 3

updated 2008-12-19 02:47:49 +0800

hi dennis,
thank you for the tip.But it did not work.
Here the output looks now,popup appears on top:
http://www.screencast.com/users/umanga/folders/Default/media/a0777ea3-8b69-43d6-a22f-0cce2f97b895

best regards

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-12-02 07:14:01 +0800

Seen: 457 times

Last updated: Dec 24 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More