无法创建ValueProxy

时间:2011-09-01 04:21:26

标签: java gwt requestfactory

我正在尝试创建一个ValueProxy,其中包含有关用户正在执行的搜索的一些基本信息。出于某种原因,GWT希望它成为一个EntityProxy,但我不明白为什么(这个类也不是真正的EntityProxy)。

// 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。

1 个答案:

答案 0 :(得分:10)

可能是RequestContext中根本没有引用你的DayFilterProxy吗?