I am having a performance problem. I am trying to build a page that
allows the user to select from a fairly large list of objects (up to
20,000). We have filtering capabilities to trim the list so the user
doesn't have to scroll through all of them. It's a reasonable UI.
Unfortunately, I only get decent performance on Safari. IE6 is
exceptionally miserable. It's okay when the list has 100 items, but
it crashes as we exceed 300. So I've been experimenting, and I
haven't found a way around it.
So I created a sample app. All I did was populate an
ArrayList<String> with 20,000 fairly short strings that I read out of
the HTML file. Under Safari 4 on a G5 Mac Pro, this is almost
instant. Under IE6 on a similar age Windows box, it's taking 4
minutes. Firefox on the G5 runs out of memory.
Is it possible to store large amounts of data in my GWT applications?
Or do I have to store fairly small amounts of data and go back and
forth to the server a lot? If it's the latter, I may as well just go
back to what we used to do (WebObjects).
I'm including my little sample program. Maybe there's something
obvious that I can do?
-Joe
--- GWTMinimum.java ---
package com.missionmode.gwtminimum.client;
import java.util.*;
import com.google.gwt.core.client.*;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GWTMinimum implements EntryPoint {
public FlexTable panel;
public Button loadBtn;
public Button displayBtn;
public ListBox listBox;
public Label label;
public ArrayList<String> usernames = new ArrayList<String>();
public String[] parts;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
panel = new FlexTable();
RootPanel.get("web2").add(panel);
loadBtn = new Button("Click to start load");
panel.setWidget(0, 0, loadBtn);
loadBtn.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
loadUsers();
}
});
}
/**
* We've loaded the user table. Set up so they
* can press another button to display the data.
*/
public void setupForDisplay() {
displayBtn = new Button("Click to Display");
panel.setWidget(0, 1, displayBtn);
displayBtn.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
showUsers();
}
});
}
/**
* Load the users from the HTML page.
*/
public void loadUsers() {
if (parts == null) {
String str = stringFromDocument("users");
parts = str.split("===");
loadBtn.setText("Click me again");
}
else {
for (String name : parts) {
name = name.trim();
if (name.length() > 0) {
usernames.add(name);
}
}
showCount();
setupForDisplay();
}
}
/**
* Just show how many users were actually loaded.
*/
public void showCount() {
label = new Label("Total user count: " + usernames.size());
panel.setWidget(1, 0, label);
}
/**
* Show the loaded users.
*/
public void showUsers() {
try {
listBox = new ListBox();
listBox.setVisibleItemCount(20);
panel.setWidget(2, 0, listBox);
for (String str : usernames) {
listBox.addItem(str);
}
}
catch (Exception e) {
panel.setText(3, 0, "Error: " + e.getMessage());
}
}
/**
* Return a string from the document.
*/
public String stringFromDocument(String elementName) {
String retVal = "";
Element params = DOM.getElementById(elementName);
if (params != null) {
retVal = DOM.getInnerText(params);
}
return retVal;
}
}
--- Foo.html ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>GWTMinimum</title>
<script type="text/javascript" language="javascript"
src="com.missionmode.gwtminimum.GWTMinimum.nocache.js"></script>
</head>
<body>
<div id="web2"></div>
<p id="users" style="display: none;">
User 0===
User 1===
User 2===
Repeat more users as desired===
</p>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---