B4J Question [SOLVED] ABMMini - 2 pages - how to programmatically go from 1 to the other?

JackKirk

Well-Known Member
Licensed User
Longtime User
Using ABMMini as a base.

I have set up 2 pages:
Start_Page
Launch_4_ABM_Page

In Process_Globals I have:
B4X:
Sub Process_Globals
    
    ...    (normal stuff)
    
    Public myPage1 As Start_Page
    Public myPage2 As Launch_4_ABM_Page

End Sub

There is html and javascript in Start_Page module that creates a simple trigger that when fired calls the following code in Start_Page module:
B4X:
Sub Start_Instance_NextPage(value As Map)
    Private nextPageID As String = ABM.GetPageID(Main.myPage2.page, Main.myPage2.PageName, ws)
    Log(nextPageID)
    Private nextPageHTML As String = Main.myPage2.page.PageHTMLName
    Log(nextPageHTML)
    'Load next page
    Main.Server.NavigateToPage(ws, nextPageID , nextPageHTML)
End Sub

Log(nextPageID) produces:
Launch_4_ABM_Pagef27cacf4-2f57-454f-aaf4-bcbee5c4acc7

Log(nextPageHTML) produces:
Launch_4_ABM.html

When the code is fired the statement
Main.Server.NavigateToPage(ws, nextPageID , nextPageHTML)
does not load the second page.

I'm thinking I need to embellish the nextPageHTML parameter somehow in the above statement but am out of ideas.

Any and all suggestions welcome.
 

JackKirk

Well-Known Member
Licensed User
Longtime User
Alain has suggested:

...but the call should be something like:

B4X:
Main.Server.NavigateToPage(ws, ABMPageId, "../SecondPage")

Where ABMPageID is the PageID of the page you are leaving and the TargetUrl the path to the page you want to go to

With this clue and some further fiddling the solution is:
B4X:
Sub Start_Instance_NextPage(value As Map)
    Private nextPageName As String = Main.myPage2.PageName
    Private nextPageHTML As String = Main.myPage2.page.PageHTMLName
    'PageID is set in WebSocket_Connected
    'Load next page
    'Main.Server.NavigateToPage(ws, PageID , "../Launch_4_ABM_Page/Launch_4_ABM.html")
    Main.Server.NavigateToPage(ws, PageID , "../" & nextPageName & "/" & nextPageHTML)
End Sub

Many thanks Alain...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…