gpt4 book ai didi

jquery - jTable jquery 与 struts2

转载 作者:行者123 更新时间:2023-12-01 01:44:48 24 4
gpt4 key购买 nike

我正在使用 Struts2 开发 jquery Jtable ,因此当我想要添加新记录或更新现有记录并且我在显示的弹出窗口中输入新值时,这些值不会被 struts 操作恢复,并且新记录会添加所有内容空值。这是我的java方法:

private String nom,identifiant;
private String prenom;
private String email;

// getter/setter...
public String create() throws IOException {
record = new Student();

record.setNom(this.getNom());
record.setPrenom(this.getPrenom());
record.setEmail(this.getEmail());
record.setIdentifiant(getIdentifiant());
try {
// Create new record

dao.ajout(record);
result = "OK";

} catch (Exception e) {
result = "ERROR";
message = e.getMessage();
System.err.println(e.getMessage());
}
return Action.SUCCESS;
}

这里是 jquery 代码:

$(document).ready(function () {

$('#StudentTableContainer').jtable({
title: 'Liste des agents pharmaciens',
paging : true, //Enable paging
pageSize : 3, //Set page size (default: 10)
actions: {
listAction : 'afficheStudent',
createAction : 'createAction',
updateAction : 'updateAction',
deleteAction : 'deleteAction'
},
fields: {
id: {
title:'id',
key: true,
list: true,

},
identifiant: {
title: 'Identifiant',
width: '20%',
edit:true
},
nom: {
title: 'Nom',
width: '20%',
edit:true
},
prenom: {
title: 'Prenom',
width: '30%',
edit:true,
create:true
},
email: {
title: 'Email',
width: '20%',
edit: true,
create:true
}
}
});
$('#StudentTableContainer').jtable('load');
});

最佳答案

一个错误是字段 nom 没有 create : true 选项。

$(document).ready(function () {

$('#StudentTableContainer').jtable({
title: 'Liste des agents pharmaciens',
paging : true, //Enable paging
pageSize : 3, //Set page size (default: 10)
actions: {
listAction : 'afficheStudent',
createAction : 'createAction',
updateAction : 'updateAction',
deleteAction : 'deleteAction'
},
fields: {
id: {
title:'id',
key: true,
list: true,

},
identifiant: {
title: 'Identifiant',
width: '20%',
edit:true
},
nom: {
title: 'Nom',
width: '20%',
edit:true,
create: true //this is one error
},
prenom: {
title: 'Prenom',
width: '30%',
edit:true,
create:true
},
email: {
title: 'Email',
width: '20%',
edit: true,
create:true
}
}
});
$('#StudentTableContainer').jtable('load');
});

关于jquery - jTable jquery 与 struts2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29482008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com