2010-05-20 7 views
2

누군가가 SmartGWT에서 페이징이 어떻게 작동하는지 설명해 주시겠습니까?SmartGWT 페이징은 어떻게 작동합니까?

나는 showcase에서 작동하는 것을 볼 수 있지만 어디서나 문서화 된 것을 찾을 수 없습니다. javadoc의 정보는 지금까지의 상황을 이해하는 데 충분하지 않습니다.

저는 ListGrid와 내 서버와 상호 작용하는 사용자 정의 DataSource를 가지고 있습니다.

ListGrid에서 페이지 크기를 25 레코드로 설정하고 싶습니다.

  • 을 ListGrid에 :

    나는 무엇을해야합니까?

  • 내 사용자 지정 DataSource에 (DSRequest 및 DSResponse 개체에 대한 액세스 권한이 있습니까?)
  • 내 서버에?

SmartGWT 클라이언트가 서버로 보내는 매개 변수는 무엇이며, 그 결과로 SmartGWT 클라이언트가 예상하는 매개 변수는 무엇입니까?

답변

4

당신이 스마트 GWT LGPL을 사용하는 경우 :

이 자세하게 설명으로 RestDataSource의 Javadoc을 읽어 보시기 바랍니다 : http://www.smartclient.com/smartgwt/showcase/#featured_restfulds

경우 : http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RestDataSource.html

는 또한 RestDataSource 샘플에서 봐 당신은 스마트 GWT EE를 사용하고 있습니다. 1) SQL 커넥터를 사용하고 있다면 서버에 쓰는 코드가 0입니다. 스마트 GWT 서버 측 코드는 데이터베이스 테이블과의 데이터 바인딩을 담당합니다. 2) 서버 데이터 바인딩에 대한 모드 제어가 필요한 경우 스크롤 (가져 오기) 할 때 자체 서버 API를 호출하거나 삽입/업데이트/삭제가 발생할 수 있습니다. 이 샘플의 출처를 살펴보십시오. http://www.smartclient.com/smartgwtee/showcase/#javabeans

소스보기 버튼을 클릭하고 SourceItemDMI 클래스의 소스를 확인하십시오. 요청의 시작 행, 끝 행 매개 변수를 확보하는 방법에 유의하십시오.

// 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; 
}