简体   繁体   English

空listgrid记录原因

[英]Empty listgrid record cause

My client side code is as follows where I am sending some data to the server to just print out the output. 我的客户端代码如下,我将一些数据发送到服务器以仅打印输出。 But when it returns from the server I get a empty listgrid record. 但是,当它从服务器返回时,我得到一个空的listgrid记录。 what is the cause for this. 是什么原因造成的。

Here is the screen shot of the issue 这是问题的屏幕截图

在此处输入图片说明

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());
                                        }
                                    }
                                }
                            };

and on the server side my add method is very simple for now where I am just printing the data I received from the client 在服务器端,我的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;

}

I have also attached the shot of the issue 我也附上了问题的镜头

The problem is at server side from where you are sending an empty DSResponse back to client hence at client side you are getting zero length records array. 问题出在服务器端,您将从那里将空的DSResponse发送回客户端,因此在客户端,您得到的是零长度记录数组。

Return a valid DSResponse that contains all the information of the newly added record. 返回一个有效的DSResponse ,其中包含新添加的记录的所有信息。


Please have a look at 请看看

Must read The basic flow of logic for handling DataSource requests 必须阅读处理数据源请求的基本逻辑流程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM