Your site had helped me a lot in java web development. My only hindrance is Populating Dropdown inside javascript through struts2
action class (using jtable). I have used your sample code "AJAX based CRUD operation in Struts 2 using jTable plugin"
.
In below code snippet i want Department to be dropdown which gets value from database using list2
method of com.action.JtableAction
class.
userDefinedJtable.js:
department : {
title : 'Department',
width : '30%',
edit : true,
options : '/WebApplication1/list2Action',
list: false
},
list2
method inside JtableAction
public String list2() {
JSONObject obj = new JSONObject();
obj.put("name", "foo");
obj.put("num", new Integer(100));
obj.put("balance", new Double(1000.21));
obj.put("is_vip", new Boolean(true));
return obj.toString();
}
Declaration in struts.xml
<action name="getJSONResult" class="com.action.JtableAction" method="list2">
<result type="json" />
</action>
But when i accessed
/WebApplication1/list2Action
i am getting this error
HTTP Status 404 - No result defined for action com.action.JtableAction and result {"balance":1000.21,"num":100,"is_vip":true,"name":"foo"}
Kindly help me whether i am doing right thing or not. And what is required.
EDIT
struts.xml
<struts>
<package name="default" extends="json-default">
<action name="*Action" class="com.action.JtableAction" method="{1}">
<result type="json">/jTable.jsp</result>
</action>
<action name="getJSONResult" class="com.action.JtableAction" method="list">
<result type="json" />
</action>
<action name="getJSONResult" class="com.action.JtableAction" method="list2">
<result type="json">
<param name="root">obj</param>
</result>
</action>
</package>
</struts>