var SendLevel = [[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9']];
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data: SendLevel
}),
这个静态下拉框,
text就是对应的值
value就是值对应的ID吧?
var sendLevel = Ext.getCmp('sendLevel').getValue();
然后这样能得到对应的ID么?还是得到text值?
它干嘛要出这个错误
363747 [http-8080-4] INFO org.hibernate.type.IntegerType - could not bind value '2, 2' to parameter: 1; java.lang.String cannot be cast to java.lang.Integer
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer也就是没有把对应的ID传到后台,而是传的值
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data: SendLevel
}),
这个静态下拉框,
text就是对应的值
value就是值对应的ID吧?
var sendLevel = Ext.getCmp('sendLevel').getValue();
然后这样能得到对应的ID么?还是得到text值?
它干嘛要出这个错误
363747 [http-8080-4] INFO org.hibernate.type.IntegerType - could not bind value '2, 2' to parameter: 1; java.lang.String cannot be cast to java.lang.Integer
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer也就是没有把对应的ID传到后台,而是传的值
这就就能得到ID呀,为什么还会出现这些异常
2011-8-5 11:22:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Error setting expression 'ext-comp-1073' with value '[Ljava.lang.String;@64978b'
ognl.InappropriateExpressionException: Inappropriate OGNL expression: (ext - comp) - 10732011-8-5 11:22:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Error setting expression 'sendLevel' with value '[Ljava.lang.String;@193229'
ognl.MethodFailedException: Method "setSendLevel" failed for object com.infotoall.action.AdminagencyAccountAction@2c3549 [java.lang.NoSuchMethodException: com.infotoall.action.AdminagencyAccountAction.setSendLevel([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265)
Caused by: java.lang.NoSuchMethodException: com.infotoall.action.AdminagencyAccountAction.setSendLevel([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
... 64 more
/-- Encapsulated exception ------------\
java.lang.NoSuchMethodException: com.infotoall.action.AdminagencyAccountAction.setSendLevel([Ljava.lang.String;)
2011-8-5 11:22:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Could not find action or result
No result defined for action com.infotoall.action.AdminagencyAccountAction and result input
var data = [["3", "我是Text3"], ["0", "我是Text0"], ["1", "我是Text1"]];
var proxy = new Ext.data.MemoryProxy(data);
var yearInfo = new Ext.data.Record.create([{
name : 'value',
type : 'String',
mapping : 0
}, {
name : 'text',
type : 'String',
mapping : 1
}]); var reader = new Ext.data.ArrayReader({}, yearInfo);
var store = new Ext.data.SimpleStore({
fields : ['value', 'text'],
data : data,
reader : reader,
autoLoad : true
})
var com = new Ext.form.ComboBox({
triggerAction : 'all',
emptyText : '请选择',
store : store,
displayField : 'text',//我们看到下拉框的内容
valueField : 'value',//getValue得到的值取决于这里的定义
width : 150,
mode : 'local',
fieldLabel : 'ComboBox',
value : "",
id : 'comid',
listeners : {
// 监听select事件
'select' : function(com, index) {
alert(Ext.getCmp('comid').getValue())//得到的是Value 也就是3、0、1这些 }
}
})
// Combox 定义结束
// 定义大panel
var form = new Ext.FormPanel({
title : "",
frame : true,
autoHeight : true,
applyTo : Ext.getBody(),
layout : "form",
items : [com] })
})
);
看看输出的是什么值?
那在后台怎么转成Integer类型,我在后台是这样接受的 private int sendLevel;
你没进action就能抛错了??
对于后台报的错 要在后台将前台的字符串转下Integer.parseInt(“传过来的那个值”) 这样"2" 才能变为int 2
前台传值又出问题了For input string: "2, 2"这个异常,我只传ID到后台,但是后台得到的却是值和ID
var Data = [[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9']];
{
xtype:'combo',
id: 'sendLevel',
//name:'sendLevel',
fieldLabel:'设优先级',
//defaultValue:'value',
displayField: 'text',
valueField: 'value',
editable: false,
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data: Data
}),
triggerAction: 'all',
width: 40,
readOnly: true,
mode: 'local',
value: send_level,
width:155
}],handler:function(){
var sendLevels = Ext.getCmp('sendLevel').getValue();
//alert(sendLevel);
if (levelForm.form.isValid()) {
levelForm.getForm().submit({
url:'adminagencyAccountAction!updateLevels.action?task='+task_id,
waitMsg: '正在保存中,请稍后...',
params: {sendLevel : sendLevels},
method: 'post',
success: function(form, action){
win.hide();
},
failure: function(form, action){
win.hide();
}
});
}
var sendLevels = Ext.getCmp('sendLevel').getValue();
//alert(sendLevel);
if (levelForm.form.isValid()) {
levelForm.getForm().submit({
url:'adminagencyAccountAction!updateLevels.action?task='+task_id,
waitMsg: '正在保存中,请稍后...',
params: {sendLevel : sendLevels},
method: 'post',
success: function(form, action){
win.hide();
},这个是你传向后台的参数 看你写的也能猜个八九不离十 这肯定不是像“1”这样的单纯的字符串 是数组吧?呵呵
这样到后台会出错的 你把后台这个action处理代码也发上来吧
嘿嘿,好了,可以运行了,
但是还有一个异常
2011-8-5 13:08:38 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Error setting expression 'ext-comp-1073' with value '[Ljava.lang.String;@1499154'
ognl.InappropriateExpressionException: Inappropriate OGNL expression: (ext - comp) - 1073
这样的,
不过我也能正常运行修改数据库。