On Monday, June 27, 2011 12:40:05 PM UTC+2, Ryan McFall wrote:
>
> I have two domain objects that implement the same interface on the 
> server, and a third class that contains a (heterogeneous) List of 
> those objects.  I need to be able to expose this list on the client 
> side.  The domain objects do not share a common super-class (they 
> instead delegate the common functionality to another object). 
>
> Given that all proxy interfaces are required to extend BaseProxy, I 
> cannot figure out how to write multiple proxies that will have a 
> parent interface in common.  I tried making a base interface that both 
> proxies extend, but that base interface must extend EntityProxy, and 
> the GWT compiler complains if you have an interface that extends 
> EntityProxy but does not have a ProxyFor annotation.
>

The interface need not extend EntityProxy, you can have:
interface BaseInterface { ... }
interface FooProxy extends BaseInterface, EntityProxy { }
interface BarProxy extends BaseInterface, EntityProxy { }

...but then you obviously cannot have a proxy declare a list that contain 
both FooProxy and BarProxy, as a Collection<BaseInterface> would be rejected 
because BaseInterface doesn't extend EntityProxy or ValueProxy.

BUT!

   - The hierarchy of proxy interfaces need not mimic the one of domain 
   objects on the server-side. You could have "interface BarProxy extends 
   FooProxy" for example.
   - or, because you can have more than one proxy interface for the same 
   domain object, you could annotate the base interface with a @ProxyFor for 
   one of the domain class.


I am wondering (although I suspect the answer is no) whether I can 
> have a single interface declare that it is a proxy for multiple 
> entities.  If not, other ideas for making this work are welcome.


You're right: an interface can only map to a single domain class. Moreover, 
you cannot use an interface in a @ProxyFor, as the 
RequestFactoryInterfaceValidator used by the RequestFactoryServlet will 
ultimately flag it as an error (so you unfortunately cannot use the 
interface implemented by both your domain objects).

RequestFactory does not 
(yet<http://code.google.com/p/google-web-toolkit/issues/detail?id=5367>) 
support polymorphism, so your collection can only ever contain a single 
"interface".

Not sure there's a solution to your problem besides refactoring your domain 
classes (but maybe if you share a bit more information, maybe there's a 
solution)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/FWl9h7WlrrkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to