Reputation: 31
I'm developing a jquery Jtable with Struts2 , so when I want to add new record or update existing one and I enter new value in the shown popup those values are not recovered by struts action and the new record is added with all null values. this is my java method:
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;
}
and here jquery code:
$(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');
});
Upvotes: 3
Views: 522
Reputation: 1
nom field doesn't have create true column.nom: { title: 'Nom', width: '20%', edit:true, create: true //this is one error },
Upvotes: 0
Reputation: 76
One error is that the field nom does not have the create : true option.
$(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');
});
Upvotes: 0