Thank you! Yeah, that's ugly, but that's great :) On Feb 10, 10:20 pm, Y2i <yur...@gmail.com> wrote: > It's ugly but it works. If you have a better workaround please share. > > The idea is instead of querying for List<ContactProxy> you query for > List<ContactWrapperProxy>. > Then you call ContactWrapper.getPersonContact(). If it returns non-null > value then it's a person. > Otherwise you call ContactWrapper.getCompanyContact() and repeat the check. > > Server: > > class ContactWrapper { > private PersonContact personContact; > private CompanyContact companyContact; > > // returns null if not a PersonContact > public PersonContact getPersonContact() { return personContact; } > public void setPersonContact(PersonContact personContact) { > this.personContact = personContact; } > // returns null if not a CompanyContact > public CompanyContact getCompanyContact() { return companyContact; } > public void setCompanyContact(CompanyContact companyContact) { > this.companyContact = companyContact; } > > } > > class SomeService { > public static List<ContactWrapper> queryContracts() { > final List<Contact> contacts = // polymorphic JPA query > final List<ContactWrapper> ret = new > ArrayList<ContactWrapper>(contacts.size()); > for(Contact c : contacts) { > final ContactWrapper w = new ContactWrapper(); > if(contact intanceof CompanyContact) { > w.setCompanyContact((CompanyContact)c) > } > else if(contact intanceof PersonContact) { > w.setPersonContact((PersonContact)c) > } > ret.add(w); > } > return ret; > } > > } > > Client: > @ProxyFor(ContactWrapper.class) > interface ContactWrapperProxy extends ValueProxy ( > PersonContactProxy getPersonContact(); > CompanyContact getCompanyContact(); > > } > > @Service(SomeService.class) > interface SomeServiceRequest exntends RequestContext { > // return List<ContactWrapperProxy> instead of List<ContactProxy> > List<ContactWrapperProxy> queryContracts(); > > }
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.