B4J Question ABMaterial 5.12 NavigateTo strange issue (SOLVED)

walterf25

Expert
Licensed User
Longtime User
Hi all, I need some help trying to figure out an issue I am seeing after updating my ABMaterial binary files to 5.12 version.

Basically I have a project with two pages, the home page and a createnewaccount.html page, sometimes when I restart the project I can see on my browser the page connecting and disconnecting, this happens back and forth and I can see in the B4J logs that the websocket gets connected and disconnected, I had never seen this before, I have to stop the project and re-start it a few times before the page actually shows up without any issues.

The main issue I'm having is that I have a label on the home page that when users will click on it will take them to the ../CreateAccount/newaccount.html page, the problem is that when I click on the label I can see on the url bar that the address changes from "localhost:51046/demo/home" to "localhost:51046/demo/CreateAccount/newaccount.html" page as it should but only for half a second then it switches back to "localhost:51046/demo/home" and it never actually shows the /demo/CreateAccount/newaccount.html page.

If I open a new tab and go directly to the "localhost:51046/demo/CreateAccount/newaccount.html" page then the page shows up just fine.

Is there anything I may be missing since the last updates on this library or this a bug?

Please advise.

Just tried running the demo project with the 5.12 version and the www folder of the same version and I started seeing the same issue, seems to be a bug? trying to figure out how to record a small video to better explain the issue.

Just a quick update, I decided to go back to version 4.3, and I do not see this issue on this version, I also tried version 5.0 which apparently it's the official version but also that version has the same issue. But verson 4.3 has some missing functionalities that the newest versions have.

Thanks.
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Look here: https://www.b4x.com/android/forum/t...ge-problem-b4j-9-8-abm-5-0.141870/post-949915

Remove the ws.flush line at the bottom if it is there
It looks like it's the ws.close line that needs to be removed or commented out.
B4X:
Public Sub NavigateToPage(ws As WebSocket, PageId As String, TargetUrl As String) 'ignore   
    Dim testTargetUrl As String = TargetUrl
    If Not(testTargetUrl.EndsWith(".htm") Or testTargetUrl.EndsWith(".html") Or testTargetUrl.EndsWith("/")) Then
        TargetUrl = TargetUrl & "/"
    End If
    Log("navigating to page: " & TargetUrl)
    If PageId.Length > 0 Then ABM.RemoveMeFromCache(CachedPages, PageId)
    If ws.Open Then
        ' it doesn't keep navigation history in the browser (the back button exists the application)
        ws.Eval("window.location.replace(arguments[0])", Array As Object(TargetUrl))
        ' if you need browser history just comment the lines above and uncomment the lines below
        ' it keeps the navigation history in the browser
        '''ws.Eval("window.location = arguments[0]", Array As Object(TargetUrl))
        ws.Flush
        '''ws.Close ' ALSO NEW 4.00   
        ' note that this error can be ignored anyway
        ' if you are bothered by the warning error you get with this close, you can try to replace it with this:
        Sleep(50)
        If ws.Open Then
            Log("closing the websocket, in case the eval does not do it...")
            ws.Close ' ALSO NEW 4.00
        End If
    End If   
End Sub

But thanks for the tip.
 
Upvote 0
Top