1.) Profile your web-app. What does take so long (serialization or rendering)? use Chrome Dev Tools to do that.
2.) Use paging. From a UX point of view it doesn't make sense to show all rows at once.
3.) Transfer chunks of data (using AsyncDataProvider) because as of point 2 the user doesn't need to see all rows at once.
On Monday, July 1, 2013 7:58:02 PM UTC+2, sebastie...@isen-lille.fr wrote:
Hi everybody,I'm creating a website with GWT. I want to add CellTable into my project. The problem is that I have a lot of data to put into the tables. So, my website freeze and show my table after 2-3 minutes.I find on internet that multi-threads are impossible with GWT. So, what is the solution? Even if the user have to wait 2-3 minutes, I want to avoid the fact that it's freezing.Any Ideas?Thank you.My code, maybe I can optimize it simply?public void refreshTable(final ArrayList<String> arrListFilters, final ArrayList<String> arrListAll, String url) {// Get the CQ resultRequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try {Request response = builder.sendRequest(null, new RequestCallback() {public void onError(Request request, Throwable exception) {}public void onResponseReceived(Request request, Response response) {final json json = JsonUtils.unsafeEval(response.getText()); int i = 0;int j = 0;int tot;// If there are too many resultsif (json.getResultslength() > 10000) {tot = 10000;} else {tot = json.getResultslength();}// Fill the list of rowswhile (j < tot) {i = 1;List<String> rowTemp = new ArrayList<String>();rowTemp.add(json.getDate(j));// Get the data to get a price result for a specific// customer queryarrListLnNb.add(json.getLineNb(j)); arrListId.add(json.getId(j));arrListCqid.add(json.getCqid(j)); while (i < arrListFilters.size()) {rowTemp.add(json.getResults(j, arrListAll.indexOf(arrListFilters.get(i)))); i = i + 1;}rowTemp.add("");rows.add(rowTemp);j = j + 1;}// Provide rows to the tabletable.setRowCount(rows.size(), true);table.setRowData(0, rows);final ListDataProvider<List<String>> provider = new ListDataProvider<List<String>>(rows); provider.addDataDisplay(table); // Handler to sort the columnsList<List<String>> list1 = provider.getList();ListHandler<List<String>> columnSortHandler = new ListHandler<List<String>>(list1); i = 0;while (i < table.getColumnCount()) {final int columnIndex = i;columnSortHandler.setComparator(table.getColumn( i), new Comparator<List<String>>() { public int compare(List<String> o1, List<String> o2) {if (o1 == o2) {return 0;}// Compare the name columns.if (o1 != null) {return (o2 != null) ? o1.get(columnIndex).compareTo(o2.get(columnIndex)) : 1; }return -1;}});i = i + 1;}table.addColumnSortHandler(columnSortHandler); i = 0;while (i < table.getColumnCount()) {table.getColumnSortList().push(table.getColumn(i)); i = i + 1;}}});} catch (RequestException e) {}}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment