Author Topic: Composer - Problem with a List from WebService  (Read 5188 times)

Offline wcahuana

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Composer - Problem with a List from WebService
« on: June 15, 2011, 09:27:19 PM »
Hello everyone!! I have a webService and a backend, y try to a prompt a list of users from the webService.
The connection whit the service go perfect , I use de Var0 and Var1 for the list, the webservice return me the list, and y try to catch with a backendJSP , and this is my code
[CODE]<%@page language="java" contentType="application/json" pageEncoding="UTF-8"%>
<%!
// Implement this method to execute some server-side logic.
public JSONObject performLogic(JSONObject state, Map<String, String> additionalParams) throws Exception {

String variable[] = {state.getString("Var0")};
String variable2[] = {state.getString("Var1")};
//ArrayList<String> listacod = new ArrayList();
//ArrayList<String> listanom = new ArrayList();
JSONObject result= new JSONObject();
try{

    for(int i=0;i<=variable.length;i++){
    for(int a=0;a<=variable2.length;a++){   
    String codigo = variable[i];
    String nombre = variable2[a];
    result.put("co_usua",codigo);
    result.put("no_usua",nombre);
    return result;
    }
    }
}catch(Exception e){
e.printStackTrace();

}
 
return result;
   
};
%>
<%-- GENERATED: DO NOT REMOVE --%>
<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONException"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@include file="../include/backend.jspf" %>[/CODE]

But the prompt only say's "Object Object".
Any idea or similar example? :(

Thanks

Offline Anahuac

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Composer - Problem with a List from WebService
« Reply #1 on: December 02, 2011, 07:43:38 PM »
Use the looping block:
This is like a "For" in programation.
You can join this block with the prompt block.
You must declare a variable in the looping , for example : VarCount.
And in the prompt block you can put something like this:
'FileOfSounds/' + VarArray[VarCount] + '.vox'
If the array value is {1,2,3,4}

The result was like

FileOfSound/1.vox
FileOfSound/2.vox
FileOfSound/3.vox
FileOfSound/4.vox


Regards

Offline msh

  • Newbie
  • *
  • Posts: 30
  • Karma: 1
Re: Composer - Problem with a List from WebService
« Reply #2 on: December 06, 2011, 11:34:49 AM »
this kind of thing is easier if you use a program like JSON Viewer (http://jsonviewer.codeplex.com) to see the JSON object.