GWT 2.4.0 RequestFactory polymorphism
Asked Answered
C

1

5

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?

Cheston answered 2/10, 2011 at 9:55 Comment(0)
C
10

Fixed it with @ExtraTypes:

@Service(ArticleBase.class)
@ExtraTypes({MyChild1Proxy.class, MyChild2Proxy.class})
public interface MyBaseRequest extends RequestContext {
    Request<MyBaseProxy> getStuff(); // MyChild1 here
}
Cheston answered 2/10, 2011 at 10:3 Comment(1)
thank you, saved me a lot of time - was getting weird stack overflow exceptions. Expected to put the extra types annotation on the base proxy class (this caused the stack overflow exceptions)...Dogtooth

© 2022 - 2024 — McMap. All rights reserved.