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.
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.
Comment