B4J Question [ABMaterial] [Fixed]ABMTable Click Event Not Captured

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
This is bugging me for the last couple of days (ABMaterial version 4.03):

I have a page (CustActions) with 2 tables. By clicking on the top table (tblworks) the bottom table (tblstages) is filtered. This page works fine. (There are also some more controls for searching and navigating in the top table).

I copy-pasted this page to a new page (OtherPrint), changing only the page name.
Essentially, the 2 pages are identical.
However, in this case, clicking the top table has no effect on the bottom table. The search and navigation controls work OK.

I added a Log(eventname) command in Sub Page_ParseEvent
and noticed that the tblworks_clicked event is not logged in the OtherPrint case (of course it is logged in the CustActions case).

In addition, although the Chrome console shows no error in the CustActions case, the following error is shown in the OtherPrint case:

VM1605:2 Uncaught TypeError: $(...).inputmask is not a function
at eval (eval at b4j_eval (core.4.00.min.js:1), <anonymous>:2:30)
at b4j_eval (core.4.00.min.js:1)
at n.<anonymous> (core.4.00.min.js:1)
at n.dispatchEvent (core.4.00.min.js:1)
at WebSocket.<anonymous> (core.4.00.min.js:1)
 

Attachments

  • CustActions.bas
    19.7 KB · Views: 130
  • OtherPrint.bas
    19.4 KB · Views: 133

Harris

Expert
Licensed User
Longtime User
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    Log("  ----"&Name&" view ws Connected")
    
    ws = WebSocket1
    ABMPageId = ABM.GetPageID( page,  Name, ws)
    Dim session As HttpSession = ABM.GetSession(ws, ABMShared.SessionMaxInactiveIntervalSeconds)
    If session.IsNew Then
        session.Invalidate
        ABMShared.NavigateToPage(ws, "", "./")
        Return
    End If

    ABMShared.NeedsAuthorization = True
    
    If ABMShared.NeedsAuthorization Then
        If session.GetAttribute2("IsAuthorized", "") = "" Then
            ABMShared.NavigateToPage(ws, ABMPageId, "../")
            Return
        End If
    End If
    
    ABM.UpdateFromCache(Me, ABMShared.CachedPages, ABMPageId, ws)
    If page.ComesFromPageCache Then
        ' refresh the page
        page.Refresh
        ' because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL
        page.FinishedLoading
    Else
        If page.WebsocketReconnected Then
            Log("Websocket reconnected")
            ' when we have a client that doesn't have the page in cache and it's websocket reconnected and also it's session is new - basically when the client
            ' had internet problems and it's session (and also cache) expired before he reconnected so the user has content in the browser but we don't have
            ' any on the server. So we need to reload the page.
            ' when a client that doesn't have the page in cache and it's websocket reconnected but it's session is not new - when the client had internet
            ' problems and when he reconnected it's session was valid but he had no cache for this page we need to reload the page as the user browser has
            ' content, reconnected but we have no content in cache
            ABMShared.NavigateToPage (ws, ABMPageId, "./" & page.PageHTMLName)
        Else
            ' when the client did not reconnected it doesn't matter if the session was new or not because this is the websockets first connection so no dynamic
            ' content in the browser ... we are going to serve the dynamic content...
            Log("Websocket first connection")
            page.Prepare
            ConnectPage
        End If
                
    End If

    page.RestoreNavigationBarPosition
    page.NavigationBar.Refresh

    Log(Name &ABMPageId)
End Sub
Generally, the table structure is created in the ConnectPage method. I see you create table headers and such in the Sub WebSocket_Connected...

Doesn't the ConnectPage method fire AFTER Sub WebSocket_Connected ?
 
Last edited:
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    Log("  ----"&Name&" view ws Connected")
  
    ws = WebSocket1
    ABMPageId = ABM.GetPageID( page,  Name, ws)
    Dim session As HttpSession = ABM.GetSession(ws, ABMShared.SessionMaxInactiveIntervalSeconds)
    If session.IsNew Then
        session.Invalidate
        ABMShared.NavigateToPage(ws, "", "./")
        Return
    End If

    ABMShared.NeedsAuthorization = True
  
    If ABMShared.NeedsAuthorization Then
        If session.GetAttribute2("IsAuthorized", "") = "" Then
            ABMShared.NavigateToPage(ws, ABMPageId, "../")
            Return
        End If
    End If
  
    ABM.UpdateFromCache(Me, ABMShared.CachedPages, ABMPageId, ws)
    If page.ComesFromPageCache Then
        ' refresh the page
        page.Refresh
        ' because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL
        page.FinishedLoading
    Else
        If page.WebsocketReconnected Then
            Log("Websocket reconnected")
            ' when we have a client that doesn't have the page in cache and it's websocket reconnected and also it's session is new - basically when the client
            ' had internet problems and it's session (and also cache) expired before he reconnected so the user has content in the browser but we don't have
            ' any on the server. So we need to reload the page.
            ' when a client that doesn't have the page in cache and it's websocket reconnected but it's session is not new - when the client had internet
            ' problems and when he reconnected it's session was valid but he had no cache for this page we need to reload the page as the user browser has
            ' content, reconnected but we have no content in cache
            ABMShared.NavigateToPage (ws, ABMPageId, "./" & page.PageHTMLName)
        Else
            ' when the client did not reconnected it doesn't matter if the session was new or not because this is the websockets first connection so no dynamic
            ' content in the browser ... we are going to serve the dynamic content...
            Log("Websocket first connection")
            page.Prepare
            ConnectPage
        End If
              
    End If

    page.RestoreNavigationBarPosition
    page.NavigationBar.Refresh

    Log(Name &ABMPageId)
End Sub
Generally, the table structure is created in the ConnectPage method. I see you create table headers and such in the Sub WebSocket_Connected...

Doesn't the ConnectPage method fire AFTER Sub WebSocket_Connected ?

Harris, you are partially right:
Indeed, the ConnectPage method is fired by the Sub WebSocket_Connected. In the ConnectPage the Table is initialized and placed in the grid.

However, when ConnectPage finishes, program control is returned back to Sub WebSocket_Connected (where the call to ConnectPage was made).

So, I believe it is OK to create the Headers of the tables in Sub WebSocket_Connected, AFTER ConnectPage has been concluded.
In any case, even if that was a problem, why would it run fine in the CustActions page and not in the OtherPrint page?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Indeed, the ConnectPage method is fired by the Sub WebSocket_Connected.
Only if it is the FIRST connection. As put in the comments, there are cases (reconnection, but the class/page is still in the cache) where it will not run ConnectPage again. I try to have a look to your .bas files in the weekend.
 
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
Only if it is the FIRST connection. As put in the comments, there are cases (reconnection, but the class/page is still in the cache) where it will not run ConnectPage again. I try to have a look to your .bas files in the weekend.
I created a new page, based on the OverviewCases page of the ABMFeedback application, which uses the template without the ConnectPage method.
Only one component is included: a simple table with 2 rows by 3 columns.
I got the same behavior: Click event is not captured and chrome console indicates the same error: Uncaught TypeError: $(...).inputmask is not a function
 

Attachments

  • MiscPrint.bas
    11.9 KB · Views: 125
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
I created a new page, based on the OverviewCases page of the ABMFeedback application, which uses the template without the ConnectPage method.
Only one component is included: a simple table with 2 rows by 3 columns.
I got the same behavior: Click event is not captured and chrome console indicates the same error: Uncaught TypeError: $(...).inputmask is not a function
After this experimentation and AlwaysBusy's feedback, I wondered if the problem had nothing to do with the new page but with the application itself.
I replaced the Main module with an earlier version (although I checked both versions and were identical) and the problem was fixed.
I still, though, have no idea what the cause of the problem was ...
 
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
can you show me your .needs file? This error should have something to do with an editable table, but the inputMask js library is not loaded.
.needs file attached as .txt
Check the MiscPrint (OtherPrint was deleted).
AlwaysBusy, thanks for your input, it helped to guide me towards the fix.
 

Attachments

  • copymewithjarneeds.txt
    5.4 KB · Views: 163
Upvote 0
Top