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

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.
 

Mashiane

Expert
Licensed User
Longtime User
In the global definition, we have our BANanoSQL defined.

B4X:
Private ourclients As BANanoSQL

In BANano_Ready, we open the backend database and create the respective tables if they dont exist.

B4X:
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!
 
Top