B4J Question [ABMaterial] Calling a page along with parameters

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I am just testing a concept. Here is what I am planning to do

Using B4J and AbMaterial, I will create a Web application
The Web application will have a Login Screen, it validates the user and takes the user to the home page
The above application will be used by the users via any web browsers

I will be calling the same web application from an B4A android app too. In the B4A app, I will be using a WebView and the webview will load the the above ABMAterial application.

Now comes the interesting part

From the android app, I would like to pass the username and password to the ABMaterial Webapp (Webpage)

For eg: the url will be something as follows http://mydomainname:51042/Test/AndroidHomePage?Username=MyUserName&Password=MyPassword

My requirement is that, when the url is invoked from the B4A android app, I don't want the user to be prompted for a username and password, instead it will be passed internally from the B4A Android app to the ABMaterial app secretly. (The user is already validated in the B4A app itself). For those users who access the AbMaterial application directly from Web browsers should be prompted for username and password and then validated.

I do not know, how ABMApplication can handle this ie for some users login page should be there and for some users NO login page. For this to happen, may be I can use 2 different landing pages ie one for Web users and one for B4A app users. In any case, ABMApplication should be aware of the username (either passed as parameters, or the user typed and logged in).

I do not know when I am looking for something impossible ?

Hope that I was able to explain what I am looking for.

Any ideas will be appreciated.
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
You can get those params in Websocket_Connected AFTER 'Dim Session as HttpSession = ABM.GetSession(...':

e.g. http://localhost:51042/template/ComposerPage/?myparam=hallo

log(ws.UpgradeRequest.GetParameter("myparam")) ' logs hallo
I can not get this to work.

My webpage call is:


In Main.AppStart I have:
B4X:
    Server.Initialize("", DonatorKey, "Launch_4_ABM")
    Server.PortSSL = 51043
    'If user needs to login, set to true - CheckLogin() method will be
    'called if user tries to login
    Server.NeedsAuthorization = False
    'First page of app
    Server.StartPage = "Launch_4_ABM_Page"
    Server.CacheScavengePeriodSeconds = 15 * 30 ' 15 minutes
    Server.SessionMaxInactiveIntervalSeconds = 30 * 60 ' 30 minutes
'    Server.UploadFolder = "uploads"
'    Server.UploadMaxSize = 1024 * 1024

In Launch_4_ABM_Page I have:
B4X:
Private Sub WebSocket_Connected(WebSocket1 As WebSocket)
    
    ws = WebSocket1   
    
    PageID = ABM.GetPageID(Page, PageName, ws)
    
    Main.Server.Connected(Me, ws, Page, PageID)
    
    Dim Session As HttpSession = ABM.GetSession(ws, 600)

    Log(ws.UpgradeRequest.GetParameter("myparam"))

'    Log("Connected: " & PageID)
    
End Sub

which is based on code in ABMMini template.

Execution gets to
Log(ws.UpgradeRequest.GetParameter("myparam"))
but nothing appears in log.

I'm assuming I should add something to WebSocket_Connected - but what?

Thanks in anticipation...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top