GWT 2.4.0 RequestFactory多态性 [英] GWT 2.4.0 RequestFactory polymorphism

查看:146
本文介绍了GWT 2.4.0 RequestFactory多态性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GWT 2.4是否支持这种情况:

Does GWT 2.4 support this case:

@Entity class MyBase {...}
@Entity class MyChild1 extends MyBase {...}
@Entity class MyChild2 extends MyBase {...}
...
@ProxyFor(MyBase.class) class MyBaseProxy extends EntityProxy {...}
@ProxyFor(MyChild1.class) class MyChild1Proxy extends MyBaseProxy {...}
@ProxyFor(MyChild2.class) class MyChild2Proxy extends MyBaseProxy {...}
...
@Service(ArticleBase.class)
public interface MyBaseRequest extends RequestContext {
    Request<MyBaseProxy> getStuff(); // MyChild1 here
}
...
Request<MyBaseProxy> getStuffRequest = request.getStuff();
getStuffRequest.fire(new Receiver<MyBaseProxy>() {
    @Override
    public void onSuccess(MyBaseProxy proxy) {
        button.setText(((MyChild1Proxy)proxy).getQwerty()); // HERE!
    }
});

问题是,我不能使它工作。它要么不支持,要么我需要在某处添加一些魔法注释。当我使用具体类型时,一切正常,但如果我使用基础类型,它就不起作用。

The problem is, I can't make it work. It's either not supported yet or I need to add some magic annotation somewhere. Everything works fine when I use concrete types, but it doesn't work if I use the base ones.

你怎么看?

推荐答案

修正了 @ExtraTypes

@Service(ArticleBase.class)
@ExtraTypes({MyChild1Proxy.class, MyChild2Proxy.class})
public interface MyBaseRequest extends RequestContext {
    Request<MyBaseProxy> getStuff(); // MyChild1 here
}

这篇关于GWT 2.4.0 RequestFactory多态性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆