B4J Question [ABMaterial] Calling CallSub2 between page.

Harris

Expert
Licensed User
Longtime User
ModalSheets are built on the current (active) ABMPage.

However,
I did a little experiment. I put the BuildModalSheet in ABMShared, and called it like this from the current page ConnectPage.
page.AddModalSheetTemplate(ABMShared.BuildMsgBox( page ))

I have to pass the ABMPage of the current page.

ABMShared sub...
Sub BuildMsgBox(page As ABMPage) As ABMModalSheet
Log(" Built Modalsheet in abmshared")

Dim msgbox As ABMModalSheet
msgbox.Initialize(page, "msgbox", False, False,"")

' and so on...
end sub

This works, the page gets built and is available, BUT what do you do with all the events?
The events (button clicks of the called sheet) must (or should for easy access) belong to the current page.

What do you do with all the elements in the modalsheet you changed? The may be global vars of the current page which don't exist in ABMShared.

The Page_ParseEvent sub handles the events.

B4X:
Sub Page_ParseEvent(Params As Map)
    Dim eventName As String = Params.Get("eventname")
    Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams"))
    If eventName = "beforeunload" Then
        Log("preparing for defects url refresh")
        'ws.session.SetAttribute("ABMNewSession", True)
        ABM.RemoveMeFromCache(ABMShared.CachedPages, ABMPageId)   
       
        Return
    End If
   
    Log("Defects Parse Event: "&Name&"   - "&Params) ' this shows me what events are raised and their params
   
    If SubExists(Me , eventName) Then   '  Me, this page!!!
        Params.Remove("eventname")
        Params.Remove("eventparams")
        Select Case Params.Size
            Case 0
                CallSub(Me, eventName)

          '.... and so on

      End Select
    Else  ' are events in the Shared Module?
       If SubExists(ABMShared , eventName) Then   'ABMShared module...
           
            Log(" sub exists in shared")
                CallSub3(ABMShared, eventName, page, Params.Get(eventParams(0))) ' as a test... , must pass this page...  
          ' this works but very impractical
              
        End If
       End If

If the sheets are simple dialogs, with no input or impact, then a shared code module seems possible.
 
Upvote 0
Top