Grid GXT 3可以';t填充网格
我想从网格中的远程服务器加载数据。以下代码:Grid GXT 3可以';t填充网格,grid,gxt,Grid,Gxt,我想从网格中的远程服务器加载数据。以下代码: final RepServiceAsync service = GWT.create(RepService.class); final RepProperties props = GWT.create(RepProperties.class); RpcProxy<PagingLoadConfig, PagingLoadResult<ReportsList>> proxy =
final RepServiceAsync service = GWT.create(RepService.class);
final RepProperties props = GWT.create(RepProperties.class);
RpcProxy<PagingLoadConfig, PagingLoadResult<ReportsList>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<ReportsList>>() {
@SuppressWarnings("unchecked")
@Override
public void load(PagingLoadConfig loadConfig, AsyncCallback callback) {
service.getReports(callback);
}
};
ListStore<ReportsList> store = new ListStore<ReportsList>(props.key());
final PagingLoader<PagingLoadConfig, PagingLoadResult<ReportsList>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<ReportsList>>(
proxy);
loader.setRemoteSort(true);
loader.addLoadHandler(new LoadResultListStoreBinding<PagingLoadConfig, ReportsList, PagingLoadResult<ReportsList>>(
store));
final PagingToolBar toolBar = new PagingToolBar(50);
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
toolBar.bind(loader);
ColumnConfig<ReportsList, String> nameCol = new ColumnConfig<ReportsList, String>(
props.name(), 150, "Name");
ColumnConfig<ReportsList, String> pathCol = new ColumnConfig<ReportsList, String>(
props.path_name(), 150, "Path");
List<ColumnConfig<ReportsList, ?>> l = new ArrayList<ColumnConfig<ReportsList, ?>>();
l.add(nameCol);
l.add(pathCol);
ColumnModel<ReportsList> cm = new ColumnModel<ReportsList>(l);
Grid<ReportsList> grid = new Grid<ReportsList>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
loader.load();
}
});
}
};
grid.getView().setForceFit(true);
grid.setLoadMask(true);
grid.setLoader(loader);
GWT Servlet Impl:
public class RepServiceImpl extends RemoteServiceServlet implements RepService {
private static final long serialVersionUID = 1L;
@EJB
private ReportEjb repManager;
@Override
public List<Report> getReports() {
List<Report> reports = null;
reports = repManager.getReports();
return reports ;
}
}
公共类RepServiceImpl扩展RemoteServiceServlet实现RepService{
私有静态最终长serialVersionUID=1L;
@EJB
私人报告经理;
@凌驾
公共列表getReports(){
列表报告=空;
reports=repManager.getReports();
返回报告;
}
}
执行代码时不会出错,执行对数据库的查询(EJB调用),但不填充网格。
在什么情况下会出现问题?根据我的经验,这通常意味着在尝试将数据放入网格本身时会出现异常。尝试将LoadExceptionHandler附加到您的加载器,看看它能给您带来什么 e、 g
public类DebugLoadHandler实现LoadExceptionHandler{
@凌驾
公共void onLoadException(LoadExceptionEvent事件){
报警(“加载异常”+事件.getException().getMessage());
}
}
public class ReportsList implements Serializable {
private static final long serialVersionUID = 1L;
int id;
String name;
String path_name;
public ReportsList() {
}
public ReportsList(int id, String name, String path_name) {
super();
this.id = id;
this.name = name;
this.path_name = path_name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath_name() {
return path_name;
}
public void setPath_name(String path_name) {
this.path_name = path_name;
}
}
public class RepServiceImpl extends RemoteServiceServlet implements RepService {
private static final long serialVersionUID = 1L;
@EJB
private ReportEjb repManager;
@Override
public List<Report> getReports() {
List<Report> reports = null;
reports = repManager.getReports();
return reports ;
}
}
public class DebugLoadHandler implements LoadExceptioniHandler<ListLoadConfig> {
@Override
public void onLoadException(LoadExceptionEvent<ListLoadConfig> event) {
Window.alert("Load Exception" + event.getException().getMessage());
}
}