I want to send a list containing map from b4j to Java and use it (Preferably use b4xmap)
Sample code on the b4x side
Sample code on the b4x side
B4X:
Dim bodylist As List
bodylist.Initialize
Dim bodymap As Map
bodymap.Initialize
bodymap.Put("id","10")
bodymap.Put("name","testname10")
bodymap.Put("price","10000")
bodylist.Add(map1)
Log(myclass.testlist(bodylist))
java code:
public static String testlist(ArrayList cars){
for(int i= 0; i< cars.size(); i++) {
anywheresoftware.b4a.objects.collections.Map map1 = new anywheresoftware.b4a.objects.collections.Map();
map1.Initialize();
map1= (Map) cars.get(i);
return map1.Get("id").toString() + map1.Get("name").toString()+map1.Get("price").toString();
}
return null;
}
Error:
Waiting for debugger to connect...
Program started.
1712928404207
Error occurred on line: 99 (Main)
java.lang.ClassCastException: class anywheresoftware.b4a.objects.collections.Map$MyMap cannot be cast to class anywheresoftware.b4a.objects.collections.Map (anywheresoftware.b4a.objects.collections.Map$MyMap and anywheresoftware.b4a.objects.collections.Map are in unnamed module of loader 'app')
at mypackage.TaxApiSDKV1.testlist(TaxApiSDKV1.java:489)
at b4j.example.main._button1_click(main.java:238)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)