2.3. Page Output Functions

Page output functions are the bulk of the WebTool API. These functions are used to create HTML tags for form entry, as well as controlling the template system. They are methods of the page object which is an instance of either the WebTool::UI::Std class or the WebTool::UI::Popup class depending on whether the page is a normal page or a popup window. The main differences between the two are header and footer layout and the presence of a menu, programmatically they behave very much the same.

use WebTool::UI::Std;
my $page = new WebTool::UI::Std;

2.3.1. HTML Widget Functions

The WebTool API contains a variety of functions designed to output HTML widgets such as textboxes, selects, checkboxes, and the like. Creation of links and submit buttons is also performed by calling WebTool UI functions, and different functions exist depending on if the link or submit button launches a popup window or not.

These functions can be found in the /lib/WebTool/UI.pm library under your webtool directory.

2.3.2. Templating Functions

The WebTool uses the Perl HTML::Template library to separate code from presentation, and provides methods of the page object to perform template related functions. See Appendix A for links to more information about the HTML::Template library.

use WebTool::UI::Std;
my $page = new WebTool::UI::Std;
my $tmpl_file = "templates/index.tmpl";

$page->set_page_title("My Title");
$page->tmpl_set("sample_var" => "My Value.");


2.3.3. Error Functions

The err method of the page object is used within action CGI scripts (see Section 3.2.3) to launch a javascript popup noting an error and return to the form page that called the action CGI.

my $page = new WebTool::UI::Popup;
my %in = WebTool::UI::process_form();

if (!$in{'required_field'}) { $page->err("The Required Field is required."); }