开发者

GWT 2.4.0 RequestFactory polymorphism

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 somewher开发者_运维百科e. Everything works fine when I use concrete types, but it doesn't work if I use the base ones.

What do you think?


Fixed it with @ExtraTypes:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜