B4J Question [ABMaterial] How to reload page ?

amminf

Active Member
Licensed User
Longtime User
Do you have a sample where this doesn't work?

Here you are:

B4X:
Sub BuildSelectorClientes(page As ABMPage) As ABMModalSheet


    Dim cSubId As String


    Dim myModal As ABMModalSheet

    myModal.Initialize(page, "inpSelectorClientes", False, False, "modalcontent2")    ' True = FixedFooter
    myModal.Size = ABM.MODALSHEET_SIZE_LARGE
    'myModal.Size = ABM.MODALSHEET_SIZE_FULL
    'myModal.Size = ABM.size
    myModal.Content.UseTheme("modalcontent2")
    'myModal.Footer.UseTheme("modalfooter")
    myModal.IsDismissible = True

    ' Primera fila
    myModal.Content.AddRows(1,True, "").AddCellsOS(6, 0, 0, 0, 2, 2, 2, "")

    'myModal.Content.Cell(1, 1).AddComponent()
    Dim i As Int
    For i= 1 To 20  ' H-V de clientes posibles
        myModal.Content.AddRows(1,True, "").AddCells12(1, "")
    Next
    myModal.Content.BuildGrid 


    Log("creando modal sheet selector de clientes")

    Return myModal
End Sub


Sub MostrarSelectorClientes(page As ABMPage,  aClientesLugar As List, aClientesCentral As List, aClientesLista As List)

    Dim cId     As String        = "inpSelectorClientes"
    Dim myModal     As ABMModalSheet = page.ModalSheet(cId)
    'Dim Content As ABMContainer  = inp.Content
    'Dim pdf     As ABMPDFViewer  = Content.Component("pdf")

    'Log("love el pdf " & cFullPdf)

    'pdf.SetDocument(cFullPdf)
    ''pdf.Refresh


    pageSeleccion = page

    Dim oCon As ABMContainer = myModal.Content ' Aqui ERROR si se entra directamente (soyyo)
    'Dim myModal As ABMModalSheet = inp 

    Dim btnTodo As ABMButton
    btnTodo.InitializeFlat(page, "btnTodo", "", "", "TODOS los clientes", "transparent")
    Dim nTodo As Int = 1
    oCon.Cell(1,1).RemoveAllComponents
    oCon.Cell(1,1).AddComponent(btnTodo) 

    Dim btnSalirApl As ABMButton
    btnSalirApl.InitializeFlat(page, "btnSalirApl", "", "", "Salir", "transparent")

     oCon.Cell(1, 6).RemoveAllComponents
    oCon.Cell(1, 6).AddComponent(btnSalirApl) 

    Dim i As Int
    For i= 0 To aClientesLugar.Size- 1
        Dim msbtn1 As ABMButton
        msbtn1.InitializeFlat(page, "msbtn1SeleccionClientes"& i, "", "", aClientesLista.Get(i), "transparent")
     
        'msbtn1.Size = 200
     
        Dim aList As List
        aList.Initialize
        aList.Add(aClientesLugar.Get(i))
        aList.Add(aClientesCentral.Get(i))
        msbtn1.Tag = aList
     
        oCon.Cell(i+ 1+ nTodo,1).RemoveAllComponents
        'oCon.Cell(i+ 1+ nTodo,1).AddComponent(msbtn1) 
        oCon.Cell(i+ 1+ nTodo,1).AddArrayComponent(msbtn1, "btnSeleccionClientes")
    Next



    page.ShowModalSheet(cId) 


End Sub

Sub SharedbtnSalirApl_clicked(target As String) ' btnSalirApl
    Dim page    As ABMPage       = pageSeleccion
    Dim cId     As String        = "inpSelectorClientes"

    ' page.CloseModalSheet(cId)     


    LogOffReal(page)

End Sub


Sub SharedbtnTodo_Clicked(Target As String)
    Dim page    As ABMPage       = pageSeleccion
    Dim cId     As String        = "inpSelectorClientes"

    lUsrClientesTodos  = True
    lAplClienteDirecto = False   
    cUsrCliLug = Null    ' Por si acaso
    cUsrCliCen = Null    ' Por si acaso

    page.CloseModalSheet(cId)
    RefreshPagePostSeleccion
End Sub

Sub SharedbtnSeleccionClientes_Clicked(Target As String) ', SubTarget As String) ', Target2 As String)
    Dim page    As ABMPage       = pageSeleccion
    Dim cId     As String        = "inpSelectorClientes"
    Dim inp     As ABMModalSheet = page.ModalSheet(cId)

    Log("viendo target " & Target) ' & " - " & SubTarget)

    Dim msbtn1 As ABMButton = inp.content.Component(Target) ' msbtn1SeleccionClientes-N 

    Dim aCodigos As List = msbtn1.Tag


    lUsrClientesTodos  = False  
    lAplClienteDirecto = True   
    cUsrCliLug = aCodigos.Get(0)
    cUsrCliCen = aCodigos.Get(1)


    Log("seleccionado " & cUsrCliLug & " " & cUsrCliCen)



    page.CloseModalSheet(cId)


    RefreshPagePostSeleccion
      
End Sub

Sub RefreshPagePostSeleccion()
    Dim ws As WebSocket = pageSeleccion.ws



    ' << Here you are >> 
        ' This page.Refresh no realoaded page
    page.Refresh


End Sub
 
Upvote 0

mindful

Active Member
Licensed User
I think amminf means that he needs to reload the page (just like he clicks the refresh button in the browser). I didn't search for this but I needed this for a page and what I did is call NavigateToPage method from ABMShared.

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

It did it like this:
B4X:
ABMShared.NavigateToPage(ws, "./")

That code will reload the page (you can see in the log that websocket disconnect and connect events are raised).
 
Upvote 0
Top