GWT 2.4 为客户端带来了服务继承(issue 6234,issue 6035)。
我一直在等待这个未来很长时间,因为它在客户端上节省了很多重复的代码。我已经开始实施它,但结果喜忧参半。
这是我的代码:
public interface BaseEntityRequest<T>
{
Request<Void> put(T entity);
Request<List<T>> getAllOrderBy(String propertyName);
Request<List<T>> getRangeAndFilter(int limit,int offset, QueryInfoProxy queryInfo);
}
@Service(value = EgdDao.class, locator = DaoServiceLocator.class)
public interface EgdRequest extends RequestContext, BaseEntityRequest<EgdProxy>
{
Request<Void> exportToExcel(QueryInfoProxy queryInfo, String userName);
}
到目前为止getAllOrderBy
,getRangeAndFilter
工作正常,但put(T entity)
没有。
我在控制台中收到以下错误:
[ERROR] Unexpected error
java.util.NoSuchElementException
这会在接收器 onFailure ServerFailure 消息中返回:
Error 500 INTERNAL_SERVER_ERROR
HTTP ERROR 500
Problem accessing /gwtRequest. Reason:
INTERNAL_SERVER_ERROR
put
我可以看到,当其他方法不起作用时,唯一的原因是它使用了泛型参数 T。当我put
在接口中移动方法EgdRequest
(使用EgdProxy
作为参数而不是 T)时,它开始工作,所以我知道我的服务器代码很好。
有人知道如何正确实施吗?
谢谢!