2010-05-20 46 views
2

有人可以向我解釋在SmartGWT中尋呼是如何工作的嗎?SmartGWT分頁如何工作?

我看到它在showcase中工作,但我無法在任何地方找到它。 (javadoc中的信息遠遠不足以理解正在發生的事情。)

我有一個ListGrid和一個與我的服務器交互的自定義​​DataSource。

比方說,我想在ListGrid中設置25個記錄的頁面大小。

我有什麼做的事:

  • 在ListGrid?
  • 在我的自定義數據源(有權訪問DSRequest和DSResponse對象)?
  • 在我的服務器?

SmartGWT客戶端發送給服務器的參數是什麼,SmartGWT客戶端期望的參數是什麼?

回答

4

如果你使用智能GWT LGPL:

請閱讀RestDataSource的Javadoc中,因爲它解釋對此進行了詳細:http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RestDataSource.html

也可以看看在RestDataSource樣本:http://www.smartclient.com/smartgwt/showcase/#featured_restfulds

如果你正在使用Smart GWT EE,然後 1)如果你使用的是SQL連接器,那麼你有0個代碼在服務器上寫,因爲智能GWT服務器端代碼負責連接數據庫表與數據綁定。 2)如果需要對服務器數據綁定進行模式控制,則可以在滾動(讀取)或插入/更新/刪除時調用自己的服務器API。查看此示例的源代碼:http://www.smartclient.com/smartgwtee/showcase/#javabeans

單擊查看源代碼按鈕並檢查SupplyItemDMI類的源代碼。注意如何獲取請求的開始行,結束行參數。

// By default, for a DSRequest of type "fetch", a method named "fetch" is invoked. 
// You can customize this via the <serverObject> declaration. 
public DSResponse fetch(DSRequest dsRequest) 
    throws Exception { 
    log.info("procesing DMI fetch operation"); 

    // Fetch a List of matching SupplyItem Beans from some pre-existing Java object model 
    // provided by you, represented by "SupplyItemStore" in this example 
    List matchingItems = 
     SupplyItemStore.findMatchingItems((Long) dsRequest.getFieldValue("itemID"), 
       (String) dsRequest.getFieldValue("itemName")); 

    // this implementation shows data paging (returning only ranges of requested records) 
    long startRow = dsRequest.getStartRow(); 
    long endRow = dsRequest.getEndRow(); 

    long totalRows = matchingItems.size(); 
    DSResponse dsResponse = new DSResponse(); 
    dsResponse.setTotalRows(totalRows); 
    dsResponse.setStartRow(startRow); 

    endRow = Math.min(endRow, totalRows); 
    dsResponse.setEndRow(endRow); 

    // trim the data to the requested range of records. In a real application, the startRow 
    // and endRow would be passed to the ORM layer or to SQL for maximum efficiency. 
    List results; 
    if (totalRows > 0) { 
     results = matchingItems.subList((int) dsResponse.getStartRow(), 
       (int) dsResponse.getEndRow()); 
    } else { 
     results = matchingItems; 
    } 

    // just return the List of matching beans 
    dsResponse.setData(results); 

    return dsResponse; 
}