2011-10-02 35 views
5

Liệu GWT 2.4 hỗ trợ trường hợp này:GWT 2.4.0 RequestFactory polymorphism

@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! 
    } 
}); 

?

Vấn đề là, tôi không thể làm cho nó hoạt động. Nó chưa được hỗ trợ hoặc tôi cần thêm một số chú thích ma thuật ở đâu đó. Tất cả mọi thứ hoạt động tốt khi tôi sử dụng các loại cụ thể, nhưng nó không hoạt động nếu tôi sử dụng các cơ sở.

Bạn nghĩ sao?

Trả lời

10

cố định nó với @ExtraTypes:

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

cảm ơn bạn, lưu lại cho tôi rất nhiều thời gian - đã nhận được ngoại lệ tràn ngăn xếp kỳ lạ. Dự kiến ​​sẽ đặt thêm chú thích kiểu trên lớp proxy cơ sở (điều này gây ra các ngoại lệ tràn ngăn xếp) ... –

Các vấn đề liên quan