GWT 2.4.0 RequestFactory polymorphism

懵懂的女人 提交于 2020-01-22 12:44:47

问题


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.

What do you think?


回答1:


Fixed it with @ExtraTypes:

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


来源:https://stackoverflow.com/questions/7625692/gwt-2-4-0-requestfactory-polymorphism

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!