我的客户端代码如下所示,我将一些数据发送到服务器以打印出输出。但是当它从服务器返回时,我得到一个空的listgrid记录。造成这种情况的原因是什么。
以下是问题的屏幕截图
if (fieldName.equals("Approve"))
{
IButton button = new IButton();
button.setHeight(18);
button.setWidth(65);
button.setTitle("Approve");
button.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
DebugTools.print("SOID " + record.getAttribute("supplierOrderID") + " SODID" + record.getAttribute("sodID")+" sordID "+record.getAttribute("sordID"));
approveProduct(record.getAttribute("supplierOrderID"), record.getAttribute("sodID"),record.getAttribute("sordID"));
}
private void approveProduct(String supplierOrderID, String sodID, String sordID)
{
Record record = new Record();
record.setAttribute("supplierOrderID", supplierOrderID);
record.setAttribute("sodID", sodID);
record.setAttribute("sordID",sordID);
historyGrid.addData(record, callback);
}
DSCallback callback = new DSCallback()
{
@Override
public void execute(DSResponse response, Object rawData, DSRequest request)
{
Record[] records = response.getData();
if (records != null && records.length > 0)
{
Record record = records[0];
JavaScriptObject js = record.getJsObj(); JSONObject json = new JSONObject(js); System.out.println(" records.length " + records.length); for (int i = 0; i < records.length; i++) { Record recordd = records[i];
JavaScriptObject jss = recordd.getJsObj();
JSONObject jsonn = new JSONObject(jss);
System.out.println(jsonn.toString());
}
}
}
};
在服务器端,我的add方法现在非常简单,我只是打印从客户端收到的数据
public DSResponse add(DSRequest dsRequest) throws Exception
{
DSResponse dsResponse = new DSResponse();
Long user_idlong = SessionUtills.getSessionUser(dsRequest.getHttpServletRequest());
System.out.println("sodID " + dsRequest.getFieldValue("sodID").toString());
System.out.println("PRODUCT APPROVED !!!!!!!!!!!!!" + " SUPPLIER ORDER ID " + dsRequest.getFieldValue("supplierOrderID").toString());
return dsResponse;
}
我还附上了问题的镜头
答案 0 :(得分:0)
问题出在服务器端,您将空DSResponse
发送回客户端,因此在客户端,您将获得零长度记录数组。
返回包含新添加记录的所有信息的有效DSResponse
。
请看一下
必须阅读The basic flow of logic for handling DataSource requests