Silent Warrior
Silent Warrior

Reputation: 5285

GWT Requestfactory coarse grained wrapper object

Currently in my application we are using GWT RequestFactory. We have multiple EntityProxy. Couple of finder method returns List from service layer. Since we are using pagination in our application we are returning pre-configured number of EntityProxy in List. We requires total number of EntityProxy also for showing in pagination UI for which we are making separate request. We want to create some wrapper object which encapsulates List and totalRecord count in single class. So in single request we can get both List and record count. What is best to do this using requestfactory ? Note : I am beginner in GWT RequestFactory.

Upvotes: 1

Views: 77

Answers (2)

Zied Hamdi
Zied Hamdi

Reputation: 2662

The answer of Umit is quite correct. I would only add a layer that abstracts the pagination handling. This comes useful when you have your BasicTables and BasicLists to address all data through the same interface PageProxy (eg. for pagination)

public interface PaginationInfo extends ValueProxy {
    public int getTotalRecords();
    //either have the manual page info
    public int getPageNumber();
    //or use the count API on GAE (returned by your db request as a web safe String)
    public String getCount();
}

public interface PageProxy extends ValueProxy {
    public PaginationInfo getPageInfo();
}

public interface MyEntityProxy extends EntityProxy  {}

public interface MyEntityPageProxy extends PageProxy {
    public List<MyEntityProxy> getEntities();
}

Upvotes: 2

&#220;mit
&#220;mit

Reputation: 17499

Well you can use something along this lines:

public interface MyEntityProxy extends EntityProxy  {}

public interface MyEntityPageProxy extends ValueProxy {
    public List<MyEntityProxy> getEntities();
    public int getTotalRecords();
}

It would be better to use a generic PageProxy interface (i.e. MyEntityPageProxy<T extends EntityProxy>) however because of this bug it's not possible or at least only through a workaround.

So for each EntityProxy you want to have Paginationsupport you have to create a separate PageProxy interface.

Upvotes: 1

Related Questions