日期:2014-05-16  浏览次数:20399 次

Extjs这样写,action如何获得传递过来的参数
JScript code

var window_add_duty = new Ext.Window({
        title : '添加职务',
        width : 340,
        height : 250,
        closeAction : 'hide',
        autoHeight : true,
        modal : true,
        resizable : false,
        bodyStyle : 'padding:5px 5px 0 0',
        items : [new Ext.form.FormPanel({
            url : 'duty/addDuty.action',
            defaultType : 'textfield',
            layout : 'form',
            defaults : {
                widht : 233,
                msgTarget : 'side'
            },
            border : false,
            baseCls : 'x-plain',
            anchor : '100%',
            labelWidth : 60,
            labelAlign : 'right',
            items : [{
                fieldLabel : '职务名称',
                id : 'duty_name',
                name : 'duty_name',
                allowBlank : false,
                maxLength : 20,
                width : '233'

            }, {
                fieldLabel : '备注',
                xtype : 'textarea',
                name : 'duty_remark',
                maxLenght : 100,
                width : 233
            }],
            buttonAlign : 'right',
            minButtonWidth : 60,
            buttons : [{
                text : '添加',
                handler : function(btn) {
                    var frm = this.ownerCt.form;
                    if (frm.isValid()) {
                        btn.disable();
                        var cnfield = frm.findField('duty_name');
                        frm.submit({
                            waitTitle : '请稍后...',
                            waitMsg : '正在提交表单数据,请稍后...',
                            success : function(form, action) {
                                var store = grid_duty.getStore();
                                var duty = new Duty({
                                    dutyId : action.result.dutyId,
                                    dutyName : cnfield.getValue(),
                                    remark : form.findField('duty_remark')
                                            .getValue()
                                });
                                store.insert(0, [duty]);
                                window_add_duty.setTitle('[' + frm.getValue()
                                        + ']添加成功!!');
                                cnfield.reset();
                                btn.enable();
                            },
                            failure : function() {
                                Ext.Msg.show({
                                    title : ' 错误提示',
                                    msg : '"' + cnfield.getValue() + '"'
                                            + '已经存在',
                                    buttons : Ext.Msg.OK,
                                    fn : function() {
                                        cnfield.focus(true);
                                        btn.enable();
                                    },
                                    icon : Ext.Msg.ERROR
                                });
                            }
                        });

                    }
                }
            }, {
                text : '重置',
                handler : function() {
                    this.ownerCt.form.reset();
                }
            }, {
                text : '取消',
                handler : function() {
                    this.ownerCt.ownerCt.hide();
                }
            }]

        })]
    });



如何把duty 传递给action呢 ? 这里使用的 是struts2,在线等!!!

------解决方案--------------------
var myForm = new Ext.form.FormPanel({
onSubmit: Ext.emptyFn,
submit: function() {


this.getForm().getEl().dom.submit();


}