Finally, we can show a page to the browser (or chart or ajax or whatever you want) the way this is done is via a "view object".
A view object is simply something that
has a new(), create() and display() method.
With new() being the constructor and create() being a sort of "mini constructor".
The reason for having two of them is that your view implementation may choose to cache information (such as compiled subroutines). Because of this, new() is only invoked once, giving you the opportunity to set things up.
Each time a view is needed, the create() method is called (with a request) allowing you to set up any request-specific bits. (Possibly stashing them in the request's pad() area for later use. )
This sounds complicated, but it really isn't. Create is just a way of giving you the opportunity to cache information for views.
The display() method is handed a request object (the same one used in create()) and is expected to actually send it's data through the requests output handle.
# a display method.
sub display {
my($self,$req) = (shift,shift);
$req->out()->print("Hello World\n");
}
To make things easy, GenieMod has it's own template system, but you don't need to use it if you don't want to. Anything that implements the methods of GenieMod::View should suffice.
The template system GenieMod::View::Template more or less takes an asp/jsp looking file and compiles it into a perl subroutine.