You can also do a json response directly from the called service, but you'll
need the response object, so call it as an event instead of a service.  Once
you get the response object, the rest is easy (jsonString is the json
formatted string you want to return to the browser):

        //Skip System.out.println("Sending Jason response String " + 
jsonString);
        response.setContentType("application/x-json");
        try
        {
            response.setContentLength(jsonString.getBytes("UTF-8").length);
        } catch (UnsupportedEncodingException e) {
            response.setContentLength(jsonString.length());
        }

        Writer out;
        try {
            out = response.getWriter();
            out.write(jsonString);
            out.flush();
        } catch (IOException e) {
            Debug.logError(e, "Failed to get response writer", module);
            result = "error";
        }


-----Original Message-----
From: Nandani Aggarwal [mailto:[email protected]]
Sent: Tuesday, July 03, 2012 9:20 PM
To: [email protected]
Subject: Re: Response from java Method to client - Ajax call


If you want to call another java method on basis of responses you get then
you may use :

<response name="success" type="request" value="JAVA_METHOD_NAME" />

<handler name="java" type="request"
class="org.ofbiz.webapp.event.JavaEventHandler" />


Thanks
Nandani

On Tue, Jul 3, 2012 at 11:51 PM, Robert G. <[email protected]> wrote:

> what does that do? How can I handle the response in the ajax callback?
>
> --
> View this message in context:
>
http://ofbiz.135035.n4.nabble.com/Response-from-java-Method-to-client-Ajax-c
all-tp4634402p4634411.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Reply via email to