B4J Question [ABMaterial] refresh ABMCodeLabel text from another module

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Log on a web-page:
Sub Update_Log
    txtSysLog.Text = others.Get_Log
    txtSysLog.Refresh
End Sub

If i call this sub from this web-page class - it's OK. The log is filled from any other app codes...but if to start some background work with filling the log, and call the sub from other module - ABMCodeLabel cannot be updated on the web-page, error at "txtSysLog.Refresh" is:
Waiting for debugger to connect...
Program started.
DB inited
loading /home/scat-learning/tempjars: copymewithjar.needs...
Using cache
Error occurred on line: 234 (dbgen)
java.lang.NullPointerException
at com.ab.abmaterial.ABMCodeLabel.RefreshInternal(ABMCodeLabel.java:85)
at com.ab.abmaterial.ABMCodeLabel.Refresh(ABMCodeLabel.java:79)
at peacemaker.sc4grabber.dbgen._update_log(dbgen.java:114)
at peacemaker.sc4grabber.vtkdb._buttest_clicked(vtkdb.java:969)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~e:
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:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor1.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)
~e:
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:513)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:468)
at peacemaker.sc4grabber.abmserver._page_parseevent(abmserver.java:284)
at peacemaker.sc4grabber.vtkdb._page_parseevent(vtkdb.java:2615)
~e:
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:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
~e:
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~e:
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
~e:
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
~e:
at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:142)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
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)
~e:
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
~e:
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4j.object.JServlet.createInstance(JServlet.java:81)
at anywheresoftware.b4j.object.BackgroundWorkersManager$1.run(BackgroundWorkersManager.java:40)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
~e:
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
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.raiseEvent(BA.java:98)
at anywheresoftware.b4j.object.JServlet.createInstance(JServlet.java:81)
at anywheresoftware.b4j.object.BackgroundWorkersManager$1.run(BackgroundWorkersManager.java:40)
~e:
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
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)
~e:
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at peacemaker.sc4grabber.main.main(main.java:29)
FTP_connected

But why ?

dbgen is web-page with ABMCodeLabel, and its update is called from vtkdb module.
 
Last edited:

MichalK73

Well-Known Member
Licensed User
Longtime User
I think you need to have a module like Class. In this class, place the Initialization where you provide the ABMPage of the calling class. Additionally, of course, the ABM library because it contains ABMLabel. Then in such a class you can create a Public Sub that will display the string via ABMLabel and such a component will return to the calling module.
With something like this, any other module will be able to connect to this class and call the string change function in ABMLabel.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It seems, trying to call any sub in an ABM webpage class - depends on "Page_ParseEvent" sub of the webpage that has such errors.
I could solve this situation only by a timer updating the ABMCodeLabel independently inside the webpage.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
But I said that your Label should be in a separate Class module and then it can be used from different modules.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
And you can't check something takeigo. Put in ABMShared
B4X:
Sub changelabel(page As ABMPage, id_label As String, value As String)
    Dim label As ABMLabel = page.Component(id_label)
    label.Text = value
    label.Refresh
End Sub

Then you can call

B4X:
ABMShared.changelabel(page, "mylabel", "new value for label")
 
Upvote 0
Top