I am writing a bunch of screens using CellTable and the AsyncDataProvider along with RequestFactory calls. I would like to get away from the pattern of making a server call for data and a second call for row count to update the AsyncDataProvider's data and row count. I would like create a generic return object that contains both data and count and make only one cal to the server.
My code looks like:
public class Result<T extends EntityBase> {
private final List<T> data;
private final long count;
public Result(List<T> data, long count) {
public List<T> getData() {
@ProxyFor(value = Result.class, locator = EntityLocator.class)
public interface ResultProxy<T extends EntityProxy> extends ValueProxy {
@Service(value=UserDao.class,locator=BaseServiceLocator.class)
@ExtraTypes({ResultProxy.class})
public interface UserRequest extends RequestContext {
Request<UserProxy> find(Long id);
Request<ResultProxy<UserProxy>> findAll(int firstResult, int maxResults);
Request<Void> persist(UserProxy instance);
Request<Void> remove(UserProxy instance);
@PersistenceContext(unitName = "acdb")
private EntityManager entityManager;
private static Logger LOGGER = Logger.getLogger(UserDao.class.getName());
public User find(Long id) {
return entityManager.find(User.class, id);
public Result<User> findAll(int firstResult, int maxResults) {
public void persist(User instance) {
LOGGER.info("Persisting instance:" + instance);
entityManager.merge(instance);
LOGGER.info("Persisted instance:" + instance);
public void remove(User instance) {
@ProxyFor(value = User.class, locator = EntityLocator.class)
public interface UserProxy extends EntityProxy {
Long getId();
String getFirstName();
void setFirstName(String firstName);
String getLastName();
void setLastName(String lastName);
}
When I compile, I am getting:
ResultProxy.java:13: warning: Cannot validate this method because the domain mapping for the return type (java.util.List) could not be resolved to a domain type
UserRequest.java:19: Could not find domain method similar to com.avaya.gwtproto.shared.model.Result<T> findAll(intint)
Lines are highlighted in red above.
I cannot figure out what I am doing wrong. I am guessing that the compiler is not handling the generics as I would expect it to. I don't want to write a separate return value for each EntityProxy and I don't want to make 2 server calls to get data and count to refresh my CellTable.