B4J Question B4XPages / Error java.lang.RuntimeException: Object should first be initialized (B4XView) when try to update a value

christianjeannot

Member
Licensed User
Hello Community,

I have again trouble with an App where I use multiple pages and try to update values.

I am using this code to initiate the update .

B4X:
Private Sub B4XPage_Disappear
    'ManageProfilePage = B4XPages.GetPage("ManageProfile Page")
    Log($"txtNumberNumber.Text = ${txtNumberNumber.Text}"$)
    Log($"txtNumberCount.Text = ${txtNumberCount.Text}"$)
    ManageProfilePage.UpdateNumber
End Sub

I am using this code to update the values.

B4X:
Public Sub UpdateNumber
    NumberProfilePage = B4XPages.GetPage("NumberProfile Page")
    Log($"Actual lblNumber : ${lblNumber.Text}"$)
    Log($"Number from Text Field: ${NumberProfilePage.txtNumberNumber.Text}"$)
    Log($"Count Text Field: ${NumberProfilePage.txtNumberCount.Text}"$)
    lblNumber.Text = NumberProfilePage.txtNumberNumber.Text
    lblNumberCount.Text = NumberProfilePage.txtNumberCount.Text
End Sub

I got the following error

B4X:
Error occurred on line: 621 (B4XManageProfilePage)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getNodeObject(B4XViewWrapper.java:120)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getText(B4XViewWrapper.java:318)
    at b4j.B4XDicy.b4xmanageprofilepage._updatenumber(b4xmanageprofilepage.java:1615)
    at b4j.B4XDicy.b4xnumberprofilepage._b4xpage_disappear(b4xnumberprofilepage.java:143)
    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:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:487)
    at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:434)
    at b4j.B4XDicy.b4xpagesmanager._raiseeventwithresult(b4xpagesmanager.java:628)
    at b4j.B4XDicy.b4xpagesmanager._mainform_closed(b4xpagesmanager.java:473)
    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:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:216)
    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)

Line 621 is

B4X:
Log($"Actual lblNumber : ${lblNumber.Text}"$)

I do not understand why.

lblNumber is defined in Sub Class_Globals

B4X:
Public lblNumber As B4XView

I tried this part in a small helper app. Here it works properly. I tested several ways to update the values and all worked.
What do I miss?

Best regards

--Christian
 

christianjeannot

Member
Licensed User
@Erel
No, I am adding it only with AddPage.

The "page flow" is
mainpage -> manage profile page -> number page -> back to manage profile page

The error come up when I go back from number page to manage profile page.

From my understanding the layout should be there as I already was working on and with the manage profile page.
 
Upvote 0

christianjeannot

Member
Licensed User
I checked the booklets and searched the forum but was not able to find information how to do that exactly.
Can someone please provide a link where I can read further about page event logging.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can someone please provide a link where I can read further about page event logging.
To enable the PagesEvents add
B4X:
        B4XPages.GetManager.LogEvents = True
 
Upvote 0
Top