2013-10-09 70 views
1

當前在我的應用程序中,我們正在使用GWT RequestFactory。我們有多個EntityProxy。 finder方法的幾個返回服務層列表。由於我們在應用程序中使用分頁,因此我們在List中返回預配置數量的EntityProxy。我們還需要總數的EntityProxy在分頁UI中顯示,我們正在爲其分別提出請求。我們想要創建一些封裝List和totalRecord數量的封裝對象。因此,在單個請求中,我們可以同時獲得List和Record count。什麼是最好使用requestfactory來做到這一點?注意:我是GWT RequestFactory的初學者。GWT Requestfactory粗粒度包裝對象

回答

1

那麼你可以使用的東西沿着這條線:

public interface MyEntityProxy extends EntityProxy {} 

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

這將是更好地使用通用PageProxy接口(即MyEntityPageProxy<T extends EntityProxy>),然而因爲這個bug它是不可能的,或者至少只能通過一種變通方法。

因此,對於每個EntityProxy您想要Paginations支持您必須創建一個單獨的PageProxy接口。

2

Umit的答案非常正確。我只會添加一個抽象分頁處理的圖層。當您的BasicTable和BasicLists通過相同的PageProxy接口尋址所有數據時(例如用於分頁),此功能非常有用

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(); 
}