What if you want to provide a text interface to some, while providing an HTML interface to others? What if you're one of those young whipper-snappers using the so-called "Web 2.0" approach and need to provide only a small portion of a page (so ajax can then insert it via DHTML?)
How about.. XMLRPC?
The answer of course, is multiple views.
Multiple viewmaps can give your application a sort of split personality.
Here is an example
# Default view map.
<viewmap default>
<action do_test_two>
.. Stuff for do_test_two in normal mode.
</action>
</viewmap>
# Alternate view map
<viewmap alt>
<action do_test_two>
.. Stuff for do_test_two in alternate mode
</action>
</viewmap>
Now you just need to get the viewmap into the request object. (How you determine this is entirely up to you, you could use sub domains, cookies, special GET parameters or maybe even base it on the browser IP.
The controller doesn't care.
In GenieMod::View::Map there is an optional MapName parameter
that is used to set which section is used. For an alternate viewmap, you would then
set it to "alt"
$altmap = GenieMod::View::Map(MapName => "alt", %other_options_here);
It uses the "default" viewmap by ah, well.. default.
Recall that to set up a request, you pass it a ViewMap parameter. In the case of "alt" you
would just give it $altmap and be done with it.
However, there is something I left out.
Ok great.. you set up an alternate view, everything is cool, right? well.. yes if you happen to have views for every possible outcome. What if some of them are incomplete? what of abnormal views (like error pages telling the user that a parameter was invalid, pages that should normally not be seen anyway) fallback viewmaps allow you to use the default when none are present
You can think of it as the environment variable $PATH in any unix host. If you
set it to ~/bin:/usr/bin it will look for your own version of archie before
using the one stored in /usr/bin the same holds true for viewmaps.
$request = new GenieMod::Request(ViewMap => [$altmap, $defaultmap], %others);
Now if the controller requests a view that isn't defined in the alt section, it
will fallback to the default section.