Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Unable to get Data from smartgwt.client.DSResponse.getData()

    1. GWT 2.1/Smartgwt Power 2.3

    Client Side Code:
    upl = new UploadItem("FSEFILE");
    uploadFiltBtn = new ButtonItem("Submit");
    uploadFiltBtn.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    System.out.println("Button Clicked and form Submitted");
    fseImportMain.saveData(new DSCallback() {
    public void execute(DSResponse response, Object rawData,
    DSRequest request) {
    System.out.println("Returned after File Import !....");
    partyDataGrid = new ListGrid();
    ListGridField keyField = new ListGridField("Key", "Key");
    partyDataGrid.setFields(keyField);
    System.out.println("Total no of Records :"+response.getData().length);
    System.out.println("The Server Returned :"+response.getAttribute("Test"));
    //System.out.println("The Server Party Data as :"+response.getAttributeAsStringArray("PDATA"));
    Record[] rds = response.getData();
    int i = 0;
    for (Record r : (Record[]) rds) {
    String[] attrs = r.getAttributes();
    //System.out.println("# of attrs for record : " + i + " = " + attrs.length);
    int j = 0;
    for (String attr : attrs) {
    //System.out.println("Record : " + i + " Attr : " + j + " = " + attr);
    j++;
    }
    i++;
    System.out.println("Key = " + r.getAttribute("Key"));
    }
    partyDataGrid.setData(rds);
    //fseImportWnd.destroy();
    showPartyDataWindow();
    }

    });
    }
    });

    The above client side code has upload File icon and a Button in a Window.
    When I upload a file, It is sent to server as stated in the Datasource file.

    DS File:
    <DataSource
    ID="FILEIMPORTMain"
    serverType="custom"

    >
    <fields>
    <field name="FSEFILE" type="binary"/>
    <field name="TYPE" type="text"></field>
    </fields>
    <operationBindings>
    <operationBinding operationType="add" customValueFields="" customCriteriaFields="">
    <serverObject className="com.fse.fsenet.server.administration.FSEImport" lookupStyle="new" />
    <serverMethod>doFileImport</serverMethod>
    </operationBinding>
    </operationBindings>

    </DataSource>

    I am able to get the file in server side <<doImport>> method and able to get data from the same. I am again taking the data and putting it in Hashmap and budling the hasmap to a List(ArrayList of Hashmap).

    again I am setting the List o DSResponse.setdata method.

    The portion of server side code is as follows:

    dsResponse.setStartRow(1);
    dsResponse.setEndRow(maxRow);
    dsResponse.setTotalRows(maxRow);
    dsResponse.setData(partyDatalist);
    dsResponse.setStatus(DSResponse.STATUS_SUCCESS);
    dsResponse.setProperty("PDATA", partyDatalist);
    dsResponse.setProperty("Test", "Values Received");
    HashMap<String, Comparable> temp = partyDatalist.get(0);
    System.out.println("Data =>*********"+temp);


    The data is set successfully in the server side, but I am unable to get the data in the client side.

    When I used response.getData() it is returning empty records.

    Please help me in getting the data from client side.

    I tested the server side by printing the value of the List.
    Somehow it is not getting the value in client side.

    #2
    For any such problem, just look at the RPC tab in the Developer Console to see what the server is returning.

    However your usage is odd. saveData() does an "update" or "add" and the expected response is a single record containing the updated values. If you want to do another request at the same time to fetch other data, use queuing (RPCManager.startQueue()). More info is in the QuickStart Guide.

    Comment


      #3
      The Details of my requirement is as follows:

      1) upload the excel file with data
      2) once uploaded to server, parse the file and sends the data back to user and displays int he List Grid.

      How I did:

      1) File uploaded through UploadFile item
      2) the server code reads the file and writes the data in HashMap (individual records) and HashMap to List ( list of records). The assigned records are set to DSResponse in the server.
      3) Receives the data from response(from callback of the upload file) through getData and sets the data in the ListGrid.


      Please let meknow if there is any possible way to achieve the same.

      Comment


        #4
        It's built into Enterprise Edition (BatchUploader). If you want to build your own, you should properly represent the data being returned as a separate "fetch" request, in a queue. You can take the List of HashMaps generated by the upload process and stick them in the servletRequest via setAttribute(), then retrieve them from the fetch operation with a DMI.

        Comment


          #5
          I have created a listgrid using a datasource. The listgrid filter is not allowing to filter the values. It keeps refreshing the listgrid. After doing some surfing if I come back to the same listgrid it is working fine. The same issue is not reproducible in Firefox and Chrome.

          Comment

          Working...
          X