B4J Question Help me to solve an error with open an B4XPages

universengo

Member
Hello Pro!
I have a project B4xPages with 2 layouts and I have an error when opening an other layout.

B4X:
B4XPage 1:

Private Sub OpenPage2_Click
    Page2.Initialize
    B4XPages.AddPage("Page2", Page2)
    B4XPages.ShowPage("Page2")
End Sub

B4XPage 2:
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once before the page becomes visible.
Private Sub B4XPage_Created(Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Page2")
End Sub

When I open Page 2 that shows me an Error as below (Although before the time I opened normally ):

b4xpagesmanager._createpageifneeded (java line: 311)
java.lang.RuntimeException: java.lang.ClassCastException: b4j.MyProject.b4xtable cannot be cast to anywheresoftware.b4a.ObjectWrapper
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:523)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:469)
at b4j.MyProject.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:311)
at b4j.MyProject.b4xpagesmanager._showpage(b4xpagesmanager.java:726)
at b4j.MyProject.b4xpages._showpage(b4xpages.java:126)
at b4j.MyProject.b4xpage1._openpage2_click(b4xpagecapmoi.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:185)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.ClassCastException: b4j.MyProject.b4xtable cannot be cast to anywheresoftware.b4a.ObjectWrapper
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:191)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:227)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:100)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:101)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:508)
at b4j.MyProject.b4xpage2._b4xpage_created(b4xpage2.java:47)
at b4j.MyProject.b4xpage2.callSub(b4xpage2.java:147)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:498)
... 18 more
 

teddybear

Well-Known Member
Licensed User
The code looks like that it is ok, could you post a small project?
 
Upvote 0

universengo

Member
Thanks all, I fixed this error (because I changed B4XTable to TableView on the frmPage2 form but I couldn't change Delare for it (example: Private Tbv1 as B4XTable -> Private Tbv1 as TableView (OK))
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…