B4J Question [ABMaterial] No items showing in combo control

stanmiller

Active Member
Licensed User
Longtime User
I'm having trouble getting combo box items to display in the list. I've added items but the list is still empty in the browser.

Any ideas?

1_combo_no_data.jpg


B4X:
'*--------------------------------------------------------------- ConnectPage
'*
Sub ConnectPage()

    ABMShared.ConnectNavigationBar(page)

    page.Cell(1,1).UseTheme("cellWB")
    page.Cell(2,1).UseTheme("cellWB")
    page.Cell(3,1).UseTheme("cellWB")
    page.Cell(4,1).UseTheme("cellWB")
    page.Cell(5,1).UseTheme("cellWB")

    page.Cell(1,1).AddComponent(ABMShared.BuildParagraph(page, "p1", "1. First row" ))
    page.Cell(2,1).AddComponent(ABMShared.BuildParagraph(page, "p2", "2. Second row" ))
    'page.Cell(3,1).AddComponent(ABMShared.BuildParagraph(page, "p3", "3. Third row" ))

    Dim combo1 As ABMCombo
    combo1.Initialize(page, "combo1", "Category", 650, "")
    combo1.IconName = "mdi-action-account-circle"

    ' add items
    combo1.AddItem("combo1S1", "Aggregate", BuildSimpleItem("S1", "", "{NBSP}{NBSP}Aggregate or Sand"))
    combo1.AddItem("combo1S2", "Decorative", BuildSimpleItem("S2", "", "{NBSP}{NBSP}Decorative Gravel"))
    combo1.AddItem("combo1S3", "Soil", BuildSimpleItem("S3", "", "{NBSP}{NBSP}Soil"))
    combo1.AddItem("combo1S4", "Mulch", BuildSimpleItem("S4", "", "{NBSP}{NBSP}Mulches, Compost, Soil"))

    ' Add combo
    page.Cell(3,1).AddComponent( combo1 )

    page.Cell(4,1).AddComponent(ABMShared.BuildParagraph(page, "p4", "4. Fourth row" ))
    page.Cell(5,1).AddComponent(ABMShared.BuildParagraph(page, "p5", "5. Fifth row" ))

    page.Refresh ' IMPORTANT

    ' NEW, because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL
    page.FinishedLoading 'IMPORTANT

End Sub

'*----------------------------------------------------------- BuildSimpleItem
'* 
Sub BuildSimpleItem(id As String, icon As String, Title As String) As ABMLabel
    Dim lbl As ABMLabel
    If icon <> "" Then
        lbl.Initialize(page, id, Title, ABM.SIZE_H6, True, "header")
    Else
        lbl.Initialize(page, id, Title, ABM.SIZE_H6, True, "")
    End If
    lbl.VerticalAlign = True
    lbl.IconName = icon
    Return lbl
End Sub
 

stanmiller

Active Member
Licensed User
Longtime User
This problem appears to be caused by a dirty browser cache.

Here the combo is functioning correctly. Items are displayed and Chrome reports successful navigation.

1_abm_combo_items_shown.jpg


Below the class and page were renamed to ABMPageTemplate1 and the combo is now empty. Chrome reports an error.

2_abm_combo_items_missing.jpg


This occurred while I had the cache disabled through the Chrome debugger. After clearing the cache, exiting all browser windows, and restarting Chrome the combo box began working under ABMPageTemplate1

Of the controls I'm using ( input, label, button, and combo box ) the only control failing is the combo control. I can change the name of the page (and class), colors, grid layout, and so forth and everything updates without needing to clear the cache or exit.

I've also seen the symptom on an iPad (iOS 9.3.2) running Safari. Like Chrome, clearing the Safari cache and exiting all instances, then restarting Safari corrected the issue.

I'm using ABM 2.00
 
Last edited:
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This error means the combo library is not loaded. I've made a fix for this in the next release. In the meantime if this happens, add page.NeedsCombo = true to the BuildPage() method as a workaround.

Also, you should use the AppVersion variable in ABMShared. It tries to force a reload of the libraries every time YOU restart your jar file (not every time the user goes to your webapp).

in Sub Process_Globals:
B4X:
Public AppVersion As String = DateTime.Now

In case you haven't used the AppVersion variable:
B4X:
Public Sub NavigateToPage(ws As WebSocket, TargetUrl As String)   
   If AppVersion <> "" Then
     TargetUrl = TargetUrl & "?" & AppVersion  '<---
   End If
   If ws.Open Then       
     ws.Eval("window.location = arguments[0]", Array As Object(TargetUrl))       
   End If
End Sub
 
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
This error means the combo library is not loaded. I've made a fix for this in the next release. In the meantime if this happens, add page.NeedsCombo = true to the BuildPage() method as a workaround.

Also, you should use the AppVersion variable in ABMShared. It tries to force a reload of the libraries every time YOU restart your jar file (not every time the user goes to your webapp)....

Thanks! I will put this in straight away.

Here's another combo related question:
https://www.b4x.com/android/forum/threads/abmaterial-combo-items-overlap-navigation-menu.72698/
 
Upvote 0
Top