jTable jquery with struts2

gpfsuwkq  于 2023-05-06  发布在  jQuery
关注(0)|答案(2)|浏览(132)

我正在用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');
});
kr98yfug

kr98yfug1#

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

$(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');
});
0md85ypi

0md85ypi2#

nom字段没有create true列。nom: { title: 'Nom', width: '20%', edit:true, create: true //this is one error },

相关问题