<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Obtaining JSON object from struts action response</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>anees.iny on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p30809</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p30809</guid>
        	        	<description><![CDATA[<blockquote>
<p><strong>kirangentlebreeze1987 said </strong></p>
<blockquote>
<p>aarati said:<br />
 Hello,</p>
<p> Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" alt="Smile" src="http://www.trirand.com/blog/wp-content/forum-smileys/sf-smile.gif" />.</p>
<p> Made slight modifications to the existing code:</p>
<p> <strong><span style="text-decoration: underline">Struts Action:</span></strong></p>
<p> 1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p> 2) Using the write method of the jsonObj to write the response data.</p>
<p> The action method now looks like the following:</p>
<p> <em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />
 Â Â Â HttpServletRequest request, HttpServletResponse response) {</em></p>
<p> <em>â€¦<br />
 â€¦<br />
 Â JSONObject jsonObj = createJSONTestData();<br />
 </em></p>
<p> <em>System.out.println("Final JSON OBj: " + jsonObj.toString());Â </em></p>
<p> <em>jsonObj.write(response.getWriter());</em></p>
<p> <em>return null;</em><em><br />
 Â }</em></p>
<p> <em>Â </em></p>
<p> <em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p> <strong><span style="text-decoration: underline">JSP:</span></strong></p>
<p> JSP Code to populate the grid is shown below:</p>
<p> <em>$(document).ready(function(){<br />
 $.ajax(<br />
 Â Â Â  {<br />
 Â Â Â Â Â Â  type: "POST",<br />
 Â Â Â Â Â Â  <a href="http://www.trirand.com/blog/'/PeakAlpha/mutualfund.do?method=getMFTransDetails1'" target="_blank"><em>url:' Â /TestJSON/testAction.do?method=getJSONData'</em></a></em><em>,</em><br />
 Â Â Â Â Â Â  data: "",<br />
 Â Â Â Â Â Â  dataType: "json",<br />
 Â Â Â Â Â Â  success: function(result)<br />
 Â Â Â Â Â Â  {<br />
 Â Â Â Â Â Â Â Â Â Â Â  alert("success");<br />
 Â Â Â Â Â Â Â Â Â Â Â  alert("result: " + result.total);<br />
 Â Â Â Â Â Â Â Â Â Â Â  jQuery("#list10").jqGrid({<br />
 Â Â Â Â Â Â Â Â Â Â Â Â <a href="http://www.trirand.com/blog/'/PeakAlpha/mutualfund.do?method=getMFTransDetails1'" target="_blank"><em>url:' Â /TestJSON/testAction.do?method=getJSONData'</em></a><em>,</em><br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  datatype: 'json',<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  mtype: 'POST',<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  colNames:['Invoice Number','Invoice Date','Invoice Name'],<br />
 Â Â Â Â Â Â Â Â  colModel:[<br />
 Â Â Â Â Â Â Â Â Â Â  Â Â {name:'id',index:'id', id:'name',width:90},<br />
 Â Â Â Â Â Â Â Â Â Â  Â Â {name:'invdate',index:'invdate', width:120},<br />
 Â Â Â Â Â Â Â Â Â Â  Â Â {name:'invname',index:'invname', width:200}<br />
 Â Â Â  Â ],<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  pager: jQuery('#pager1'),<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  rowNum: 5,<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  rowList: [5, 10, 20, 50],<br />
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  viewrecords: true<br />
 Â Â Â Â Â Â Â Â Â Â Â  })<br />
 Â Â Â Â Â Â  },<br />
 Â Â Â Â Â Â  error: function(x, e)<br />
 Â Â Â Â Â Â  {<br />
 Â Â Â Â Â Â Â Â Â Â Â  alert("errorddd " + x.readyState + " "+ x.status +" "+ e);<br />
 Â Â Â Â Â Â Â Â Â Â Â  if (x.readyState == 4) {<br />
 Â Â Â Â Â Â Â Â Â Â Â  Â var response = x.responseText;<br />
 Â Â Â Â Â Â Â Â Â Â Â  Â alert(response);<br />
 Â Â Â Â Â Â Â Â Â Â Â  }<br />
 Â Â Â Â Â Â  }<br />
 Â Â Â  });<br />
 setTimeout(function() {$("#list10").jqGrid('setGridParam',{datatype:'json'}); },50);<br />
 });</p>
<p> <em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p> Â If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
<p> Regards,</p>
<p> Aarati
 </p>
</blockquote>
<hr />
<p> i do have some problem populating a json object values to my gridÂ </p>
<p> can you help me???</p>
</blockquote>
<p>Hi aarati,</p>
<p>Can u provide me full code which is mentioned above.I need it very urgently Pls reply fast.</p>
<p>Thanks,</p>
<p>anees.iny</p>
]]></description>
        	        	<pubDate>Sat, 05 Jul 2014 09:47:20 +0300</pubDate>
        </item>
        <item>
        	<title>vsendhil on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27317</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27317</guid>
        	        	<description><![CDATA[<blockquote>
<p>vsendhil said:What are the java libraries (jar) required for json?</p>
<p>I tried the above with json-lib-2.2.2-jdk15.jar and I am getting "java.lang.NoClassDefFoundError: net.sf.ezmorph.Morpher" error.</p>
</p>
</blockquote>
<hr />
<p>I downloaded the JARs and fixed this</p>
]]></description>
        	        	<pubDate>Thu, 13 Sep 2012 10:19:33 +0300</pubDate>
        </item>
        <item>
        	<title>vsendhil on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27316</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27316</guid>
        	        	<description><![CDATA[<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
<p>Hi Aarthi,</p>
<p>I tried this and I am getting the alerts but there is not table populated, could you please share the full source code (jsp and action) or let us know the steps to do this.&#160; Thanks</p>
]]></description>
        	        	<pubDate>Thu, 13 Sep 2012 10:18:39 +0300</pubDate>
        </item>
        <item>
        	<title>vsendhil on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27313</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p27313</guid>
        	        	<description><![CDATA[<p>What are the java libraries (jar) required for json?</p>
<p>I tried the above with json-lib-2.2.2-jdk15.jar and I am getting "java.lang.NoClassDefFoundError: net.sf.ezmorph.Morpher" error.</p></p>
]]></description>
        	        	<pubDate>Thu, 13 Sep 2012 05:30:31 +0300</pubDate>
        </item>
        <item>
        	<title>rohan.gandhi on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p26851</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p26851</guid>
        	        	<description><![CDATA[<p>Thanks a zillion Arati! That works like magic! <img class="spSmiley" style="margin:0" title="Cool" src="/blog/wp-content/forum-smileys/sf-cool.gif" alt="Cool" /></p>
]]></description>
        	        	<pubDate>Tue, 26 Jun 2012 15:07:24 +0300</pubDate>
        </item>
        <item>
        	<title>surendra on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25923</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25923</guid>
        	        	<description><![CDATA[<p>hiii aarti would you explain how to use jquery , json with java &#38; jsp in struts 1.2 ? Please clarrify your code and what is the use url an how to automaically create jquery grid in jsp.</p>
]]></description>
        	        	<pubDate>Fri, 10 Feb 2012 14:47:51 +0200</pubDate>
        </item>
        <item>
        	<title>surendra on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25922</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25922</guid>
        	        	<description><![CDATA[<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>I get an empty grid when trying to obtain a json object from struts action method.</p>
<p>Making use of the following&#160;in the&#160;application:</p>
<p>1) Struts 1.2</p>
<p>2) JQGrid 3.8.2</p>
<p>3) JQuery 1.4.4</p>
</p>
<p>The Struts action method returns a json object after obtaining data from the database. See code below:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br />&#160;response.setHeader("X-JSON", jsonObj.toString());<br />&#160;System.out.println("Final JSON OBj: " + jsonObj.toString());<br />&#160;return mapping.findForward(sForward);<br />}</em></p>
<p><em>/*<br />&#160; *This piece of code is the same as the php code mentioned in one of the examples<br />&#160; *provided in jqgrid demos<br />*/<br />public JSONObject createJSONTestData() {<br />&#8230;.<br />&#8230;.<br />//Hit the database and obtain the resultset and create the json object</em></p>
<p><em>&#160;JSONObject responcedata=new JSONObject();<br />&#160;net.sf.json.JSONArray cellarray=new net.sf.json.JSONArray();<br />&#160;responcedata.put("total","3&#8243;);<br />&#160;responcedata.put("page",cpage);<br />&#160;responcedata.put("records","2&#8243;);</em></p>
<p><em>&#160;net.sf.json.JSONArray cell=new net.sf.json.JSONArray();<br />&#160;net.sf.json.JSONObject cellobj=new net.sf.json.JSONObject();</em></p>
<p><em>&#160;int i=1;<br />&#160;while(rs.next()){<br />&#160;&#160;cellobj.put("id",rs.getInt(1));<br />&#160;&#160;cell.add(rs.getInt(1));<br />&#160;&#160;cell.add(rs.getString(2));<br />&#160;&#160;cell.add(rs.getString(3));<br />&#160;&#160;cellobj.put("cell",cell);<br />&#160;&#160;cell.clear();<br />&#160;&#160;cellarray.add(cellobj);<br />&#160;&#160;i++;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160; PrintWriter out = response.getWriter();<br />&#160; responcedata.put("rows",cellarray);<br />&#160;&#160;&#160; <br />&#160; return responcedata;</em></p>
<p><em>}</em></p>
<p><em>&#160;</em></p>
<p>The struts-config.xml action forward mapping points to an empty.jsp that has no specific code.</p>
</p>
<p>The jsp file formulates the jqgrid as shown below:</p>
</p>
<p><em>$(document).ready(function(){<br />$("#load_callback1&#8243;).click(function(){<br />jQuery("#list10&#8243;).jqGrid({<br />&#160;</em><a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,<br />&#160;datatype: "json",<br />&#160;&#160; &#160;colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;id&#39;,width:90},<br />&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160; &#160;],<br />&#160;&#160; &#160;rowNum:10,<br />&#160;&#160; &#160;autowidth: true,<br />&#160;&#160; &#160;rowList:[10,20,30],<br />&#160;&#160; &#160;pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160; &#160;sortname: &#39;invname&#39;,<br />&#160;&#160;&#160; sortorder: "desc",<br />&#160;&#160;&#160; caption:"JSON Example"<br />}).navGrid(&#39;#pager1&#39;,{edit:false,add:false,del:false});&#160;<br />});<br />});</em></p>
</p>
<p>The grid comes up with no data. A similar example works well with the doGet method of a servlet.</p>
</p>
<p>Questions:</p>
<p>1) How do we obtain the json object returned from a struts action method?</p>
<p>2) Is there any process to be done in the empty.jsp file to handle the response object and obtain the json data?</p>
</p>
<p>Awaiting for a clarification at the earliest. Thank you.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
]]></description>
        	        	<pubDate>Fri, 10 Feb 2012 14:43:33 +0200</pubDate>
        </item>
        <item>
        	<title>surendra on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25921</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p25921</guid>
        	        	<description><![CDATA[<blockquote>
<p>kirangentlebreeze1987 said:</p>
<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
<p>i do have some problem populating a json object values to my grid&#160;</p>
<p>can you help me???</p>
</p>
</blockquote>
<hr />
]]></description>
        	        	<pubDate>Fri, 10 Feb 2012 14:42:39 +0200</pubDate>
        </item>
        <item>
        	<title>aarati on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p23839</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p23839</guid>
        	        	<description><![CDATA[<blockquote>
<p>moin_mkhan said:</p>
<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="http://www.trirand.com/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="http://www.trirand.com/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="http://www.trirand.com/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
<p>Hi,</p>
</p>
<p>For populating the grid this code works fine. But i am unable to make the grid editable even by setting the editable:true option.</p>
<p>Can you please help resolve this issue?</p>
</p>
<p>Thanks,</p>
<p>Moin</p>
</p>
</blockquote>
<hr />
<p>Did you include the necessary js files required for making the jqgrid editable.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
]]></description>
        	        	<pubDate>Sun, 03 Jul 2011 10:05:58 +0300</pubDate>
        </item>
        <item>
        	<title>mlotfi on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p23836</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p23836</guid>
        	        	<description><![CDATA[<p>Hi <strong>aarati,</strong></p>
</p>
<p><strong>I am new here, I will appreciate if you can send me the src code of a working example using :</strong></p>
<p>1) Struts 1.2</p>
<p>2) JQGrid 3.8.2</p>
<p>3) JQuery 1.4.4</p>
<p>my email is : <a href="mailto:majidnakit@yahoo.com" target="_blank">majidnakit@yahoo.com</a></p>
<p>Thanks lot.</p>
]]></description>
        	        	<pubDate>Sat, 02 Jul 2011 08:47:13 +0300</pubDate>
        </item>
        <item>
        	<title>moin_mkhan on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22927</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22927</guid>
        	        	<description><![CDATA[<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="http://www.trirand.com/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="http://www.trirand.com/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="http://www.trirand.com/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
<p>Hi,</p>
</p>
<p>For populating the grid this code works fine. But i am unable to make the grid editable even by setting the editable:true option.</p>
<p>Can you please help resolve this issue?</p>
</p>
<p>Thanks,</p>
<p>Moin</p></p>
]]></description>
        	        	<pubDate>Tue, 26 Apr 2011 07:39:42 +0300</pubDate>
        </item>
        <item>
        	<title>aarati on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22538</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22538</guid>
        	        	<description><![CDATA[<p>Hi Kiran,</p>
</p>
<p>Which version of struts are you using? What is the&#160;problem that you are facing?</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
]]></description>
        	        	<pubDate>Thu, 24 Mar 2011 05:36:31 +0200</pubDate>
        </item>
        <item>
        	<title>kirangentlebreeze1987 on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22480</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p22480</guid>
        	        	<description><![CDATA[<blockquote>
<p>aarati said:</p>
<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
</blockquote>
<hr />
<p>i do have some problem populating a json object values to my grid&#160;</p>
<p>can you help me???</p></p>
]]></description>
        	        	<pubDate>Sun, 20 Mar 2011 12:14:25 +0200</pubDate>
        </item>
        <item>
        	<title>aarati on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p21560</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p21560</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Finally got it to work <img class="spSmiley" style="margin:0" title="Smile" src="/blog/wp-content/forum-smileys/sf-smile.gif" alt="Smile" />.</p>
<p>Made slight modifications to the existing code:</p>
<p><strong><span style="text-decoration: underline;">Struts Action:</span></strong></p>
<p>1) Earlier was returning to an empty jsp page with no specific code. Now returning null.</p>
<p>2) Using the write method of the jsonObj to write the response data.</p>
<p>The action method now looks like the following:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br /></em></p>
<p><em>System.out.println("Final JSON OBj: " + jsonObj.toString());&#160;</em></p>
<p><em>jsonObj.write(response.getWriter());</em></p>
<p><em>return null;</em><em><br />&#160;}</em></p>
<p><em>&#160;</em></p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p><strong><span style="text-decoration: underline;">JSP:</span></strong></p>
<p>JSP Code to populate the grid is shown below:</p>
<p><em>$(document).ready(function(){<br />$.ajax(<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; type: "POST",<br />&#160;&#160;&#160;&#160;&#160;&#160; <a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a></em><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160; data: "",<br />&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160; success: function(result)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("success");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("result: " + result.total);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list10").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39; &#160;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,</em><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;name&#39;,width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 5,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [5, 10, 20, 50],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160; error: function(x, e)<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert("errorddd " + x.readyState + " "+ x.status +" "+ e); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (x.readyState == 4) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;var response = x.responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;alert(response);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; });<br />setTimeout(function() {$("#list10").jqGrid(&#39;setGridParam&#39;,{datatype:&#39;json&#39;}); },50);<br />});</p>
<p><em>--------------------------------------------------------------------------------------------------------------------------</em></p>
<p>&#160;If any one faces any problem with the above mentioned implementation please post a reply to this topic.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
]]></description>
        	        	<pubDate>Thu, 06 Jan 2011 09:26:14 +0200</pubDate>
        </item>
        <item>
        	<title>aarati on Obtaining JSON object from struts action response</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p21558</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/obtaining-json-object-from-struts-action-response#p21558</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I get an empty grid when trying to obtain a json object from struts action method.</p>
<p>Making use of the following&#160;in the&#160;application:</p>
<p>1) Struts 1.2</p>
<p>2) JQGrid 3.8.2</p>
<p>3) JQuery 1.4.4</p>
</p>
<p>The Struts action method returns a json object after obtaining data from the database. See code below:</p>
<p><em>public ActionForward getJSONData(ActionMapping mapping, ActionForm form,<br />&#160;&#160;&#160;HttpServletRequest request, HttpServletResponse response) {</em></p>
<p><em>&#8230;<br />&#8230;<br />&#160;JSONObject jsonObj = createJSONTestData();<br />&#160;response.setHeader("X-JSON", jsonObj.toString());<br />&#160;System.out.println("Final JSON OBj: " + jsonObj.toString());<br />&#160;return mapping.findForward(sForward);<br />}</em></p>
<p><em>/*<br />&#160; *This piece of code is the same as the php code mentioned in one of the examples<br />&#160; *provided in jqgrid demos<br />*/<br />public JSONObject createJSONTestData() {<br />&#8230;.<br />&#8230;.<br />//Hit the database and obtain the resultset and create the json object</em></p>
<p><em>&#160;JSONObject responcedata=new JSONObject();<br />&#160;net.sf.json.JSONArray cellarray=new net.sf.json.JSONArray();<br />&#160;responcedata.put("total","3&#8243;);<br />&#160;responcedata.put("page",cpage);<br />&#160;responcedata.put("records","2&#8243;);</em></p>
<p><em>&#160;net.sf.json.JSONArray cell=new net.sf.json.JSONArray();<br />&#160;net.sf.json.JSONObject cellobj=new net.sf.json.JSONObject();</em></p>
<p><em>&#160;int i=1;<br />&#160;while(rs.next()){<br />&#160;&#160;cellobj.put("id",rs.getInt(1));<br />&#160;&#160;cell.add(rs.getInt(1));<br />&#160;&#160;cell.add(rs.getString(2));<br />&#160;&#160;cell.add(rs.getString(3));<br />&#160;&#160;cellobj.put("cell",cell);<br />&#160;&#160;cell.clear();<br />&#160;&#160;cellarray.add(cellobj);<br />&#160;&#160;i++;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160; PrintWriter out = response.getWriter();<br />&#160; responcedata.put("rows",cellarray);<br />&#160;&#160;&#160; <br />&#160; return responcedata;</em></p>
<p><em>}</em></p>
<p><em>&#160;</em></p>
<p>The struts-config.xml action forward mapping points to an empty.jsp that has no specific code.</p>
</p>
<p>The jsp file formulates the jqgrid as shown below:</p>
</p>
<p><em>$(document).ready(function(){<br />$("#load_callback1&#8243;).click(function(){<br />jQuery("#list10&#8243;).jqGrid({<br />&#160;</em><a href="/blog/&#39;/PeakAlpha/mutualfund.do?method=getMFTransDetails1&#39;" target="_blank"><em>url:&#39;/TestJSON/testAction.do?method=getJSONData&#39;</em></a><em>,<br />&#160;datatype: "json",<br />&#160;&#160; &#160;colNames:[&#39;Invoice Number&#39;,&#39;Invoice Date&#39;,&#39;Invoice Name&#39;],<br />&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;{name:&#39;id&#39;,index:&#39;id&#39;, id:&#39;id&#39;,width:90},<br />&#160;&#160; &#160;&#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:120},<br />&#160;&#160; &#160;&#160;{name:&#39;invname&#39;,index:&#39;invname&#39;, width:200}<br />&#160;&#160; &#160;],<br />&#160;&#160; &#160;rowNum:10,<br />&#160;&#160; &#160;autowidth: true,<br />&#160;&#160; &#160;rowList:[10,20,30],<br />&#160;&#160; &#160;pager: jQuery(&#39;#pager1&#39;),<br />&#160;&#160; &#160;sortname: &#39;invname&#39;,<br />&#160;&#160;&#160; sortorder: "desc",<br />&#160;&#160;&#160; caption:"JSON Example"<br />}).navGrid(&#39;#pager1&#39;,{edit:false,add:false,del:false});&#160;<br />});<br />});</em></p>
</p>
<p>The grid comes up with no data. A similar example works well with the doGet method of a servlet.</p>
</p>
<p>Questions:</p>
<p>1) How do we obtain the json object returned from a struts action method?</p>
<p>2) Is there any process to be done in the empty.jsp file to handle the response object and obtain the json data?</p>
</p>
<p>Awaiting for a clarification at the earliest. Thank you.</p>
</p>
<p>Regards,</p>
<p>Aarati</p>
]]></description>
        	        	<pubDate>Thu, 06 Jan 2011 07:04:43 +0200</pubDate>
        </item>
</channel>
</rss>