简体   繁体   English

GWT从服务器向客户端发送大量数据的最佳实践

[英]GWT Best practice to send huge amount of data from server to client

Which are the Best practices to send huge amount of data from server to client in GWT? 哪些是在GWT中从服务器向客户端发送大量数据的最佳实践?

Right now we are facing performance issue in GWT 2.3.0. 目前我们正面临GWT 2.3.0中的性能问题。

Our server side is sending huge xml (Size in MB/GB) to client side, our client side parses that xml and using parsed data, list of beans are formed for populating data in Celltable grid. 我们的服务器端向客户端发送巨大的xml(大小以MB / GB为单位),我们的客户端解析xml并使用解析的数据,形成bean列表以在Celltable网格中填充数据。

We are filling 1k + / 10k+ records in CellTable grid. 我们在CellTable网格中填写1k + / 10k +记录。

Is there any effective way/ Best practices followed while dealing with such a huge data? 在处理如此庞大的数据时,是否有任何有效的方法/最佳实践? If we parse the data at server side and formed the beans at server side, Is this good? 如果我们在服务器端解析数据并在服务器端形成bean,这是好的吗? or any alternative way.. 或任何替代方式..

Any help or guidance in this matter would be appreciated. 任何有关此事的帮助或指导将不胜感激。

Basically you only request as much data (and a little more) than is currently viewed by the user, not the whole data set. 基本上,您只需要比用户当前查看的数据(和更多)请求,而不是整个数据集。

See Adding Paging Controls for further details. 有关详细信息,请参阅添加分页控件

Two practices when dealing with large data for your case: 处理案例的大数据时的两种做法:

1) Use JSON instead of xml, that way the client doesn't need to parse the data but can directly use the data. 1)使用JSON而不是xml,这样客户端不需要解析数据,但可以直接使用数据。 In GWT via the GWT-JSNI interface you can write data objects accessing these JavaScript objects, see: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html . 在GWT中,您可以通过GWT-JSNI接口编写访问这些JavaScript对象的数据对象,请参阅: http//code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html With a JSON REST library you can generate the JSON on the server instead of sending xml to the client. 使用JSON REST库,您可以在服务器上生成JSON,而不是将xml发送到客户端。 But you can also use GWT-RPC on both client/server, which makes programming easier because the whole data conversion to and from JSON is handled by GWT, but adds some type information to the objects send. 但是你也可以在客户端/服务器上使用GWT-RPC,这使得编程更容易,因为往返于JSON的整个数据转换由GWT处理,但是向对象发送添加了一些类型信息。

2) Use paging: only get data that is visible to the user and cache it in the client. 2)使用分页:仅获取用户可见的数据并将其缓存在客户端中。 If you have a table presentation it's not likely the user needs all the data at once. 如果您有表格演示文稿,则用户不一定需要所有数据。 GWT cell panels have support out of the box (see the link Oliver mentions about Adding Paging Controls) GWT单元面板支持开箱即用(请参阅Oliver提到的关于添加分页控件的链接)

As in the other answers, return only the data that can usefully be used by the user and lazily fetch other data when the user requests it (or Predictive Fetch ). 与其他答案一样,只返回用户可以使用的数据,并在用户请求时(或Predictive Fetch )懒惰地获取其他数据。

See AsyncDataProvider section here: http://code.google.com/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#data-provider 请参阅此处的AsyncDataProvider部分: http//code.google.com/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#data-provider

  1. Use paging. 使用分页。 GWT cell widgets support paging out-of-the-box. GWT单元小部件支持开箱即用的分页。 So implement server side paging so that each time you click 'next' a server call is made. 因此,实现服务器端分页,以便每次单击“下一步”进行服务器调用。 That way, the client only deals with say 10 or 20 records at a time. 这样,客户端一次只处理10或20条记录。

  2. Use Javascript Overlay types as the display beans. 使用Javascript Overlay类型作为显示bean。 And to populate these beans, use JSON as the transport model instead of XML. 要填充这些bean,请使用JSON作为传输模型而不是XML。 If you use XML (ie Async calls), then GWT does some JAXB marshalling/unmarshalling logic in the back end. 如果使用XML(即异步调用),则GWT会在后端执行一些JAXB编组/解组逻辑。 If you use JSON, much of that is avoided. 如果使用JSON,则可以避免大部分内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM