B4J Question [ABMaterial] Modal and B4JS doesn't work well togheter

Xandoca

Active Member
Licensed User
Longtime User
Hi,

I'm trying to use B4JS for handle user input at a login modal. Everything works fine until I try to get the ABMInput component on HandleLogin sub.
When I try to open the Login Modal after handlelogin was executed, the page freezed for a period, and I got an error on Chrome Dev Console and an error and B4J. Eventually after some time the Login Modal shows up.

Chrome Dev Error:
B4X:
Uncaught TypeError: Cannot read property 'apply' of undefined
    at x.<anonymous> (core.4.38.min.js:1)
    at x.dispatchEvent (core.4.38.min.js:1)
    at WebSocket.<anonymous> (core.4.38.min.js:1)
(anonymous) @ core.4.38.min.js:1
x.dispatchEvent @ core.4.38.min.js:1
(anonymous) @ core.4.38.min.js:1

B4J error:
B4X:
java.util.concurrent.TimeoutException
    at anywheresoftware.b4j.object.WebSocket$SimpleFuture.getValue(WebSocket.java:63)
    at com.ab.abmaterial.ABMInput.getVisibility(Unknown Source)
    at com.ab.abmaterial.ABMInput.RefreshInternal(Unknown Source)
    at com.ab.abmaterial.ABMCell.RefreshInternalExtra(Unknown Source)
    ...

I've identified that the error happens when I try to get the ABMInput (login field): (Line 8 on following code)
B4X:
public Sub HandleLogin(LoginFromPage As String)

    Log(80)
    Dim x As ABMModalSheet = page.ModalSheet("login")
    If page.ws.Session.GetAttribute2("IsAuthorized", "") = "" Then
        Log(90)
        'if the next line is commented problem does not happen
        Dim y As ABMInput = x.Content.Component("logininp1")        '********Here********
    End If

'    '  user was successful in login.  Now navigate to xxx...
    page.CloseModalSheet("login")
End Sub

If that line is commented problem doesn't happen, but also I can't get user login.
If I don't use B4JS everything works fine. But I would like to use it to handle user input directly on browser without overhead the server.

Attached a small project to reproduce the problem.

Below a video showing the problem:

Thank you very much.
 

Attachments

  • Template.zip
    63.4 KB · Views: 131

alwaysbusy

Expert
Licensed User
Longtime User
I'll have to investigate further. Something weird is going on. The good news is there is nothing wrong with your code and the 'Dim y As ABMInput = x.Content.Component("logininp1")' line. The problem starts when you try to open the modalsheet a second time after you've pressed login. For some reason, re-opening a modal with B4JS code tries to run a GetVisibility and GetEnabled on the input field that does not exist (yet). Then a browser error occurs (which halts all javascript execution) and of course your second error in the B4J logs is just because it timeouts waiting for something from the browser.
 
Upvote 0
Top