2

SmartGWT でページングがどのように機能するかを誰かに説明してもらえますか?

ショーケースで動作しているように見えますが、どこにも文書化されていません。(javadocs の情報は、何が起こっているのかを理解するのに十分ではありません。)

ListGrid と、サーバーとやり取りするカスタム DataSource があります。

ListGrid で 25 レコードのページ サイズを設定するとします。

私は何をしなければなりませんか:

  • リストグリッドで?
  • 私のカスタム DataSource (DSRequest および DSResponse オブジェクトにアクセスできます) で?
  • 私のサーバーで?

SmartGWT クライアントからサーバーに送信されるパラメーターは何ですか?また、SmartGWT クライアントが返すパラメーターは何ですか?

4

1 に答える 1

4

Smart 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コネクタを使用している場合、Smart GWTサーバー側のコードがデータベーステーブルとのデータバインディングの配線を処理するため、サーバーに書き込むコードは0になります。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;  
}
于 2010-05-21T09:53:16.163 に答える