Hi all:
I have a jRDC2 class, with this sub to return a map with 3 keys: "Correcto" (Boolean), "Data" (DBResult), "Message" (string)
So "Respuesta" is a map, and Respuesta.Get("Datos") is a DBResult type: Type DBResult (Tag As Object, Columns As Map, Rows As List)
Well, I have the sub where I receive the data
So, in mapResultados I have a key (TodayDate) with a List of arrays... (or and array of objects I think). I mean, I have every month's day, with none, one, o more items
The log of Log("Resultados: " & mapResultados)
My problem is go through the [[Ljava.lang.Object;@4ef5260, [Ljava.lang.Object;@b3f8319] data.
I want to get this data in this sub
The error I get (I've tried several types for "parte", list, array of list, array of strings...)
Probably the answer is very easy but I'm blocked today...
I have a jRDC2 class, with this sub to return a map with 3 keys: "Correcto" (Boolean), "Data" (DBResult), "Message" (string)
B4X:
Public Sub GetRecord (Command As String, parameters() As String) As ResumableSub
Dim Respuesta As Map
Respuesta.Initialize
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand(Command, parameters)
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
Respuesta.Put("Correcto", j.Success)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(Res As DBResult)
'work with result
'req.PrintTable(res)
Respuesta.Put("Datos",Res)
Respuesta.Put("Mensaje","Se han leído correctamente los datos")
Else
Log("ERROR: " & j.ErrorMessage)
Respuesta.Put("Mensaje","No han leído correctamente los datos, inténtelo más tarde. Error: " & j.ErrorMessage)
End If
j.Release
Return Respuesta
End Sub
So "Respuesta" is a map, and Respuesta.Get("Datos") is a DBResult type: Type DBResult (Tag As Object, Columns As Map, Rows As List)
Well, I have the sub where I receive the data
B4X:
Sub PopulatePartes (Month As Long)
.....
jRDC.Initialize
.....
B4XLoadingIndicator1.Show
Wait For(jRDC.GetRecord("selectParteTrabajo", Parametros)) Complete (Respuesta As Map)
.....
rs = Respuesta.Get("Datos")
...
Dim Datos() As Object
mapResultados.Initialize 'Global map Variable
If rs.Rows.Size > 0 Then
Datos = rs.Rows.Get(0)
.....
listaPartesDia.Add(Datos)
mapResultados.Put(TodayDate, listaPartesDia)
.....
Log("Resultados: " & mapResultados) '<----See logs below
End If
....
For i = 1 To DateUtils.NumberOfDaysInMonth(DateTime.GetMonth(Month), DateTime.GetYear(Month)) 'From day 1 to 31...
....
Dim p As B4XView = CreateItem(color, DiaActual, 300dip)
clvPartesTrabajo.Add(p, expandable.CreateValue(p, DiaActual))
....
Next
B4XLoadingIndicator1.Hide
End Sub
So, in mapResultados I have a key (TodayDate) with a List of arrays... (or and array of objects I think). I mean, I have every month's day, with none, one, o more items
The log of Log("Resultados: " & mapResultados)
B4X:
Resultados: (MyMap) {04/03/2020=[[Ljava.lang.Object;@4ef5260, [Ljava.lang.Object;@b3f8319], 02/03/2020=[[Ljava.lang.Object;@6804c92], 03/03/2020=[[Ljava.lang.Object;@6e14663], 05/03/2020=[[Ljava.lang.Object;@2529fde], 06/03/2020=[[Ljava.lang.Object;@d97e5bf]}
My problem is go through the [[Ljava.lang.Object;@4ef5260, [Ljava.lang.Object;@b3f8319] data.
I want to get this data in this sub
B4X:
Sub CreateItem(clr As Int, Today As String, ExpandedHeight As Int) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clvPartesTrabajo.AsView.Width, ExpandedHeight)
p.LoadLayout("Item")
......
'Add a panel for every job the day has
Dim ListaDatos As List
ListaDatos = mapResultados.Get(DateTime.Date(Today))
If ListaDatos.IsInitialized Then 'If we have jobs for this day
Dim parte As List
For i = 0 To ListaDatos.Size-1
parte = ListaDatos.get(i)
...
lbProyecto.Text = "PROYECTO: " & parte.Get(0)
...
Next
End If
Return p
End Sub
The error I get (I've tried several types for "parte", list, array of list, array of strings...)
B4X:
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.util.List
Probably the answer is very easy but I'm blocked today...