Webman-framework

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

About | Overview | Documentation

 

Documentation > Tutorial > 7.1 Entry list page: Automatic code generation

7.1 Entry list page: Automatic code generation

 

Go back to the command prompt window, run the code generator script again, and enter the required initial inputs as follows.

 

The script will give the option to use an existing input settings if the input settings used in the previous code generation for guestbook entry page (section 6.1) is saved. If this is the case just answer "n" as shown below since we want to create new service that is to list guestbook entries entered by the user.

 

When the script ask for database item handling options, choose the option number "1" that's just to list mygb_entry table items and don't apply filter to the item list.

 

Other than the primary key (id_entry_62base), there will be no more fields to be excluded from being displayed as a column in the list view page.

 

At this stage all related resources for mygb_entry table item list operation have been created and updated. Inside the application main link structure, apply the parameter seetings for these new resources into "List Entry" link node that has the link ID of "8".

 

Again, as already mentioned in the previous section (section 6.1), it's advisable to save all previous input settings for productivity reason. If there is later a need to regenerate resources with the exact same specifications, the saved input settings then can be reused by the script. The input settings can autonomously be fed to the script without requiring manual intervention by the developers.

 

As in section 6.1 (guestbook entry page) or every time automatic code generation was accomplished, it's important to have the knowledge on all related resources that have been created or updated by the script. Specific to list entry page code generation of mygb application, there will be new component-type module and coressponded view template files generated as listed below.

E:\wmbase\webman\pm\apps\mygb\mygb_entry_list.pm
E:\wmbase\public_html\cgi-bin\webman\mygb\mygb_entry_list.html

Also check the new content of mygb application main controller module (E:\wmbase\webman\pm\apps\mygb\mygb.pm). The new generated module (mygb_entry_list.pm) should be automatically included inside the main controller module such as shown in line 11 below.
  1 package mygb;                                                           
  2                                                                         
  3 use webman_main;                                                        
  4                                                                         
  5 @ISA=("webman_main");                                                   
  6                                                                         
  7 ### Include new customized application modules next to this line.       
  8                                                                         
  9 #__cust_mod__                                                           
 10                                                                         
 11 use mygb_entry_list;                                                    
 12 use mygb_entry_std_insert;                                              
 13                                                                         
 14 #__cust_mod__                                                           
 15                                                                         
 16 ### Don't remove the above "#__cust_mod__" comments since they are used 
 17 ### by the framework code generator to automatically add/remove modules.
 18 ...                                                                     
 19 ...                                                                     

Next is to check how the script deploys the new generated resources into application main link structure. Inside the ADT's "Link Structure/Reference" page section, view the "Update Reference" sub-section for "List Entry" node as shown below.

 

Click the link of "webman_component_selector" DYNAMIC_MODULE type reference and the setting applied will be displayed as below.

 

Why the new generated "mygb_entry_list" module is referenced by "List Entry" node via "webman_component_selector" DYNAMIC_MODULE type reference and how the integration will work have been already explained in section 6.1 (exactly the same when the script automatically deploys "mygb_entry_std_insert" module reference to "Sign Guestbook" node).

For "mygb_entry_list" module's reference made via "webman_component_selector" DYNAMIC_MODULE type reference, at the "Operation" column click the "Set Param[09]" link. The list of all parameter settings of "mygb_entry_list" module's reference that automatically added by the script should be displayed as below.

 

As shown above, set parameter setting for "default_order_field_selected" parameter name with the value of "3". Click the "Set" button and the new parameter setting will be added as shown below.

 

The new added parameter setting is used to set the default order key-field name(s) to be used to sort the list. Do check the key-field names set via "order_field_name" parameter name and note that they are separated by ":" characters. The "wmf_date_created" order key-field name is the one that becomes the default.

Each entries will record both date and time when they were made thus sorting soley based on date using "wmf_date_created" key-field name is not the precise one. It's preferable to list the entries from the latest to the earliest (based on date and then time). Thus, the list order option should be changed by using the combination of key-field:

"wmf_date_created desc, wmf_time_created desc"

To do this change the value setting for "order_field_name" parameter name as shown below.

 

Click the "Set" button to apply the change. Below is the latest parameter settings of "mygb_entry_list" module's reference that should be displayed by the browser.

 

In order to really understand how the parameter settings could be applied to "mygb_entry_list" module's reference above, we need to first know the parent module it's based on. Do try to open mygb_entry_list.pm module's file and the beginning part of its content should look like below.

  1 package mygb_entry_list;             
  2                                      
  3 use webman_db_item_view_dynamic;     
  4                                      
  5 @ISA=("webman_db_item_view_dynamic");
  6                                      
  7 ...                                  
  8 ...                                  

The new generated "mygb_entry_list" module is actually a child module to "webman_db_item_view_dynamic" component-type module. Read the documentation on webman_db_item_view_dynamic module for more detailed descriptions on how to control the parameter settings of "mygb_entry_list" module's reference.