File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to prevent DIV from reloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to prevent DIV from reloading" Watch "How to prevent DIV from reloading" New topic
Author

How to prevent DIV from reloading

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Nov 16, 2004
Posts: 1490
    
    1
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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/


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

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.

My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
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

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.


GenRocket - Experts at Building Test Data
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
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

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to prevent DIV from reloading