B4J Tutorial [BANanoWebix] Creating Multi-Page Apps - Part 2

Discussion in 'B4J Tutorials' started by Mashiane, Jul 22, 2019.

  1. Mashiane

    Mashiane Expert Licensed User

    Ola

    Part 1 of this lesson looked at how we could create the shell skeleton of our app i.e. the various pages of our app that will host the different sections we need to build.

    We created two pages, one for cities and one for positions. In this part we will use the Form Builder/Designer to create the underlying BANanoSQL database, the cities table and also the positions table.

    The positions table has 3 fields, id (int), value (string) and color (string) and the
    cities table has 2 fields, id (int) and value (string).



    We are using the form designer because we want to have crud functionality for both these tables and this is done by the BWFD easily.
     
  2. Mashiane

    Mashiane Expert Licensed User

    In the global definition, we have our BANanoSQL defined.

    Code:
    Private ourclients As BANanoSQL
    In BANano_Ready, we open the backend database and create the respective tables if they dont exist.

    Code:
    Sub BANano_Ready()
        ourclients.OpenWait(
    "ourclients""ourclients")
        
    Dim newTable As Map = CreateMap()
        newTable.put(
    "id","INT")
        newTable.put(
    "value","STRING")

        
    'initialize the helper class
        Dim alaSQL As BANanoAlaSQL
        alaSQL.Initialize
        
    'generate the create table sql
        Dim rs As AlaSQLResultSet = alaSQL.CreateTable("cities", newTable, "id")
        
    'execute the create table command
        rs.Result = ourclients.ExecuteWait(rs.query, rs.args)
        
        
    Dim newTable As Map = CreateMap()
        newTable.put(
    "color","STRING")
        newTable.put(
    "id","INT")
        newTable.put(
    "value","STRING")

        
    'initialize the helper class
        Dim alaSQL As BANanoAlaSQL
        alaSQL.Initialize
        
    'generate the create table sql
        Dim rs As AlaSQLResultSet = alaSQL.CreateTable("positions", newTable, "id")
        
    'execute the create table command
        rs.Result = ourclients.ExecuteWait(rs.query, rs.args)
    We also ensure that the database variable is defined in all the modules that we will use it.

    For now we park the CRUD code generated by the form designer. We need to first create the UX for both the cities and the positions and then link the generated code so that our records are saved, read, updated and deleted whenever we want.

    Ta!
     
    joulongleu likes this.
Loading...
  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