B4J Question [BANano v6.09/BANanoServer] Issue with SKContainer LoadLayout

LJG

Member
Thank you for the update!
Trying to run BANano v6.09 in the BANanoServer demo. All works fine except it seems that in the BANanoServer environment, we can no longer simply load a layout to a SKContainer like we were able to do before (eg, SKMainContainer.Element.LoadLayout("Template")):

B4X:
Private body As BANanoElement
body.Initialize("#body")
body.Append($"<div id="mainHolder"></div>"$).Get("#mainHolder").LoadLayout("UploadForm")
SKMainContainer.Element.LoadLayout("Template")

This worked before in the BANanoServer demo (as called from the Sub WebSocket_Connected()), but now it doesn't show up in the browser and I get the following error in the web browser console:

browserabout.js:1513 Uncaught TypeError: Cannot read property 'BANll' of null
at _B.websocket_connected (browserabout.js:1513)
at b4j_runFunction (bananocore.js:9)
at p._B._ws.onmessage (browserabout.js:1491)
at HTMLDivElement.<anonymous> (bananocore.js:7)
at WebSocket.s.onmessage (bananocore.js:7)

In JS: _B._skmaincontainer.getelement().BANll(_B.template);

This seems to work fine outside of using BANanoServer. I know that outside of BANanoServer, SKMainContainer.Element.LoadLayout("Template") would be initiated from BANano_Ready(), so I do not know if that is the issue here within the BANanoServer environment (again, this wasn't an issue before v6.09).

Any help in resolving this would be appreciated, thanks.
 

alwaysbusy

Expert
Licensed User
Longtime User
I forgot to check off the AutoID on the SKLabel1 in the UploadForm. I will upload the corrected version later today.

However, as for your problem, I don't see any reference in my demo to:
B4X:
SKMainContainer.Element.LoadLayout("Template")

How is SKMainContainer defined? Is it in another Layout? Is its AutoID = false in the properties in the layout?

As soon as you use it in the code, e.g. by using the Generate Members in the Abstract Designer, AutoID MUST be False.

This is why SKLabel1's AutoID in this demo also must be False: I use it in my code

B4X:
Private SKLabel1 As SKLabel
...
Dim prom As BANanoPromise = BANano.UploadFile(theFile)
prom.Then(Response)
    SKLabel1.Text = "Upload status: " & Response.GetField("status").Result
prom.Else(Response)
    Log(Response)
prom.end

The problem is, if AutoID = True, SKLabel1 is no longer called "SKLabel1" anymore, but maybe something like "zosjnfhl".

So in your case I can only suspect that the AutoID of your SKMainContainer in your Layout is set to True.

If this is not clear, can you upload an example? I may be missing something...

Alwaysbusy
 
Upvote 0
Top