2011-09-01 9 views
5

Sto tentando di creare uno ValueProxy che contiene alcune informazioni di base su una ricerca eseguita da un utente. Per qualche motivo GWT vuole che sia un EntityProxy ma non vedo perché (né ha senso che questa classe sia un EntityProxy).Impossibile creare ValueProxy

// FilterProxy extends ValueProxy 
@ProxyFor(DayFilter.class) 
public interface DayFilterProxy extends FilterProxy { 

    void setFilterValue(Date day); 
    Date getFilterValue(); 
} 

public class DayFilter extends Filter { 

    public DayFilter() { 
     setOperator(FilterOperator.GREATER_THAN_OR_EQUAL); 
     setField("dateRequested"); 
    } 

    public void setFilterValue(Date date) { 
     this.value = date; 
    } 

    public Date getFilterValue() { 
     return value; 
    } 
} 

public interface PaginationRequest<T> extends RequestContext { 

    Request<List<T>> paginate(int offset, int limit, String sortColumn, 
      boolean isSortAscending, List<FilterProxy> filters); 

    Request<Integer> count(List<FilterProxy> filters); 
} 

@Service(value=TripService.class, locator=SchedgyServiceLocator.class) 
public interface TripRequest extends PaginationRequest<TripProxy> { 

    Request<TripProxy> save(TripProxy trip); 
} 

All'interno l'attività che sta inviando questo ritorno al server:

// Request is a TripRequest 
DayFilterProxy filter = request.create(DayFilterProxy.class); 

Questo si traduce in:

java.lang.AssertionError: com.schedgy.trip.dao.filter.trip.proxy.DayFilterProxy is not an EntityProxy type 
    at com.google.web.bindery.requestfactory.shared.impl.IdFactory.asEntityProxy(IdFactory.java:66) 
    at com.google.web.bindery.requestfactory.shared.impl.IdFactory.createId(IdFactory.java:229) 
    at com.google.web.bindery.requestfactory.shared.impl.IdFactory.allocateId(IdFactory.java:41) 
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.create(AbstractRequestContext.java:478) 
    at com.schedgy.trip.client.activity.TripsActivity.getFilters(TripsActivity.java:56) 

Tutte le idee? Dev'essere qualcosa di ovvio che sto solo sottovalutando il fatto che ho ValueProxies che lavora altrove nel codice.

risposta

10

È possibile che DayFilterProxy non faccia alcun riferimento a RequestContext?

+0

Sì, penso che sia il caso. Sto solo facendo riferimento al tipo FilterProxy di base nel RequestContext. Pensavo che con GWT 2.4 avremmo potuto utilizzare parametri polimorfici nella factory richiesta? – Brad

+5

Devi aggiungere un'annotazione di '@ ExtraTypes' che li rimanda a: http://code.google.com/p/google-web-toolkit/wiki/RequestFactory_2_4#Polymorphism_support –

+0

Impressionante! Grazie! – Brad