Lightweight, Component-based, and Database-oriented Web Application Framework

About | Overview | Documentation


Documentation > Tutorial > 3. Main view template assignment

Main view template assignment


At this stage, the proposed application's main link structure should be already created under the "Home" link node as folllows.


Click the "Exit" main link to go back to ADT's main page.


At the ADT's main page, for mygb application, click the "Run" link under the "Task" column. The login page for mygb application should be opened in new browser tab as below.


Enter to mygb application as a guest by clicking the "Guest Login" link. The application will display a warning about the problem that the main application's module (mygb.pm) still not assigned with any view template.


The mygb.pm module has inheritance relationships with other framework's modules as follows:








The webman_main.pm module implements customizations into framework's component-type module standard specifications that derived from the webman_CGI_component.pm and CGI_Component.pm modules. Read the documentations on CGI_Component and webman_CGI_component modules to get detailed explanations about the framework's component-type module standard specifications. The customizations redefine webman_main.pm module to become a generic main controller inside accross different applications developed using the framework. Read the documentation on webman_main module to know how the main controller will play its roles within the application.

Based on the above explanations, mygb.pm module is actually the main controller for mygb application. It's the one that will be instantiated inside the application's main CGI script (index.cgi). It also inherit the behaviours of component-type module that applies framework's Convention over Configuration (CoC). Following the framework's CoC, mygb.pm module will by default try to find by itself the view template file named template_mygb.html or mygb.html to be used as its content place-holder.

However, neither one of these template files are exist thus result the warning as the final content output. To resolve this problem developers can create the template file, named it following the proposed naming conventions, and place it inside mygb template directory path (E:\wmbase\public_html\cgi-bin\webman\mygb). Another option is to manually assign the predefined existing template using facilities provided by the ADT. Do browse the content of mygb template directory path and there will be a view template file named template_main.html. The next steps will show how to manually assign the template_main.html view template file to mygb.pm module via its parent module (webman_main.pm).

Move back to browser window/tab for ADT and list the top level link structure of mygb application which are under the "Root" node as below.


Note that "Home" node is just under the "Root" virtual node and has its "Auto Selected" option is set to "YES". When the index.cgi main script is invoked without link node ID information supplied, the "Home" node ID will automatically selected and the service run by the application is the one referred to by the "Home" node. This is exactly what happen when we try to run the application previously. The "Home" node is actually the main entry point to the application thus assigning default main view template for the application should be made start from this particular node.

Under the "Operation" column click "Update Ref.[00]" link for "Home" node. The ADT will display the page that support node's references management for "Home" node as shown below.


Make sure that the "MAIN_CONTROLLER" radio button under the "Reference Type" column is selected and then click the "Add" button under the "Operations" column. The "Home" node should now have the "webman_main" as its single reference as follows.


Each references to link node must be assigned with special unique IDs. These unique IDs can be a signed integer number or a string value without space character. Inside the ADT these unique IDs are in general refered as "Dynamic Content ID" and further sub-categorized to "Num." and "Name". Note that "webman_main" reference of "Home" node above is assigned with number ID "-1" to indicate that it's a special reference to application's main controller.

Click the "Set Param [00]" link of "webman_main" reference and then enter the parameter value for "template_default" parameter name of "webman_main" reference as shown below.


After clicking the "Set" button, "webman_main" reference should now have single parameter name "template_default" set with the value "template_main.html" as follows.


As explained previously, all applications developed using the framework will have their main controller actually a sub-module of "webman_main" component-type module. Developers with OOP experience might think that the above setting will cause all application main controllers will be assigned with the same template file ("template_main.html"). This is not true since the framework embraces database-oriented approach. The parameter setting is actually made at the database table layer and limited to mygb application context. When mygb.pm module is instantiated at the application runtime, it will dynamically implement all parameter settings applied to "webman_main" node's reference based on a query to the database table. Within mygb application itself, this setting only effects "Home" node and its child nodes, not to other nodes which are at the same level with or higher than "Home" node. For flexibility purposes, other nodes under the "Home" node can override this setting by again make a reference to "webman_main" compnent-type module but assign it with different template file name.

At this point, developers should already gained a practical hands-on experience on the concepts of how web application could be mainly constructed from hierarchical connected nodes with the support of component-type module (CBSD) and database-oriented approach. Refresh browser window/tab for mygb application. The main controller should now, without any CGI debug text warning, properly display application content using "template_main.html" view template layout as below.