extjs代码:
[code="java"]
var add_guest = new Ext.Button({
text:'添加客户',
iconCls : 'icon-add',
handler : function() {
window_add_guest.show();
}
});
var window_add_guest = new Ext.Window({
title : '添加客户',
width : 350,
height : 440,
resizable : false,
autoHeight : true,
modal : true,
closeAction : 'hide',
listeners : {
'hide' : function() {
this.findById('duty.dutyName').ownerCt.form.reset();//可能是找到id ,把以前的数据重置
}
},
//进入到Form的设置
items : [
fp = new Ext.FormPanel({
frame:true,
labelAlign: 'right',
labelWidth: 85,
width:340,
waitMsgTarget: true,
items :[
new Ext.form.FieldSet({
title: 'Guest Information',
autoHeight: true,
defaultType: 'textfield',
//客户信息填写开始
items:[{
fieldLabel: '客户编号',
emptyText: '客户编号',
name: 'first',
width:190
}, {
fieldLabel: '客户名称',
emptyText: '客户名称',
name: 'last',
width:190
}
]
//客户信息填写结束
})
]
}),
//提交按钮设置
submit = fp.addButton({
text:'提交',
disabled:false,//disabled为true表示不能提交
handler:function(){
fp.getForm().submit({url:'save_guest.action',waitMsg:'正在保存数据',submitEmptyText: false})
}
})
]
});
[/code]
action代码:
[code="java"]
package Action;
import GuestDao.DaoFactory;
import GuestDao.GuestDao;
public class addGuestAction {
private String guest_id;
private String guest_name;
public String execute(){
System.out.println("------start the action by addGuestAction--------");
GuestDao imp = DaoFactory.getGuestDaoimp();
System.out.println("guest_id"+guest_id);
System.out.println("guest_name" +guest_name);
try {
imp.addGuest(guest_id, guest_name);
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
public String getGuest_id() {
return guest_id;
}
public void setGuest_id(String guestId) {
guest_id = guestId;
}
public String getGuest_name() {
return guest_name;
}
public void setGuest_name(String guestName) {
guest_name = guestName;
}
}
[/code]
控制台报错:
------start guestimp----
totalInfos:525
------start the action by addGuestAction--------
guest_id: null
guest_name: null
com.microsoft.sqlserver.jdbc.SQLServerException: 不能将值 NULL 插入列 'guest_id',表 'sinwa.dbo.guest';列不允许有空值。INSERT 失败。
怎么样才能把 guest_id 和guest_name 传给action 呢?我只想用Ext.form.FieldSet.