Documentation > Modules and APIs > webman_main
Description: Component type module that inherits webman_CGI_Component module. It acts as a main controller for web applications developed using the framework. It's not directly used but inherited by application's main module. The application's main module is the actual one that instantiated inside application's main CGI script. Being a generic module of main controller inside applications, webman_main module provides the basic logical structure and facilities to dynamically compose other components to build up a complete system. The logical structure is actually the control mechanisms that are in tandem with component's specifications as explained in CGI_Component and webman_CGI_component. The facilities are functions to support framework's concepts and its development strategies to provide most generic, semi-complete design of web applications that are mainly constructed from hierarchical connected nodes implemented as HTML links structure and heavily rely on database. Support from database technology not limited to domain problem content but further extended to application's logic control elements.
Dependencies: Webman-framework's Core Modules:
1. View Template The view template assigned to webman_main type modules normally is the main template of the application. Below is an example of most simple main template proposed by the framework.
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <!-- start_view_ //--> <table border="1" width="100%"> <tr> <td> <div align="center"><h2>$app_name_ Application Header</h2></div> <div align="right"><b>You are login as:</b> $user_full_name_ </div> </td> </tr> <tr height="30"> <td align="center"> <!-- dynamic_content_ name=link_main //--> </td> </tr> <tr> <td align="center" valign="top"> <br /> <!-- dynamic_content_ name=content_main //--> </td> </tr> <tr height="30"> <td align="center"> Copyright © 2010 - $current_year_ Your organization name. </td> </tr> </table> <div id="popup_div_onmove" class="popup" onMouseOut="popup_hide(this);"> </div> <div id="popup_div_onclick" class="popup_onclick"> </div> <!-- end_view_ //--> </body> </html>
Inside the above template file the paired type template tags <!-- start_view_ //--> and <!-- end_view_ //--> are used to mark the parts of template content that will be processed by the application's main module (the main controller). The single dynamic type template tags <!-- dynamic_content_ name=link_main //--> and <!-- dynamic_content_ name=content_main //--> with different tags names are used as a placeholders for other dynamic contents generated by other sub controllers (components). The main controller not only used to compose other application's components but also to associate them with these particular content placeholders. The simple tags $app_name_, $user_full_name_, and $current_year_ are referring to scalars that only exist and available inside the main controller to facilitate developers to easily print out basic information of application inside the main template page.
2. Instantiation and Basic Parameter Setting The passed arguments $cgi and $db_conn are other Webman-framework core modules instances. The $cgi is an instance of GMM_CGI module and the $db_conn is an instance of database connection created using DBI module.
my $component = new webman_main; $component->set_CGI($cgi); $component->set_DBI_Conn($db_conn);
3. Component-type Generic Function Calls Other generic functions to be called following Webman-framework specificatons to run the module as a framework's component. There is no access control applied since its run as a main controller for the application.
### Set component specific parameters from database table. Overrides the ### original one from the parent (webman_CGI_component) to fulfill its roles ### as main controller. $component->set_Module_DB_Param; $component->run_Task; $component->process_Content; $component->end_Task; my $content = $component->get_Content;
|Copyright © 2012, Mohd Razak Samingan, Faculty of Computer Science & Information System, Universiti Teknologi Malaysia.|