52,797
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script type="text/javascript">
Ext.onReady(function(){
var store=new Ext.data.JsonStore({
autoLoad: true,
url:'UtilGetJsonStore.action',
root: "root",
//data: [{id: "aa", value: "aa"}, {id: "bb", value: "bb"}],//把前面那个注释掉,用这句,是能显示的
fields:['id', 'value']
});
var combo=new Ext.form.ComboBox({
id:'depart',
name:'Pptype',
emptyText:'请选择',
mode : 'local',
editable: false,
triggerAction: 'all',
store:store,
valueField : 'value',
displayField : 'id'
});
combo.render("comboid");
});
</script>
</head>
<body>
<div id="comboid"></div>
</body>
</html>
private JSONObject jSONObject = null;
/**
* @return the jSONObject
*/
public JSONObject getjSONObject()
{
return jSONObject;
}
/**
* @param jSONObject the jSONObject to set
*/
public void setjSONObject(JSONObject jSONObject)
{
this.jSONObject = jSONObject;
}
public String getJsonStore()
{
System.out.println("getThemes33333...............");
List<JSONObject> jsonObjectList = new ArrayList<JSONObject>();
JSONObject jSONObject1 = new JSONObject();
jSONObject1.put("id", "aa");
jSONObject1.put("value", "aa");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("id", "bb");
jSONObject2.put("value", "bb");
jsonObjectList.add(jSONObject1);
jsonObjectList.add(jSONObject2);
JSONArray arr = JSONArray.fromObject(jsonObjectList);
jSONObject.put("root", arr);
return SUCCESS;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2" extends="json-default" namespace="">
<action name="utilGetJsonStore" class="text.UtilAction" method="getJsonStore">
<result type="json">
<param name="root">jSONObject</param>
</result>
</action>
</package>
</struts>