0
我正在尝试使用GWT创建一个Web应用程序,并且它是我第一次使用此工具。我也在使用GAE数据存储。我想使用rpc调用从数据存储区将数据加载到我的Web应用程序中。我使用菜单,当用户选择某个内容时,通过rpc调用正确的方法,以便可以加载正确的数据。我使用arraylist保存数据,因为我想在我的网页中显示它们中的很多。我设法加载数组列表,但我不喜欢它在我的网页上显示的方式。我应该更改哪些内容?有没有其他方法可以做到这一点?代码如下:如何使用GWT显示从数据存储到网站的许多数据
它加载数据
List<String>places=new ArrayList<String>();
DatastoreService ds= DatastoreServiceFactory.getDatastoreService();
public List<String> display(String s){
Query q=new Query(s);
PreparedQuery pq = ds.prepare(q);
for (Entity place : pq.asIterable()) {
String result = place.getProperties().toString();
places.add(result);
}return places;
我的异步调用
public void onSuccess(Object result) {
CellList<String> cellList = new CellList<String>(new TextCell());
final ListDataProvider<String> dataProvider = new ListDataProvider<String>();
dataProvider.addDataDisplay(cellList);
final TextBox valueBox = new TextBox();
List<String> list = dataProvider.getList();
list.add(result.toString());
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(cellList);
RootPanel.get().add(vPanel);
}
因此,而不是我的代码中的此行: for(Entity place:pq.asIterable()){ String result = place.getProperties()。toString(); places.add(result); } return places; 我应该把实体放在我的数组列表中。对? –
您需要将您的Datastore实体转换为您自己Place类的对象。 –
你能用一个例子来解释一下吗?对不起,但我很新,这... –