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

Discussion in 'B4J Questions' started by Mashiane, Jan 8, 2019.

  1. Mashiane

    Mashiane Expert Licensed 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.
    joulongleu likes this.
  2. alwaysbusy

    alwaysbusy Expert Licensed 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.
    Mashiane likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    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):
    For i = 1 To 100
    Dim l1 As List
     m.Put(i, l1)
    Mashiane and alwaysbusy like this.
  4. alwaysbusy

    alwaysbusy Expert Licensed 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.
  5. alwaysbusy

    alwaysbusy Expert Licensed User

    Seems like Erels way is the way to go. Before an initialize, one does a dim. No changes needed.
  6. Mashiane

    Mashiane Expert Licensed User

    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.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice