I guess, you can't. See 
http://code.google.com/p/google-web-toolkit/issues/detail?id=6967 and 
http://code.google.com/p/google-web-toolkit/issues/detail?id=5974

For the 2 server calls you can simply (and probabily better) call two 
different service methods with two different receivers in the same request 
context, before firing it (that will end up in a single http request, if I 
remember right).

On Wednesday, November 14, 2012 9:52:07 PM UTC+1, otth2oskier wrote:
>
> 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) {
> this.data = data;
> this.count = count;
> }
>
> public List<T> getData() {
> return data;
> }
>
> public long getCount() {
> return count;
> }
> }
>
>
> @ProxyFor(value = Result.class, locator = EntityLocator.class)
> public interface ResultProxy<T extends EntityProxy> extends ValueProxy {
> List<T> getData();
>
> public long getCount();
> }
>
>
> @Service(value=UserDao.class,locator=BaseServiceLocator.class)
> @ExtraTypes({ResultProxy.class})
> public interface UserRequest extends RequestContext {
> Request<Long> count();
>
> Request<UserProxy> find(Long id);
>
> Request<ResultProxy<UserProxy>> findAll(int firstResult, int maxResults);
>
> Request<Void> persist(UserProxy instance);
>
> Request<Void> remove(UserProxy instance);
> }
>
>
> @Stateless
> public class UserDao {
>
> @PersistenceContext(unitName = "acdb")
> private EntityManager entityManager;
>
> private static Logger LOGGER = Logger.getLogger(UserDao.class.getName());
>
> public long count() {
> ...
> }
>
> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/NMCy8FBVvxoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to