Hi David,
I tried to print $data = json_decode($rd->getFile('post_file'));
it return NULL..
How to validate post_file.
Thank you,
Abhi.
On Thu, May 28, 2009 at 5:30 PM, <[email protected]> wrote:
> Send users mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.agavi.org/mailman/listinfo/users
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of users digest..."
>
>
> Today's Topics:
>
> 1. Json- problem (abhi p)
> 2. Re: Json- problem (Steffen Gransow)
> 3. Re: Json- problem (David Z?lke)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 28 May 2009 11:29:36 +0530
> From: abhi p <[email protected]>
> Subject: [Agavi-Users] Json- problem
> To: [email protected]
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.agavi.org/pipermail/users/attachments/20090528/d08e6679/attachment.html
>
> ------------------------------
>
> Message: 2
> Date: Thu, 28 May 2009 09:34:14 +0200
> From: "Steffen Gransow" <[email protected]>
> Subject: Re: [Agavi-Users] Json- problem
> To: Agavi Users Mailing List <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi Abhi,
>
> almost correct. IMHO you just missed to return json_encode()'d data.
>
> Just for the record:
>
>
> Rather on top of routing.xml file define the output type changing route:
>
>
> <route pattern="application/json" source="_SERVER[HTTP_ACCEPT]"
> output_type="json" stop="false" />
> ...
> <route name="some_service" patter="^route/to/service$" ... />
>
>
> Then create executeJson() methods in those views, that should return
> content as JSON (and perhaps think about creating a fallback executeJson()
> method in your base views).
>
>
> public function executeJson(AgaviRequestDataHolder $rd) {
> // do something
> return json_encode($data);
> }
>
>
> On clientside:
>
>
> $.getJSON("http://some.host.com/route/to/service", function(data) {
> if (window.console) console.log(data);
> });
>
>
> Maybe helpful resources:
>
> Agavi sample app:
> http://trac.agavi.org/browser/branches/1.0/samples/app/config/routing.xml#L15
>
> User-FAQ entry: http://www.mivesto.de/agavi/agavi-faq.html#routing_7
>
>
> Hope it helps.
>
> Regards,
>
> Steffen
>
> -------- Original-Nachricht --------
> > Datum: Thu, 28 May 2009 11:29:36 +0530
> > Von: abhi p <[email protected]>
> > An: [email protected]
> > Betreff: [Agavi-Users] Json- problem
>
> > 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
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 28 May 2009 13:08:19 +0200
> From: David Z?lke <[email protected]>
> Subject: Re: [Agavi-Users] Json- problem
> To: Agavi Users Mailing List <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> 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
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/pkcs7-signature
> Size: 2474 bytes
> Desc: not available
> Url :
> http://lists.agavi.org/pipermail/users/attachments/20090528/6ec79eb2/attachment-0001.bin
>
> ------------------------------
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.agavi.org/mailman/listinfo/users
>
>
> End of users Digest, Vol 31, Issue 8
> ************************************
>
_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users