2011-09-01 75 views
5

我试图创建一个ValueProxy,其中包含有关用户正在执行的搜索的一些基本信息。出于某种原因,GWT希望它成为一个EntityProxy,但我不明白为什么(对于这个类来说,它也没有任何意义,因为它是一个EntityProxy)。无法创建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); 
} 

在被发送此回服务器的活动:

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

这导致:

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) 

任何想法?由于ValueProxies在代码中的其他地方工作,它显然是我所忽略的。

回答

10

难道你的DayFilterProxy根本就没有被RequestContext引用吗?

+0

是的,我认为是这样。我只在RequestContext中引用基本的FilterProxy类型。我认为在GWT 2.4中,我们可以在请求工厂中使用多态参数? – Brad

+5

您必须添加引用它们的@ ExtraTypes注释,然后:http://code.google.com/p/google-web-toolkit/wiki/RequestFactory_2_4#Polymorphism_support –

+0

太棒了!谢谢! – Brad