It's been a month since I used Ofbiz.
I want to use JSON Array sent from Ajax.
How does JAVA handle this?
1. controller.xml
<request-map uri="CRUDList">
                <security https="true" auth="true"/>
                <event type="service" invoke="CRUDList"/>
                <response name="success" type="request" value="json"/>
        <response name="error" type="request" value="json"/>
        </request-map>

2. service.xml
<service name="CRUDList" default-entity-name="TestEntity" engine="java"
auth="true"
        location="com.test.services.TestServices" invoke="CRUDList">
        <attribute name="crudMode" mode="IN" type="String"
optional="false"/>
        <attribute name="data" mode="INOUT" type="java.util.List"
optional="true"/>
    </service>

3. crudList.ftl


4. service.java
public static Map<String, Object> CRUDList(DispatchContext dctx, Map<String,
?> context) {
        Delegator delegator = dctx.getDelegator();
        Map<String, Object> result = ServiceUtil.returnSuccess();
        GenericValue userLogin = (GenericValue) context.get("userLogin");
        
        List<String> reqData = UtilGenerics.checkList(context.get("data"));
        String str = reqData.get(0);
        JSONArray data = new JSONArray();
        data = new JSONArray(str);
...........
}

**result = data.length ==> 1
When I take a JSONARray and size it, it's 1.
I don't know why.
I'd appreciate it if you could explain why.
And then, Please let me know if there is an easier way to use Java by
sending an arraylist to Ajax.



--
Sent from: http://ofbiz.135035.n4.nabble.com/OFBiz-User-f135036.html

Reply via email to