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在代碼中的其他地方工作,它顯然是我所忽略的。
是的,我認爲是這樣。我只在RequestContext中引用基本的FilterProxy類型。我認爲在GWT 2.4中,我們可以在請求工廠中使用多態參數? – Brad
您必須添加引用它們的@ ExtraTypes註釋,然後:http://code.google.com/p/google-web-toolkit/wiki/RequestFactory_2_4#Polymorphism_support –
太棒了!謝謝! – Brad