All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.extjs.gxt.ui.client.data.JsonPagingLoadResultReader Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Sencha GXT 2.3.0 - Sencha for GWT
 * Copyright(c) 2007-2013, Sencha, Inc.
 * [email protected]
 * 
 * http://www.sencha.com/products/gxt/license/
 */
 package com.extjs.gxt.ui.client.data;

import java.util.List;

/**
 * A JsonReader implementation that reads JSON data using a
 * ModelType definition and returns a paging list load result.
 * 
 * @param  the ListLoadResult type being returned by the reader
 */
public class JsonPagingLoadResultReader extends JsonLoadResultReader {

  /**
   * Creates a new reader.
   * 
   * @param modelType the model type definition
   */
  public JsonPagingLoadResultReader(ModelType modelType) {
    super(modelType);
  }
  
  @Override
  protected Object createReturnData(Object loadConfig, List records, int totalCount) {
    ListLoadResult result = (ListLoadResult) super.createReturnData(loadConfig, records, totalCount);

    if (result instanceof PagingLoadResult) {
      PagingLoadResult r = (PagingLoadResult) result;
      r.setTotalLength(totalCount);

      if (loadConfig instanceof PagingLoadConfig) {
        PagingLoadConfig config = (PagingLoadConfig) loadConfig;
        r.setOffset(config.getOffset());
      }
    }
    return result;

  }

  @Override
  protected BasePagingLoadResult newLoadResult(Object loadConfig, List models) {
    return new BasePagingLoadResult(models);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy