Re: Getting acknowledgment for an AJAX request
Thanks. Will try this. ManiKanta
RE: Getting acknowledgment for an AJAX request
You can process the json response using yui plugins.There is a module called ConnectionManager in yui using that you can invoke your json action class as shown below var mySource = new DataSource('some/some/example.action?'); below is yui link. http://developer.yahoo.com/yui YAHOO.util.Event.onDOMReady(function () { var DataSource = YAHOO.util.DataSource, DataTable = YAHOO.widget.DataTable, Paginator = YAHOO.widget.Paginator; var mySource = new DataSource('some/some/example.action?'); mySource.responseType = DataSource.TYPE_JSON; mySource.responseSchema = { resultsList : 'records', fields : ['id','userName','status'], metaFields : { totalRecords: 'totalRecords' // The totalRecords meta field is // a "magic" meta, and will be passed // to the Paginator. } }; -Original Message- From: ManiKanta G [mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2008 10:17 AM To: Struts Users Mailing List Subject: Re: Getting acknowledgment for an AJAX request > As I said, the JSON plugin would be a good starting point. > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html Thanks. I've experimented with the JSON and I m able to return a JSON string, but was not able to process that in the jsp. How I m going to process the JSON in jsp? Do I need to write javascript for it? Regards, ManiKanta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting acknowledgment for an AJAX request
> As I said, the JSON plugin would be a good starting point. > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html Thanks. I've experimented with the JSON and I m able to return a JSON string, but was not able to process that in the jsp. How I m going to process the JSON in jsp? Do I need to write javascript for it? Regards, ManiKanta
Re: Getting acknowledgment for an AJAX request
ManiKanta G wrote: Thanks Laurie, If all you need to return is a number or true/false, simply write that to the response in your action method and return null what do you mean writing to response? You mean using response.xxx methods? or some thing else? More or less, yes: write your response data directly to the response output stream, as in response.getOutputStream.write(...). The bottom line is that, once you understand what it is you want to return (a number, a boolean, a JSON data structure, etc.) the means by which you generate that response are up to you. Understand what the response ought to look like first, *then* worry about what your options are for generating it. well I want to return the number of records got updated successfully and/or the number of records failed to update. And please tell me what if I want to get these two values same time. I think for this JSON is the way. If yes, can you point out some resource to head. correct me if I m wrong. As I said, the JSON plugin would be a good starting point. http://cwiki.apache.org/S2PLUGINS/json-plugin.html L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting acknowledgment for an AJAX request
Thanks Laurie, If all you need to return is a number or true/false, simply write that to > the response in your action method and return null what do you mean writing to response? You mean using response.xxx methods? or some thing else? The bottom line is that, once you understand what it is you want to return > (a number, a boolean, a JSON data structure, etc.) the means by which you > generate that response are up to you. Understand what the response ought to > look like first, *then* worry about what your options are for generating it. well I want to return the number of records got updated successfully and/or the number of records failed to update. And please tell me what if I want to get these two values same time. I think for this JSON is the way. If yes, can you point out some resource to head. correct me if I m wrong. ManiKanta
Re: Getting acknowledgment for an AJAX request
ManiKanta G wrote: Hi, I m practicing AJAX in S2. And in response to my previous mail, Dave replied That's what Ajax does (loosely speaking): returns HTML fragments (or data as JSON, XML, etc.). That's the point of it--so you don't have to return entire pages and refresh the entire window. So, If I want to acknowledge some AJAX request (say, '2 new records has been added') I just needed the count of how many rows got inserted/updated successfully or a flag indicating the success or failure of the request. And for this I m sure I don't need to return a jsp. How can be this done? through JSON? if yes, can some one point me to some resource to learn using JSON in S2? If all you need to return is a number or true/false, simply write that to the response in your action method and return null (so Struts knows not to try executing any other results for the request). For more complex response data, the JSON plugin would be a good starting place. There's nothing stopping you from generating the response with a JSP, either, it's just not usually the easiest thing to do for an Ajax response. The bottom line is that, once you understand what it is you want to return (a number, a boolean, a JSON data structure, etc.) the means by which you generate that response are up to you. Understand what the response ought to look like first, *then* worry about what your options are for generating it. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Getting acknowledgment for an AJAX request
Hi This has lot of info about sending ajax requests http://developer.yahoo.com/yui/ -Original Message- From: ManiKanta G [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 23, 2008 4:03 PM To: Struts Users Mailing List Subject: Re: Getting acknowledgment for an AJAX request > Please check http://www.roseindia.net/ajax well I didn't find any thing. More over site speaks about regular AJAX there. Can some tell me how to do that in S2. I mean JSON or some other. Regards, ManiKanta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting acknowledgment for an AJAX request
> Please check http://www.roseindia.net/ajax well I didn't find any thing. More over site speaks about regular AJAX there. Can some tell me how to do that in S2. I mean JSON or some other. Regards, ManiKanta
RE: Getting acknowledgment for an AJAX request
hi, Please check http://www.roseindia.net/ajax Thanks -Original Message- From: ManiKanta G [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 23, 2008 3:41 PM To: Struts-User Subject: Getting acknowledgment for an AJAX request Hi, I m practicing AJAX in S2. And in response to my previous mail, Dave replied > That's what Ajax does (loosely speaking): returns HTML fragments (or data as JSON, XML, etc.). That's the point of it--so you don't have to return entire pages and refresh the entire window. > > So, If I want to acknowledge some AJAX request (say, '2 new records has been added') I just needed the count of how many rows got inserted/updated successfully or a flag indicating the success or failure of the request. And for this I m sure I don't need to return a jsp. How can be this done? through JSON? if yes, can some one point me to some resource to learn using JSON in S2? Thanks in advance ManiKanta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]