Am 23.12.2011 11:38, schrieb nquirynen:
> Ok nevermind, I fixed my problem :) !
>
> Some simplified code of what I've done:
>
> @Inject
> private Request request; // to access GET and/or POST variables
>
> // Event handler method which returns the JSON based on request parameters
> StreamResponse onGetData() {
> return new TextStreamResponse("text/json", buildJson(request));
> }
>
> // to retrieve an url to the event handler
> public String getDataEventLink() {
> return resources.createEventLink("getData").toURI();
> }
Good solution! I think you can leave the TextStreamResponse and return
the JSONObject or JSONArray directly (these are handled by
JSONObjectEventResultProcessor and JSONArrayEventResultProcessor):
JSONObject onGetData() {
return buildJson(request);
}
And you could use @RequestParameter to extract the query parameters (so
you don't have to inject Request:
JSONObject onGetData(@RequestParameter("myparam") String myParam) {
return buildJson(myParam);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]