B4J Question [ABM] Problems with display of modal sheets on small screens.

Rob White

Member
Licensed User
Hi all,
Back on the third of Sept. I posted some images of a problem I was having.
I have the same screen issues with the following code, is there someone out there which can look at the code and tell me where I am going wrong.
Thanks in advance.

Code for the modal sheet creation.:
' Triggered by the Select icon on the SprayDataPage

Sub Process_Globals
    Private ABM As ABMaterial
    Private Page As ABMPage
    Dim ChemTypeCbo As ABMCombo
    Dim ChemTbl As ABMTable
End Sub

Sub BuildmsSelectStock(pg As ABMPage) As ABMModalSheet
    Page = pg
    Dim MS As ABMModalSheet
    
    MS.Initialize(pg,"msselectstock",True,ABM.MODALSHEET_SIZE_NORMAL,"mytheme")
    MS.Content.AddRows(1,True,"").AddCellsOS(1,0,0,0,6,6,6,"").AddCellsOS(1,0,0,0,4,4,4,"")
    MS.Content.AddRows(1,True,"").AddCellsOS(1,0,0,0,12,12,12,"")
    MS.Content.UseTheme("modalcontent")
    
    MS.Footer.AddRows(1,True,"").AddCellsOS(1,0,0,0,5,5,5,"").AddCellsOS(1,1,1,1,3,3,3,"")
    MS.Footer.BuildGrid
    MS.Footer.SetFixedHeight("10px")
    MS.Footer.UseTheme("modalfooter")
    
    MS.Size = ABM.MODALSHEET_SIZE_LARGE
    MS.IsDismissible = True
    MS.MaxWidth = "100%"
    MS.MaxHeight = "100%"
    MS.Content.BuildGrid
    MS.IsDismissible = True
    
    Dim Title As ABMLabel
    Title.Initialize(pg,"Title","Testing modal sheet",ABM.SIZE_H6,False,"mytheme")
    MS.Content.Cell(1,1).AddComponent(Title)

    ChemTypeCbo.Initialize(pg,"chemtypecbo","Type of chemical",300,"mytheme")
    
    ChemTypeCbo.SetActiveItemId("0")
    MS.content.Cell(1,2).AddComponent(ChemTypeCbo)

    ChemTbl.Initialize(pg,"chemlist",True,False,True,"mytheme")
    ChemTbl.IsResponsive=True
    ChemTbl.SetHeaders(Array As String ("ID","Chemical", "Stock no","Qty left"))
    ChemTbl.SetColumnWidths(Array As Int(1,300,100,80))
    ChemTbl.SetColumnVisible(Array As Boolean (False,True,True,True))
    MS.Content.Cell(2,1).AddComponent(ChemTbl)

    Dim Gbut As ABMLabel
    Gbut.Initialize(pg,"Flab","Double tap/click to select.",ABM.SIZE_H6,False,"mytheme")
    MS.Footer.Cell(1,1).AddComponent(Gbut)
    FillTable
    Return MS
End Sub

public Sub FillTable
    Dim Row As List
    Row.Initialize
    ChemTbl.Clear
    For i = 0 To 6
        Dim labName As ABMLabel
        Dim labStkNo As ABMLabel
        Dim labBal As ABMLabel
        labName.Initialize(Page,"name"&i, "Product"&i,ABM.SIZE_H6,False,"mytheme")
        labStkNo.Initialize(Page,"stkno"&i, "StockNo"&i,ABM.SIZE_H6,False,"mytheme")
        labBal.Initialize(Page,"bal"&i, i*4,ABM.SIZE_H6,False,"mytheme")
        labName.Clickable=True
        labName.VerticalAlign=True
        Row.Clear
        Row.Add("ID&i")
        Row.Add(labName)
        Row.add(labStkNo)
        Row.Add(labBal)
        ChemTbl.AddRowFixedHeight("R"&i,Row,10)
    Next
    
    ChemTbl.Refresh
End Sub

The page code:
'Class module
Sub Class_Globals
    Private ws As WebSocket 'ignore
    ' will hold our page information
    Public page As ABMPage
    ' page theme
    Private theme As ABMTheme
    ' to access the constants
    Private ABM As ABMaterial 'ignore   
    ' name of the page, must be the same as the class name (case sensitive!)
    Public Name As String = "tstMS"  '<-------------------------------------------------------- IMPORTANT
    ' will hold the unique browsers window id
    Private ABMPageId As String = ""
    ' your own variables   
    
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
    ' build the local structure IMPORTANT!
    BuildPage       
End Sub

#Region ABM
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)   
    Log("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
        
    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
        ' when we have a page that is cached it doesn't matter if it comes or not from a new connection we serve the cached version.
        Log("Comes from cache")       
        page.Refresh       
        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
    Log(ABMPageId)       
End Sub

Private Sub WebSocket_Disconnected
    Log("Disconnected")
End Sub

Sub Page_ParseEvent(Params As Map)
    Dim eventName As String = Params.Get("eventname")
    Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams"))
    
    'log(eventName)
    
    If eventName = "beforeunload" Then
        Log("preparing for url refresh")
        ABM.RemoveMeFromCache(ABMShared.CachedPages, ABMPageId)
        Return
    End If
    Dim caller As Object = page.GetEventHandler(Me, eventName)
    If caller = Me Then
        If SubExists(Me, eventName) Then
            Params.Remove("eventname")
            Params.Remove("eventparams")
            If eventName = "page_dropped" Then
                page.ProcessDroppedEvent(Params)
            End If
            Select Case Params.Size
                Case 0
                    CallSub(Me, eventName)
                Case 1
                    CallSub2(Me, eventName, Params.Get(eventParams(0)))
                Case 2
                    If Params.get(eventParams(0)) = "abmistable" Then
                        Dim PassedTables As List = ABM.ProcessTablesFromTargetName(Params.get(eventParams(1)))
                        CallSub2(Me, eventName, PassedTables)
                    Else
                        CallSub3(Me, eventName, Params.Get(eventParams(0)), Params.Get(eventParams(1)))
                    End If
                Case Else
                    ' cannot be called directly, to many param
                    CallSub2(Me, eventName, Params)
            End Select
        End If
    Else
        CallSubDelayed2(caller, "ParseEvent", Params) 'ignore
    End If
End Sub

public Sub BuildTheme()
    ' start with the base theme defined in ABMShared
    theme.Initialize("pagetheme")
    theme.AddABMTheme(ABMShared.MyTheme)

    ' add your specific page themes
    
End Sub

public Sub BuildPage()
    ' initialize the theme
    BuildTheme
    
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = "Test"
    page.PageDescription = "Template"
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
        
    page.ShowConnectedIndicator = True
                
    ' adding a navigation bar
    ' ABMShared.BuildNavigationBar(page, "My Page","../images/logo.png", "", "", "")   
            
    ' create the page grid
    page.AddRowsM(2,True,20,0, "").AddCells12MP(1,0,0,0,0,"")   
    
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components       
End Sub

public Sub ConnectPage()           
    '    connecting the navigation bar
    ' ABMShared.ConnectNavigationBar(page)
    
    page.AddModalSheetTemplate(msSelectStock.BuildmsSelectStock(page))

    Dim butAddMS As ABMButton
    butAddMS.InitializeRaised(page,"butaddms","","","Show modal sheet","")
    
    page.Cell(1,1).AddComponent(butAddMS)
    ' refresh the page
    page.Refresh
    
    ' Tell the browser we finished loading
    page.FinishedLoading
    ' restoring the navigation bar position
    page.RestoreNavigationBarPosition   
End Sub

Sub butaddms_clicked(Tar As String)
    page.ShowModalSheet("msselectstock")
End Sub
#end region

#Region ABMPage
' clicked on the navigation bar
Sub Page_NavigationbarClicked(Action As String, Value As String)
    ' saving the navigation bar position
    page.SaveNavigationBarPosition
    If Action = "LogOff" Then
        ABMShared.LogOff(page)
        Return
    End If

    ABMShared.NavigateToPage(ws, ABMPageId, Value)
End Sub

Sub Page_DebugConsole(message As String)
    Log("---> " & message)
End Sub
#end region
 

Rob White

Member
Licensed User
Thanks AlwaysBusy that corrected the display problem. The underlying page is not active (does not respond to any touches what so ever)! I have tried a page.refresh in the page_modalsheetdismissed event to no avail.
Any suggestions on that one?
 
Upvote 0

Harris

Expert
Licensed User
As for ABMTables on small devices, I agree with @alwaysbusy - responsive sucks! If your table cell number is small (will fit on a portrait screen without horizontal scrolling) then ABMTable responsive = false (default), then it will work fine. However this is rarely the case for me.
I switched to ABMCustomCard on small devices, which granted, is more work - but the outcome is much more pleasing / useful.
I think I wrote a tut / snippet on this but my memory often fails me...
 
Upvote 0

Harris

Expert
Licensed User
Upvote 0
Top