Hi,
Thank you very much, it works well.

El Wednesday, June 2, 2021 a la(s) 8:25:10 PM UTC-5, Shai Almog escribió:

> In JSON [] means array or list and {} means object or map. So you do have 
> a list of maps in the jSON which is what you see in Java.
>
> Sorry it wasn't clear but I means java.util.List not 
> com.codename1.ui.List. If you fix your import the code I posted above 
> should work.
>
> On Wednesday, June 2, 2021 at 6:06:04 AM UTC+3 [email protected] wrote:
>
>> Hi,
>>
>> In with a JSON validator on the internet I put the URL that I am using:
>>
>> http://3.12.118.139:8091/scriptcase/app/tempus/blank_ws_autenticar/blank_ws_autenticar.php?usuario=demo1&contrasena=123
>>
>> I was able to verify that the ws is working well as the validation 
>> resulted in:
>> [ { "usuario_id":"17", "usuario":"demo1", "nombre_empresa":"Embutidora 
>> Nacional", "impuesto":"7", "menu_id":"1", "dispositivo_id":"4", 
>> "lee_huella":"1", "imei":"55555", "numero_telefono":"64237770", "correo":"
>> [email protected]", "nombre":"Usuario Embutidos", "radio":"300", 
>> "fuente_inventario":"A", "permite_cambiar_foto":"1", "inicio_sesion":"1", 
>> "rango_inicio":"100001", "rango_fin":"150000", "secuencia_orden":"100054", 
>> "estado":"A", "token":"0a5b3d4a-5b8f-443d-af8e-cfb4100b71c4" }]
>>
>> For some reason that I do not understand, I am resiving it as a list and 
>> therefore my problem must be with the client. The method to receive is:
>>  
>> public static void login(Idioma idioma, String usuario, String 
>> contrasena, final SuccessCallback<Usuario> onSuccess, final 
>> FailureCallback<Object> onError) {
>>           Rest.get(SERVER_URL + 
>> "blank_ws_autenticar/blank_ws_autenticar.php").
>>                 acceptJson().
>>                 queryParam("contrasena", contrasena).
>>                 queryParam("usuario", usuario).
>>                 getAsJsonMapAsync(new Callback<Response<Map>>() {
>>
>>                     @Override
>>                     public void onSucess(Response<Map> value) {
>>                         usr = new Usuario();
>>                         PreferencesObject.create(usr).bind();
>>                         
>> usr.getPropertyIndex().populateFromMap(value.getResponseData());
>>
>>                         onSuccess.onSucess(usr);
>>                     }
>>
>>                     @Override
>>                     public void onError(Object sender, Throwable err, int 
>> errorCode, String errorMessage) {
>>                         onError.onError(null, err, errorCode, 
>> errorMessage);
>>                     }
>>                 });
>>       }
>>
>> I appreciate you pointing out what I'm doing wrong.
>> Thanks
>>
>>
>> El Tuesday, June 1, 2021 a la(s) 9:01:21 PM UTC-5, [email protected] 
>> escribió:
>>
>>> Hi,
>>>
>>> Return error in List entries = (List)responseMap.get("data");
>>>
>>> java.lang.ClassCastException: class java.util.ArrayList cannot be cast 
>>> to class com.codename1.ui.List (java.util.ArrayList is in module java.base 
>>> of loader 'bootstrap'; com.codename1.ui.List is in unnamed module of loader 
>>> com.codename1.impl.javase.ClassPathLoader @5d5eef3d)
>>> at com.innova507.server.UsuarioService$1.onSucess(UsuarioService.java:84)
>>> at com.innova507.server.UsuarioService$1.onSucess(UsuarioService.java:68)
>>> at 
>>> com.codename1.io.rest.RequestBuilder$6.actionPerformed(RequestBuilder.java:582)
>>> at 
>>> com.codename1.io.rest.RequestBuilder$6.actionPerformed(RequestBuilder.java:567)
>>> at 
>>> com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
>>> at 
>>> com.codename1.ui.util.EventDispatcher.access$100(EventDispatcher.java:45)
>>> at 
>>> com.codename1.ui.util.EventDispatcher$CallbackClass.run(EventDispatcher.java:95)
>>> at com.codename1.ui.Display.processSerialCalls(Display.java:1365)
>>> at com.codename1.ui.Display.edtLoopImpl(Display.java:1307)
>>> at com.codename1.ui.Display.mainEDTLoop(Display.java:1189)
>>> at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
>>> at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
>>>
>>> El Tuesday, June 1, 2021 a la(s) 8:45:43 PM UTC-5, Shai Almog escribió:
>>>
>>>> Hi,
>>>> It's a bit hard to read in this way but it looks like the server 
>>>> returns a list of users. 
>>>> So you would need something like this:
>>>> Map responseMap = value.getResponseData();
>>>> List entries = (List)responseMap.get("data");
>>>> usr.getPropertyIndex().populateFromMap((Map)entries.get(0));
>>>>
>>>> On Tuesday, June 1, 2021 at 6:49:12 AM UTC+3 [email protected] wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> In debug the value value.getResponseData () is:
>>>>> [image: Muestra.png]
>>>>> I have "*usuario*" class that implements PropertyBusinessObject to 
>>>>> receive interaction "0" (see image).
>>>>>
>>>>> When I try to receive the fields from the class they are in null (  
>>>>> *usr.getPropertyIndex().populateFromMap(value.getResponseData())*;  ).
>>>>>
>>>>> Thanks
>>>>>
>>>>> El Monday, May 31, 2021 a la(s) 8:45:59 PM UTC-5, Shai Almog escribió:
>>>>>
>>>>>> Hi,
>>>>>> It's hard to tell. Is the printout of data related to 
>>>>>> value.getResponseData()?
>>>>>> What are the fields of User?
>>>>>> How does it fail? Is the user object not set?
>>>>>> If you step over it with a debugger is it set for a short while? 
>>>>>>
>>>>>> On Monday, May 31, 2021 at 7:14:58 PM UTC+3 [email protected] wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am trying to consume a webservice using the restful API. It 
>>>>>>> correctly returns the information I request:
>>>>>>>
>>>>>>> data => [{usuarioid=17, usuario=demo1, nombreempresa=Embutidora 
>>>>>>> Nacional, impuesto=7, menuid=1, dispositivoid=4, leehuella=1, 
>>>>>>> imei=55555, 
>>>>>>> [email protected], nombre=Usuario Embutidos, radio=300, 
>>>>>>> fuenteinventario=A, permitecambiarfoto=1, iniciosesion=1, 
>>>>>>> contrasena=202cb962ac59075b964b07152d234b70, rangoinicio=100001, 
>>>>>>> rangofin=150000, secuenciaorden=100054, estado=A, 
>>>>>>> token=0a5b3d4a-5b8f-443d-af8e-cfb4100b71c4}]
>>>>>>>
>>>>>>> To consume I do the following:
>>>>>>>
>>>>>>> public static void login(Idioma idioma, String usuario, String 
>>>>>>> contrasena, final SuccessCallback<Usuario> onSuccess, final 
>>>>>>> FailureCallback<Object> onError) {  
>>>>>>>         Rest.get(SERVER_URL + 
>>>>>>> "blank_ws_autenticar/blank_ws_autenticar.php").
>>>>>>>                 acceptJson().
>>>>>>>                 queryParam("contrasena", contrasena).
>>>>>>>                 queryParam("usuario", usuario).
>>>>>>>                 getAsJsonMapAsync(new Callback<Response<Map>>() {
>>>>>>>
>>>>>>>                     @Override
>>>>>>>                     public void onSucess(Response<Map> value) {
>>>>>>>                         usr = new Usuario();
>>>>>>>                         PreferencesObject.create(usr).bind(); 
>>>>>>>                        * 
>>>>>>> usr.getPropertyIndex().populateFromMap(value.getResponseData())*;
>>>>>>>                         onSuccess.onSucess(usr);
>>>>>>>                     }
>>>>>>>
>>>>>>>                     @Override
>>>>>>>                     public void onError(Object sender, Throwable 
>>>>>>> err, int errorCode, String errorMessage) {
>>>>>>>                         onError.onError(null, err, errorCode, 
>>>>>>> errorMessage);
>>>>>>>                     }
>>>>>>>                 });
>>>>>>>     }
>>>>>>>
>>>>>>> I cannot pass the information through the property "populateFromMap"
>>>>>>> What is the correct way to do it?
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/0bcb62d3-bbb6-431f-87bf-52b96d9b77f8n%40googlegroups.com.

Reply via email to