jTable jquery with struts2



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

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

最新更新