Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to prevent DIV from reloading

 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three DIV tags on my page each populated with JSP.
A header DIV, detail DIV and list DIV.

The header displays a selected record name.
The detail holds detail data of the record selected.
The list is a table of a list of records.

When the page is initialy loaded the header shows a generic string.
The deatil is empty.
The list is populated and the first column contains hyperlinks of record index.

When a hyperlink is clicked the detail gets loaded using $.load.
Then the header gets loaded using $.load.

This process gets slower the more records that are in the list.

What I think is happening is when the link is clicked:
the list reloads
the detail loads
the list reloads again
the header loads
the list reloads again

How can I keep the list DIV static and not be reloaded every time something on the page changes?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are adding elements to the page, elements need to redraw. The more elements, the longer the redraw.

It could also be a memory leak in your application. Without seeing your application, we can only speculate.

Eric

 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:If you are adding elements to the page, elements need to redraw. The more elements, the longer the redraw.

It could also be a memory leak in your application. Without seeing your application, we can only speculate.

Eric



Does adding elements to one DIV tag cause the entire page to be redrawn? And does a redraw re-execute the page HTML?

Note: After everything loads I can do a list.innerHTML = ""(remove the contents of the list div) and then type in a number to lookup(simulating the list link) and the detail and header loads very fast. So it has somthing to do with the list being regenerated.

The table is being built using JSTL for each loop. Is there a better way to build this table?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not really understanding the issue.

Does adding elements to one DIV tag cause the entire page to be redrawn?
No.

And does a redraw re-execute the page HTML?
What's a "redraw"? And HTML doesn't execute in the first place.

The table is being built using JSTL for each loop. Is there a better way to build this table?
Completely moot as that happens on the server long before the page is sent to the browser. How the HTML is built is irrelevant/
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I'm not really understanding the issue.

Does adding elements to one DIV tag cause the entire page to be redrawn?
No.

And does a redraw re-execute the page HTML?
What's a "redraw"? And HTML doesn't execute in the first place.

The table is being built using JSTL for each loop. Is there a better way to build this table?
Completely moot as that happens on the server long before the page is sent to the browser. How the HTML is built is irrelevant/


Can you please look at my first post again? If there is something else I need to explain I will be more than happy to do so.
I beleive I have a relevent page for my users. It displays a lot of good data and is interactive, it's just too slow and when I take out the table portion it flies.
However, the table is necessary for navigation.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The performance of adding elements to the page really depends on how the page is structured. I deal with some large pages at my jobs and had to figure out this stuff and it was a lot of manual playing and seeing what happens.

Floats and percenages play havoc with tables.

If the table is for navigation, does it really need to be a table? Does it look like a list?

Again without seeing anything, we are just taking stabs in the dark.

Eric
 
salvin francis
Bartender
Posts: 1280
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Dyke wrote:It displays a lot of good data and is interactive, it's just too slow

Slow meaning ?
1. data takes time to come from the server
Ans: you want to optimize your server code, check out the portions that are slowing it down, main areas of optimization are
DB query optimization, code loops, etc. If all opt for a better server.

2. data takes time to process @ client
Ans: you want to optimize your javascript, do all calculations @ server instead of the client.
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
salvin francis wrote:
Steve Dyke wrote:It displays a lot of good data and is interactive, it's just too slow

Slow meaning ?
1. data takes time to come from the server
Ans: you want to optimize your server code, check out the portions that are slowing it down, main areas of optimization are
DB query optimization, code loops, etc. If all opt for a better server.

2. data takes time to process @ client
Ans: you want to optimize your javascript, do all calculations @ server instead of the client.


The data retreival takes less that 2 seconds. It is the process of populating the table using the JSTL forEach loop. There are no calculations but many conditional checks.
Here is my JSP code for the table part:

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many rows of data before it starts to get really slow? For example, if 20 rows still seems fast, but 200 rows seems slow the best thing to do is page your data so that you are only rendering 20 rows at a time, and allow the user to page to next/prev sets of data.
 
Steve Dyke
Ranch Hand
Posts: 1629
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg Bolinger wrote:How many rows of data before it starts to get really slow? For example, if 20 rows still seems fast, but 200 rows seems slow the best thing to do is page your data so that you are only rendering 20 rows at a time, and allow the user to page to next/prev sets of data.


It does seem to bog down after 20 to 25 rows. Is it difficult to set up what you suggest?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Dyke wrote:
Gregg Bolinger wrote:How many rows of data before it starts to get really slow? For example, if 20 rows still seems fast, but 200 rows seems slow the best thing to do is page your data so that you are only rendering 20 rows at a time, and allow the user to page to next/prev sets of data.


It does seem to bog down after 20 to 25 rows. Is it difficult to set up what you suggest?


If you don't know how, yes. But that's pretty much on par with anything. I'd recommend you look into some pre-made solutions. Maybe something like displayTag or jqGrid.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic