0

我想从网格中的远程服务器加载数据。以下代码:

            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);

代表属性:

public interface RepProperties extends PropertyAccess<ReportsList> {
    @Path("id")
ModelKeyProvider<ReportsList> key();
ValueProvider<ReportsList, String> name();
ValueProvider<ReportsList, String> path_name();
}

报告列表代码:

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;
    }
}

GWT Servlet 实现:

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 ;
    }
}

代码执行没有错误,执行了对数据库的查询( EJB-call ),但未填充网格。可能是什么问题?

4

1 回答 1

0

根据我的经验,这通常意味着在尝试将数据放入网格本身时出现异常。尝试将 LoadExceptionHandler 附加到您的加载程序,看看它给了您什么

例如

public class DebugLoadHandler implements LoadExceptioniHandler<ListLoadConfig> {
  @Override
    public void onLoadException(LoadExceptionEvent<ListLoadConfig> event) {
    Window.alert("Load Exception" + event.getException().getMessage());
  }
}
于 2013-05-22T17:57:54.463 回答