B4J Question [ABMaterial] Request for testing 2.16 (2016/12/07)

alwaysbusy

Expert
Licensed User
Longtime User
Hi all,

Mindful and I have been working on a better system for the reconnecting system. We did take a step back and tried a completely different approach to the problem, as we had the feeling for every 'fix' we did, another 'problem' appeared.

I have updated the demo (http://abmaterial.com) and the feedback app with the new system so if you find some time, can you play a bit with it on some different devices and report issues you may find?

Thank you!

Alwaysbusy
 

Harris

Expert
Licensed User
Longtime User
I am just "testing" some problems that I encountered in other ide/frameworks/applications and report to Alain so he can make this framework unique (this is not only a framework for the web it's also for the server itself since the next version will cache your active data(page) independently from the server session - and you will be able to setup the cache variables to suit your needs or you production needs.

No expert you say? Anyone who has knowledge of other frameworks and understands these issues (from statement above) is well beyond my novice level. We can, if you wish, settle on "well informed". Anyways, thanks for helping all of us out.

In the past 4 hours, I have accomplished many difficult web-app programming challenges with ease.
How?
Because this dev environment makes it so easy!!! Pitty the poor foos (Mr. T from the "A Team" series) that don't get this (or have yet to find this)...
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Hi all,

Can I ask you guys again if you could run your tests (now with 2.16).

http://abmaterial.com

and

http://81.165.232.188:8080/feedback/

In this version you'll be able to set the 'life-time' of a page in cache. Both demos are set to 30 minutes, so you should be able to 'disconnect' for 30 minutes and it should act as if nothing happened when you reconnect. Longer than 30 minutes would simply result in restarting the app.

Code is simplified a lot, and much safer (you may notice Page_ready is completely gone):
B4X:
'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 = "ABMPageTemplate"  '<-------------------------------------------------------- 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

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 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
     ' refresh the page
     page.Refresh
     ' Tell the browser we finished loading
     page.FinishedLoading
   Else
     ' Prepare the page
     page.Prepare
     ' load the dynamic content
     ConnectPage
   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"))
   If eventName = "beforeunload" Then
     Log("preparing for url refresh")  
     ABM.RemoveMeFromCache(ABMShared.CachedPages, ABMPageId)  
     Return
   End If
   If SubExists(Me, eventName) Then
     Params.Remove("eventname")
     Params.Remove("eventparams")
     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
End Sub

public Sub BuildTheme()
   ' start with the base theme defined in ABMShared
   theme.Initialize("pagetheme")
   theme.AddABMTheme(ABMShared.MyTheme)
  
   ' add additional themes specific for this page
  
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 = ""
   page.PageDescription = ""
   page.PageKeywords = ""
   page.PageSiteMapPriority = ""
   page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
  
   page.ShowConnectedIndicator = True
    
   ' adding a navigation bar
  
      
   ' create the page grid
   page.AddRows(2,True, "").AddCells12(1,"")
   page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    
End Sub

public Sub ConnectPage()
'   connecting the navigation bar
    
  
'   init all your own variables (like a List, Map) and add your components

'   page.Cell(1,1).AddComponent(ABMShared.BuildParagraph(page, "lbl", "This is a test"))
'  
'   Dim btn As ABMButton
'   btn.InitializeRaised(page, "btn", "", "", "Press me", "")
'   page.Cell(2,1).AddComponent(btn)
  
   ' refresh the page
   page.Refresh
   ' Tell the browser we finished loading
   page.FinishedLoading
   ' restoring the navigation bar position
   page.RestoreNavigationBarPosition
End Sub

' 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

Thanks for the feedback!

Alain
 
Last edited:
Upvote 0

amminf

Active Member
Licensed User
Longtime User
ABMaterial.com v2.16 running very well on:

  1. Mozilla Firefox, Opera and Chrome Windows desktop browsers
  2. Chrome and stock browser on Android 4.4.2 (Samsung Galaxy 3 Neo)
Congrats
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Pages seem to pop on screen! Nice!

Page ready gone? I guess I shall have to move all from ready into connectpage()?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Page ready gone? I guess I shall have to move all from ready into connectpage()?
Yes, this is acually what you'll need to do. I prepared a document describing the procedure and I used this document to convert over 10 web apps in an hour or two this morning. It's a matter of cutting & pasting really. I'm happy to hear my efforts seem to bear fruit. :) Again, it has been great to toss ideas back and forth with Mindful. You can see we did quite some trials (v2.03 -> 2.16) over the last weeks :confused:
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
In this version you'll be able to set the 'life-time' of a page in cache. Both demos are set to 30 minutes, so you should be able to 'disconnect' for 30 minutes and it should act as if nothing happened when you reconnect. Longer than 30 minutes would simply result in restarting the app.

I have been out of each app for hours... Yet it is still active in a browser tab.
When will it expire and force me to login again? Does 'disconnect' mean close the tab and before 30 mins expire - it will bring me to same page?

I would like to force users off (kill the ws) after x mins and require they log back in. Currently, (2.03) after many hours have expired, you hit a button or whatever and nothing happens - until you click the page refresh in the browser. Then it brings you back to where you were - but doesn't enforce a new login...

Many other apps I use, after some inactivity time - require you to re-authenticate when you try to access the app.

Just an observation...

Thanks
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I have been out of each app for hours... Yet it is still active in a browser tab.
Yes, as long as your are able to reach the server (has an active internet connection), a heartbeat is send from the browser to keep the session 'Alive'. The 30 minutes is the minimum life-time.

The login is saved in the Local Storage, so even when you close the browser, it still knows it. You will have to build in a timer to remove it from the local storage after some time (maybe using one of the new BackgroundWorkers Erel introduced in jServer 2.70).

At this point the ABMShared.LogOff() method could be called.

An alternative could be saving it in the Session, but then the user will have to enter his credentials every time he comes on your page.

EDIT: I'm talking 2.16 here...
 
Upvote 0
Top