json加载Ext.FormPanel的问题!

phjijiwaiwai 2010-01-22 05:49:05
后台信息:
JSONArray array=new JSONArray();

JSONObject json1=new JSONObject();
json1.put("hc","dwg");
array.add(json1);

JSONObject json2=new JSONObject();
json2.put("pp", "baichi");
array.add(json2);

JSONObject obj=new JSONObject();
obj.put("success", true);
obj.put("root", array);

out.print(obj);
*****************************************************************
后台输出json数据:
{"success":true,"root":[{"hc":"dwg"},{"pp":"baichi"}]}

******************************************************************
js内容:
var updateform=new Ext.FormPanel({

labelAlign: 'right',
frame:true,
labelWidth:85,
autoScroll:true,
width:660,
reader: new Ext.data.JsonReader(
{root:'root'},
[
{name:'hc',mapping:'hc',type:'string'},
{name:'pp',mapping:'pp',type:'string'}
]
),
items: [{

xtype:'fieldset',
title:'信息',
autoHeight:true,
layout:'column',
items:[
{columnWidth:.8,layout: 'form',border:true,
items: [
{xtype:'textfield',fieldLabel: '姓 名',name: 'hc',anchor:'90%' },
{xtype:'textfield',fieldLabel: '密 码',name: 'pp',anchor:'90%'}
]
}
]
}],
buttons: [{
text: '确 定',
handler:function(){
updateform.form.load({
url:'TestServlet',
method:'post'
});

}

},{
text: '取 消',
handler : function(){
win.hide();
}
}]
})

***********************************************************************************
加载显示页面:


********************************************************************
问题:点击“确定”按钮,只能加载JSONArray 第一个添加的数据,也就是
*JSONObject json1=new JSONObject();
json1.put("hc","dwg");
array.add(json1);*
的值,我将json1和json2添加到jsonarray中的顺序换一下,还是只显示第一个添加的值,请各位高手帮帮忙,看看这是什么原因,多谢!

...全文
172 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

52,783

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧