JTable createAction响应

时间:2014-02-10 11:27:09

标签: java jtable

我是JTable的新手,当我创建一个新条目时表不会刷新,但是当我更新o删除时它就会刷新。 在Servlet中,我为新创建的对象创建了一个arrayList(它正确插入到DB中),因此生成的JSON为

{"Result":"OK","Records":[{"ID":123456,"Description":"New Object"}]} 

知道为什么表不刷新?

1 个答案:

答案 0 :(得分:1)

在java脚本中可能是错误。

例如。检查你的jtable字段。这是java脚本代码的例子。


 fields: {

          customerid:{
                    title: 'No',
                    width: '4%',
                        key: true,
                        edit: false
                    },
          customername:{
                        title: 'Customer Name',
                        width: '25%',
                        edit: true
                    },
         }

这是带有Spring的服务器端jtable

            //Convert Java Object to Json               
            JsonElement element = gson.toJsonTree(showCoustomerList, new TypeToken<List<Customers>>() {}.getType());
            JsonArray jsonArray = element.getAsJsonArray();
            String listData=jsonArray.toString();               
            //Return Json in the format required by jTable plugin
            listData="{\"Result\":\"OK\",\"Records\":"+listData+"}";            
            response.getWriter().print(listData);