B4J Question [BANano] [Solved] How do I refresh the page?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I currently have 2 'pages' one created with pgIndex.Init() and another created with pgButtons.Init().
Of course, this is all happening on an single 'index.html' page.

I have two buttons on each of the pages, one to run pgIndex.Init() and another to run pgButtons.Init(), these replace the #body and attach events to buttons.

pgIndex.Init() is the only method on _Ready as it is the starting 'page'

I'm working on a simpler example that I will upload. Thanks.
 

alwaysbusy

Expert
Licensed User
Longtime User
I think your code is correct: it is just you assume a list.initialize or map.initialize does clear the list/map, while now it does not. (I did't know B4J did that, I never had the need for a re-initialize in my projects and just always used a .clear there instead).

Currently, BANano will need a .clear after an initialize. I can make that automatically in the next update so it behaves like B4J.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
(I did't know B4J did that, I never had the need for a re-initialize in my projects and just always used a .clear there instead).
List in B4J is a "wrapper" object. The native list is created when you call Initialize. I don't know how it behaves in BANano however the recommended way in B4X to create a new object is with dim + initialize (when there is an initialize method):
B4X:
For i = 1 To 100
 Dim l1 As List
 l1.Initialize
 m.Put(i, l1)
Next
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
I will test this. I prefer to mimic B4J behaviour as much as possible and then the automatic clear in initialize will not be needed. One just has to dim and initialize again, just like in B4J.
I have taken your advise and added a .Clear method and everything works well now as in the B4J grid project. (There I didn't need to run .Clear after .Initialize) .The lists and maps were defined in class_globals and only initialized once in the Initialize sub of the class. I think going forward whether i'm in b4j or not, I just need to clear my lists and maps after <map>.Initialize.
 
Upvote 0
Top