Hello Abhi,the problem is that the data is transmitted as a JSON structure by the JQuery Grid plugin. Output types are only for *encoding output*, not for *decoding input*.
An implementation of so-called input types to alleviate this issue is scheduled for Agavi 1.1. However, it's a very difficult task since you inevitably run into a certain chicken-and-egg-situation. Granted, the JSON example is fairly trivial in that you'd typically just need to run a json_decode() on the POST data, but if you have, say, an XML API with different schemas for each operation, then you cannot simply "decode" the XML during the framework/request startup - instead, the Controller/Action needs to supply information on how to decode the data properly. This, though, means that request data needs to be decoded quite late in the game, hooks need to be in place, validation and security need to be taken into account etc - certainly no easy task.
The quickest workaround I can offer for now is reading and decoding the POST data (containing the JSON string) though Agavi's default request data file that is created if the submitted content is not of urlencoded content type:
$data = json_decode($rd->getFile('post_file'));
Keep in mind that you need to validate the file in order to access it.
I hope that works for your specific situation. If the Action/View also
works via regular GET/POST calls, then I'm afraid for now you need to
separate out the code to handle it properly. Another alternative would
be to create a new context definition just for these "json" calls
where a very simple subclass of AgaviWebRequest would decode POSTed
JSON data in startup() using the necessary checks (and then set the
key/value pairs into request data parameters).
I should be able to pick up work on the input types implementation again very soon. The implementation currently in SVN works, but has potential security implications and various other drawbacks that unfortunately cannot be adressed in any other way than by starting over from scratch :(
Hope that helps. Let us know if you need any further help with this. - David On 28.05.2009, at 07:59, abhi p wrote:
Hi list,I am using jquery grid to display records and do some operations on the records.This grid will post some data like page, sortname etc. But i am not able to get the data posted by json.Here is my code in side view public function executeJson( AgaviRequestDataHolder $rd) { $page = $rd->getParameter('page'); $sortname = $rd->getParameter('sortname'); . . . } routing.xml<route name="#" pattern="/json" output_type="json" stop="false" source="_SERVER[HTTP_ACCEPT]" />Please help me to resolve this issue. Regards, Abhi _______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
