ajax json response

Posted by info@agentur-m3.de on
URL: http://ofbiz.116.s1.nabble.com/ajax-json-response-tp4663982.html

Hello everyone!

Here is a question concerning an ajax request:

<service name="getNext" engine="java"
      location="org.ofbiz.pcomp.pCompServices" invoke="getNext">
    <description>get next</description>
   <!-- <auto-attributes mode="IN" entity-name="pcRating"
include="nonpk" optional="true" /> -->
 <attribute name="pcId" mode="IN" type="String" optional="true" />
 <attribute name="idX" mode="OUT" type="Integer" optional="false" />
 <attribute name="idY" mode="OUT" type="Integer" optional="false" />
</service>

    <request-map uri="getNext">
      <security https="true" auth="true"/>
      <event type="service" invoke="getNext"/>
      <response name="success" type="request" value="json"/>
      <response name="error" type="request" value="json"/>
    </request-map>


The request works fine and gives back correct values for idX and idY.

My question is, if the line
      <response name="success" type="request" value="json"/>

is correct (or if there is an better alternative), because
the return values are not json, but 2 x  plain integer.

The java function implementing the service returns this:

         Map result = ServiceUtil.returnSuccess();
         int idX = 5;
         int idY = 6;
         result.put("idX",idX);
         result.put("idY",idY);
         return result;

So is value="json" formally correct?

Thank you for your help!