[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Implementing "back" and "next" buttons within the application


I'm writing a medium-to-small application for my own edification in
CGI::Application and have come up against something of a wall.  At
times I have a number of screens full of information to present and
I'd like to allow the user to browse back and forth between them.

I've written code to accept a pair of "offset" and "size" parameters
(I'm not concerned if users want to meddle with these settings,
really) and present the appropriate amount of data.  The sticking
point comes when I'm writing the code to process my templates;
obviously the URLs used to create the (say) 'next' button will have to
preserve some state.

Right now, as something of a hack[1], I'm calling C<self_url> on my
CGI object and appending to that:

        $q->self_url.'&offset='.($offset+50);

But this strikes me as pretty inelegant.  My only other thought is to
create a copy of the CGI object and re-set the params as necessary:

        my $r = $q->copy; # uses a fictional CGI.pm method
        $r->param('offset', $r->param('offset') + $r->param('size'));
        # create "next" link using $r

I'm not sure this is much better.

Any opinions?

Cheers,

jason

[1] : Actually this isn't true since I gave up on this problem while
      working to have the application use the Template Toolkit.  But
      the approach is similar.
-- 
``Oooh!  A gingerbread house!  Hansel and Gretel are set for life!''

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.