智能 GWT 不会更新列表网格中的 id

发布于 2024-10-25 22:19:44 字数 7744 浏览 2 评论 0原文

我正在使用 智能 GWT 2.3.0在任何浏览器中。

我有一个仅包含数据的简单列表网格。当我创建新的寄存器时,它不会更新我的 ID。

我阅读了关于此的常见问题解答,我认为我的一切都是正确的。

数据源代码为:

DataSource ds = null;
    try {
        ds = new DataSource();
        ds.setDataURL("do");
        ds.setController(controller);

        DataSourceTextField nombre = new DataSourceTextField("nombre", 
            "Nombre", 50, true);
        DataSourceTextField codigo = new DataSourceTextField("codigo", 
            "Código", 50, true);
        DataSourceTextField id = new DataSourceTextField("id", 
            "Identificador", 50);
        id.setPrimaryKey(Boolean.TRUE);
        id.setCanEdit(Boolean.FALSE);

        ds.setFields(id, codigo, nombre);

控制台结果为:

<前> <代码> 16:43:29.808:KPR3:DEBUG:gridEdit:isc_ListGrid_1:显示

内联编辑器位于:3,2,将重点关注: 真的 16:43:31.385:KPR5:信息:gridEdit:isc_ListGrid_1:cellEditEnd: 结束编辑,完成事件: 进入 16:43:31.386:KPR5:调试:gridEdit:isc_ListGrid_1:更改 检测:newValues:{codigo: “普鲁巴”, 名称:“Prueba”},旧值:undef 16:43:31.390:KPR5:调试:gridEdit:isc_ListGrid_1:在 字段:codigo 应用验证器:[ {类型:“isString”, typeCastValidator: true, _生成:真实, defaultErrorMessage:“必须是字符串。”}, {类型:“必需”, 默认错误消息:undef, 错误消息:“该字段为必填项”} ] 价值:普鲁巴 16:43:31.390:KPR5:信息:gridEdit:isc_ListGrid_1:validateFieldValue, newValue:“PRUEBA”,通过验证: true,结果值:null 16:43:31.392:KPR5:调试:gridEdit:isc_ListGrid_1:在 字段:应用验证器的名称:[ {类型:“isString”, typeCastValidator: true, _生成:真实, defaultErrorMessage:“必须是字符串。”}, {类型:“必需”, 默认错误消息:undef, 错误消息:“该字段为必填项”} ] 价值:普鲁巴 16:43:31.393:KPR5:信息:gridEdit:isc_ListGrid_1:validateFieldValue, newValue:“Prueba”,通过验证: true,结果值:null 16:43:31.393:KPR5:信息:gridEdit:isc_ListGrid_1:保存 newValues '{codigo: "PRUEBA", 名称:“Prueba”}' 16:43:31.996:XRP3:调试:结果集:isc_ResultSet_1 (创建者: isc_ListGrid_1):dataSource数据 改变射击方式 16:43:31.997:XRP3:信息:结果集:isc_XDataSource_3:dsResponse 对于添加类型的成功操作 没有返回更新的记录。 使用提交的请求数据进行更新 结果集缓存。 16:43:31.997:XRP3:调试:结果集:isc_XDataSource_3:已提交 要集成到缓存中的数据:[ {科迪戈:“普鲁巴”, 名称:“Prueba”} ] 16:43:31.997:XRP3:信息:结果集:isc_ResultSet_1 (创建者:isc_ListGrid_1):更新中 操作后缓存到位: 添加,allMatchingRowsCached true 16:43:31.997:XRP3:信息:结果集:isc_ResultSet_1 (创建者:isc_ListGrid_1):正在更新 缓存:操作类型“添加”已提交 by 'isc_ListGrid_1',1 行更新 数据: [ { 科迪戈:“普鲁巴”, 名称:“Prueba”} ] 16:43:31.998:XRP3:信息:结果集:isc_ResultSet_1 (创建者:isc_ListGrid_1):本地 应用过滤器:4 条记录中的 4 条匹配 筛选:{ } 16:43:31.999:XRP3:信息:结果集:isc_XDataSource_3:dsResponse 对于添加类型的成功操作 没有返回更新的记录。 使用提交的请求数据进行更新 结果集缓存。 16:43:31.999:XRP3:调试:结果集:isc_XDataSource_3:已提交 要集成到缓存中的数据:[ {科迪戈:“普鲁巴”, 名称:“Prueba”} ] 16:43:32.004:RDQ5:调试:结果集:isc_ResultSet_1 (创建者: isc_ListGrid_1):getRange(0, 3) 从缓存中得到满足

对不起,我忘了说它在插入中发生相同的情况,这是插入日志:

13:22:09.162:KPR3:DEBUG:gridEdit:isc_ListGrid_0:change detection: newValues: {codigo: "prueba",
nombre: "prueba"}, oldValues: undef
13:22:09.167:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: codigo applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.168:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.170:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: nombre applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:Saving newValues '{codigo: "prueba",
nombre: "prueba"}'
13:22:10.612:XRP7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
13:22:10.612:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.612:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: add, allMatchingRowsCached true
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'add' submitted by 'isc_ListGrid_0',1 rows update data:
[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.614:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Local filter applied: 3 of 3 records matched filter:{
}
13:22:10.615:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.615:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.627:RDQ9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 2) satisfied from cache

这是发送我的服务器 JSON 作为添加新寄存器的响应:

input: {
    "__requestBody": {
        "dataSource": "isc_XDataSource_1",
        "operationType": "add",
        "data": {
            "nombre": "prueba",
            "codigo": "prueba"
        },
        "componentId": "isc_ListGrid_0",
        "oldValues": null
    },
    "inputfields": [
        {
            "value": "prueba",
            "property": "nombre"
        },
        {
            "value": "prueba",
            "property": "codigo"
        }
    ],
    "__requestFormat": "smartgwt",
    "__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
    "__http_request": "org.apache.catalina.connector.RequestFacade@18d70a6",
    "fields": [
        {
            "name": "id",
            "property": "id"
        },
        {
            "name": "codigo",
            "property": "codigo"
        },
        {
            "name": "nombre",
            "property": "nombre"
        }
    ]
}

这是我更新寄存器的响应:

{
    "id": "1",
    "__requestBody": {
        "dataSource": "isc_XDataSource_2",
        "operationType": "update",
        "data": {
            "nombre": "prueba2",
            "id": "1"
        },
        "componentId": "isc_ListGrid_0",
        "oldValues": {
            "id": "1",
            "codigo": "prueba",
            "nombre": "prueba"
        }
    },
    "inputfields": [
        {
            "value": "prueba2",
            "property": "nombre"
        },
        {
            "value": "1",
            "property": "id"
        }
    ],
    "__requestFormat": "smartgwt",
    "__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
    "__http_request": "org.apache.catalina.connector.RequestFacade@1d40d08",
    "fields": [
        {
            "name": "id",
            "property": "id"
        },
        {
            "name": "codigo",
            "property": "codigo"
        },
        {
            "name": "nombre",
            "property": "nombre"
        }
    ]
}

I'm using Smart GWT 2.3.0 in any browser.

I have a listgrid simple only with data. And when I create new register it doesn't update my id.

I read the faq problem about that, and I think I have everything correct.

the code of data source is:

DataSource ds = null;
    try {
        ds = new DataSource();
        ds.setDataURL("do");
        ds.setController(controller);

        DataSourceTextField nombre = new DataSourceTextField("nombre", 
            "Nombre", 50, true);
        DataSourceTextField codigo = new DataSourceTextField("codigo", 
            "Código", 50, true);
        DataSourceTextField id = new DataSourceTextField("id", 
            "Identificador", 50);
        id.setPrimaryKey(Boolean.TRUE);
        id.setCanEdit(Boolean.FALSE);

        ds.setFields(id, codigo, nombre);

The console result is:

    16:43:29.808:KPR3:DEBUG:gridEdit:isc_ListGrid_1:showing

inline editor at: 3,2, will focus:
true
16:43:31.385:KPR5:INFO:gridEdit:isc_ListGrid_1:cellEditEnd:
ending editing, completion event:
enter
16:43:31.386:KPR5:DEBUG:gridEdit:isc_ListGrid_1:change
detection: newValues: {codigo:
"PRUEBA",
nombre: "Prueba"}, oldValues: undef
16:43:31.390:KPR5:DEBUG:gridEdit:isc_ListGrid_1:At
field: codigo applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Must be a String."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Field is required"}
] to value:PRUEBA
16:43:31.390:KPR5:INFO:gridEdit:isc_ListGrid_1:validateFieldValue,
newValue: "PRUEBA", passed validation:
true, resultingValue: null
16:43:31.392:KPR5:DEBUG:gridEdit:isc_ListGrid_1:At
field: nombre applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Must be a String."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Field is required"}
] to value:Prueba
16:43:31.393:KPR5:INFO:gridEdit:isc_ListGrid_1:validateFieldValue,
newValue: "Prueba", passed validation:
true, resultingValue: null
16:43:31.393:KPR5:INFO:gridEdit:isc_ListGrid_1:Saving
newValues '{codigo: "PRUEBA",
nombre: "Prueba"}'
16:43:31.996:XRP3:DEBUG:ResultSet:isc_ResultSet_1
(created by:
isc_ListGrid_1):dataSource data
changed firing
16:43:31.997:XRP3:INFO:ResultSet:isc_XDataSource_3:dsResponse
for successful operation of type add
did not return updated record[s].
Using submitted request data to update
ResultSet cache.
16:43:31.997:XRP3:DEBUG:ResultSet:isc_XDataSource_3:Submitted
data to be integrated into the cache:[
{codigo: "PRUEBA",
nombre: "Prueba"}
]
16:43:31.997:XRP3:INFO:ResultSet:isc_ResultSet_1
(created by: isc_ListGrid_1):updating
cache in place after operationType:
add, allMatchingRowsCached true
16:43:31.997:XRP3:INFO:ResultSet:isc_ResultSet_1
(created by: isc_ListGrid_1):Updating
cache: operationType 'add' submitted
by 'isc_ListGrid_1',1 rows update
data:
[
{ codigo: "PRUEBA",
nombre: "Prueba"}
]
16:43:31.998:XRP3:INFO:ResultSet:isc_ResultSet_1
(created by: isc_ListGrid_1):Local
filter applied: 4 of 4 records matched
filter:{
}
16:43:31.999:XRP3:INFO:ResultSet:isc_XDataSource_3:dsResponse
for successful operation of type add
did not return updated record[s].
Using submitted request data to update
ResultSet cache.
16:43:31.999:XRP3:DEBUG:ResultSet:isc_XDataSource_3:Submitted
data to be integrated into the cache:[
{codigo: "PRUEBA",
nombre: "Prueba"}
]
16:43:32.004:RDQ5:DEBUG:ResultSet:isc_ResultSet_1
(created by:
isc_ListGrid_1):getRange(0, 3)
satisfied from cache

Sorry I forgot to say it happens the same in insert, this is the insert log:

13:22:09.162:KPR3:DEBUG:gridEdit:isc_ListGrid_0:change detection: newValues: {codigo: "prueba",
nombre: "prueba"}, oldValues: undef
13:22:09.167:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: codigo applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.168:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.170:KPR3:DEBUG:gridEdit:isc_ListGrid_0:At field: nombre applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
defaultErrorMessage: "Debe ser una Cadena."},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Campo es obligatorio"}
] to value:prueba
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:validateFieldValue, newValue: "prueba", passed validation: true, resultingValue: null
13:22:09.172:KPR3:INFO:gridEdit:isc_ListGrid_0:Saving newValues '{codigo: "prueba",
nombre: "prueba"}'
13:22:10.612:XRP7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
13:22:10.612:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.612:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: add, allMatchingRowsCached true
13:22:10.613:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'add' submitted by 'isc_ListGrid_0',1 rows update data:
[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.614:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Local filter applied: 3 of 3 records matched filter:{
}
13:22:10.615:XRP7:INFO:ResultSet:isc_XDataSource_1:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.
13:22:10.615:XRP7:DEBUG:ResultSet:isc_XDataSource_1:Submitted data to be integrated into the cache:[
{codigo: "prueba",
nombre: "prueba"}
]
13:22:10.627:RDQ9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 2) satisfied from cache

This is what send my server JSON as response to add new register:

input: {
    "__requestBody": {
        "dataSource": "isc_XDataSource_1",
        "operationType": "add",
        "data": {
            "nombre": "prueba",
            "codigo": "prueba"
        },
        "componentId": "isc_ListGrid_0",
        "oldValues": null
    },
    "inputfields": [
        {
            "value": "prueba",
            "property": "nombre"
        },
        {
            "value": "prueba",
            "property": "codigo"
        }
    ],
    "__requestFormat": "smartgwt",
    "__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
    "__http_request": "org.apache.catalina.connector.RequestFacade@18d70a6",
    "fields": [
        {
            "name": "id",
            "property": "id"
        },
        {
            "name": "codigo",
            "property": "codigo"
        },
        {
            "name": "nombre",
            "property": "nombre"
        }
    ]
}

And this is my response of update register:

{
    "id": "1",
    "__requestBody": {
        "dataSource": "isc_XDataSource_2",
        "operationType": "update",
        "data": {
            "nombre": "prueba2",
            "id": "1"
        },
        "componentId": "isc_ListGrid_0",
        "oldValues": {
            "id": "1",
            "codigo": "prueba",
            "nombre": "prueba"
        }
    },
    "inputfields": [
        {
            "value": "prueba2",
            "property": "nombre"
        },
        {
            "value": "1",
            "property": "id"
        }
    ],
    "__requestFormat": "smartgwt",
    "__httpSession": "org.apache.catalina.session.StandardSessionFacade@1c2b15c",
    "__http_request": "org.apache.catalina.connector.RequestFacade@1d40d08",
    "fields": [
        {
            "name": "id",
            "property": "id"
        },
        {
            "name": "codigo",
            "property": "codigo"
        },
        {
            "name": "nombre",
            "property": "nombre"
        }
    ]
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滿滿的愛 2024-11-01 22:19:44

您无法通过更新来更改主键(就像在 SQL 中一样)。进行删除,然后添加。

You can't change the primary key with an update (just as in SQL). Do a remove, then an add.

翻了热茶 2024-11-01 22:19:44

日志准确地告诉您出了什么问题:

16:43:31.999:XRP3:INFO:ResultSet:isc_XDataSource_3:dsResponse 对于类型 add 的成功操作没有返回更新的记录。使用提交的请求数据来更新 ResultSet 缓存。

您的 JSON 响应基本上只是随机数据,SmartGWT 不知道如何处理它,因为您没有声明任何有关它的格式或含义的信息。所以SmartGWT只是将提交的数据作为更新数据,而提交的数据显然不包含你在服务器上生成的新id值。

从快速入门指南的数据集成章节开始,然后点击所有链接以获取更多参考。简而言之,您的 DataSource 声明告诉 SmartGWT 如何处理您的响应。您可以使用推荐的格式 (RestDataSource),也可以声明 recordXPath 等属性以使 SmartGWT 解析您现有的格式。

The logs are telling you exactly what's wrong:

16:43:31.999:XRP3:INFO:ResultSet:isc_XDataSource_3:dsResponse for successful operation of type add did not return updated record[s]. Using submitted request data to update ResultSet cache.

Your JSON response is just random data basically, SmartGWT doesn't know what to do with it because you haven't declared anything about it's format or meaning. So SmartGWT just uses the submitted data as update data, and the submitted data obviously doesn't contain the new id value you generated on the server.

Start with the QuickStart Guide, Data Integration chapter and follow all the links to further reference. In a nutshell, your DataSource declaration tells SmartGWT how to process your responses. There are recommended formats you can just use (RestDataSource) or you can declare properties such as recordXPath to have SmartGWT parse your existing format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文