コード例 #1
0
  /**
   * Create DataSource for TileGrid
   *
   * @param attributes
   */
  private void createScGridDS() {

    /*
     * Request url
     */
    String url = getRequestUrl();

    /*
     * Request fields
     */
    DataSourceField[] fields = createDataFields(attributes);

    dataSource =
        new RestDataSource() {

          protected Object transformRequest(DSRequest dsRequest) {
            dsRequest.setParams(getRequestParams());
            return super.transformRequest(dsRequest);
          }

          protected void transformResponse(DSResponse response, DSRequest request, Object data) {
            super.transformResponse(response, request, data);
          }
        };

    dataSource.setDataFormat(DSDataFormat.JSON);
    dataSource.setDataProtocol(DSProtocol.GETPARAMS);

    dataSource.setDataURL(url);
    dataSource.setFields(fields);

    /*
     * finally set data source
     */
    setDataSource(dataSource);
  }
コード例 #2
0
 @Override
 protected void transformResponse(DSResponse dsResponse, DSRequest dsRequest, Object data) {
   if (RestConfig.isStatusOk(dsResponse)) {
     Record[] records = dsResponse.getData();
     for (Record record : records) {
       String mid = record.getAttribute(FIELD_ID);
       String way = record.getAttribute(FIELD_WAY);
       String pk = mid;
       if (way != null) {
         pk = mid + way;
       }
       record.setAttribute(PRIMARY_KEY, pk);
     }
   }
   super.transformResponse(dsResponse, dsRequest, data);
 }