GWT 2.4 中客户端上的 RequestFactory 服务继承
GWT 2.4 在客户端引入了服务继承(问题 6234、问题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实体)
不行。
我在控制台中收到以下错误:
[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。当我在 EgdRequest
接口中移动 put
方法时(使用 EgdProxy
作为参数而不是 T),它开始工作,所以我知道我的服务器代码是 美好的。
有人知道如何正确实施吗?
谢谢!
GWT 2.4 brings service inheritance on the client (issue 6234, issue 6035).
I've been waiting for this future for a long time, as it saves a lot of duplicated code on the client. I've started implementing it, but so for with mixed success.
This is my code:
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);
}
So far getAllOrderBy
and getRangeAndFilter
work fine, but put(T entity)
does not.
I get the following error in the console:
[ERROR] Unexpected error
java.util.NoSuchElementException
and this gets returned in the receiver onFailure ServerFailure message:
Error 500 INTERNAL_SERVER_ERROR
HTTP ERROR 500
Problem accessing /gwtRequest. Reason:
INTERNAL_SERVER_ERROR
The only cause, that I can see, for the put
method not to work, when the others do, is that it uses the generic parameter T. When I move the put
method in the EgdRequest
interface (using EgdProxy
as a parameter instead of T) it starts to work, so I know my server code is fine.
Does anybody have any idea how to implement this correctly?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个 GWT 错误。请参阅 http://code.google.com/p/ google-web-toolkit/issues/detail?id=6794
It's a GWT bug. See http://code.google.com/p/google-web-toolkit/issues/detail?id=6794