B4J Question Splitview runtime Error

Pelky

Active Member
Licensed User
Longtime User
I have multiple pages created in my main module as follows:-

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Public DBFileDir As String = File.DirApp&"\legals"
    If File.Exists(DBFileDir, "LegalVisits.db") = False Then
        DB.InitializeSQLite(DBFileDir, DBFileName, True)
    Else
        DB.InitializeSQLite(DBFileDir, DBFileName, True)
        If LastException.IsInitialized Then Log(LastException.Message)
        Log("Tables Exist and initialized")
    End If
    Private fx As JFX
    Root.IsInitialized
    MainForm = B4XPages.GetNativeParent(Me)
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("CalendarView")
    Log("CalendarView loaded")
[B]    splitMain.LoadLayout("LeftSide")
    splitMain.LoadLayout("RightSide")[/B]
'    Form1.Title = "Months Calendar View"
    CreateRightSizeLayout
    MainForm.Show

'    Generate_dates
'    LoadData
End Sub

In My Main Module

B4X:
    Private Page2 As B4XSetups
    Private Page3 As B4XTableDays
    Private Page4 As Reporting
    Private Page5 As BookingScreen
    Private Page6 As GateReport
    Private Page7 As GateKeeper
    Private Page8 As InMateCall
    Private Page9 As CalendarView

Page2.Initialize
Page3.Initialize
Page4.Initialize
Page5.Initialize
Page6.Initialize
Page7.Initialize
Page8.Initialize
Page9.Initialize

B4XPages.AddPage("B4XSetups", Page2)
B4XPages.AddPage("B4XTableDays", Page3)
B4XPages.AddPage("Reporting", Page4)
B4XPages.AddPage("BookingScreen", Page5)
B4XPages.AddPage("GateReport", Page6)
B4XPages.AddPage("GateKeeper", Page7)
B4XPages.AddPage("InMateCall", Page8)
B4XPages.AddPage("CalendarView", Page9)
B4X:

Initial Tables Exist and initialized
Initial Tables Exist and initialized
Initial Tables Exist and initialized
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
*** calendarview: B4XPage_Created [mainpage]
Tables Exist and initialized
Mainform loaded

Below is the runtime error which happens on the splitMain.LoadLayout("LeftSide")
If I comment that out the error comes on the next line.....

Error occurred on line: 234 (CalendarView)
java.lang.reflect.InvocationTargetException
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.keywords.Common.CallSubDebug2(Common.java:482)
at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:871)
at b4j.example.b4xpagesmanager._showpage(b4xpagesmanager.java:350)

What I did was create a separate app to test the code and it was fine... i Then copied it into my main app and had to have the
B4XPage_Created (Root1 As B4XView) sub otherwise the page declarations in the main module show an error.

I am quite sure it is something quite simple but I just cant see it.

if anyone can shed some light on my error it would be appreciated
 

Pelky

Active Member
Licensed User
Longtime User
i have to be honest - I have no idea why. What I did was follow a previous example and basically just copied it. However even if I comment out the line i still get the error
 
Upvote 0

Pelky

Active Member
Licensed User
Longtime User
Why are you accessing Form.RootPane? You should load the layout into Root.

B4X:
 MainForm.SetFormStyle("UNIFIED")
The UNIFIED style was removed. This line doesn't do anything.
if I remove that line and replace the loadlayout to:-

Root.LoadLayout("CalendarView")

I get this error :-

*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
*** calendarview: B4XPage_Created [mainpage]
Tables Exist and initialized
Error occurred on line: 232 (CalendarView)
java.lang.reflect.InvocationTargetException
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)
 
Upvote 0

Pelky

Active Member
Licensed User
Longtime User
Just to let you know that I have managed to crack it - It is a worker
I think my problem lay in the Class_Globals - not defined as a split pane and my
splitMaindefined as B4XView

Thank you so much for getting me to relook at the "Why" am I using something.....

Your assistance, as always, is much appreciated.
 
Upvote 0
Top