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

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


In article <suppressed>, Jason Parker-Burlingham wrote:
> 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.

Hello Jason,

I believe this issue is generally called "paging", and I was just
researching it myself a few days ago. Looking through CPAN, an "obvious"
solution to this might seem to be HTML::Pager, because it's built to
work with HTML::Template, which already integrates with CGI::App.

Looking closely at HTML::Pager, I found it had a number of features that
made it undesirable for me:

- The interface seemed more complex than is needed
- It relies on JavaScript, which isn't necessary
- It relies on HTML embedded in the code. Even if you use a template,
  there are some parts of the output that you can't change, so you may
  not be able to achieve a specific look, or have your page validate
  under the HTML/XHTML standard that you'd like.

So I went on a hunt for a better paging module before writing my own. I
found several, and one I think I really like. Here are some that I
found:

- HTML::Paging::SQL
- Class:DBI::Pager 
- DBIx::Pager

- Data::Page
- Data::Pageset
- Data::Pageset::Variable
- Template::Plugin::Page

The last four are all based on Data::Page. This is the module that I
will be trying next time for my paging needs. At first glance, it seemed
too simple. It doesn't include any structure that includes "all the
pages". This "talk" about Data::Pageset helped me to understand it
better:

http://london.pm.org/tech_talks/21_nov_2002/leo/#1

I think Data::Page does just the right amount of work. It  doesn't need
to be tied to any display system, and it's not. It has a very easy to
use and comprehensible interface. 

To do display a listing of all the pages, all I need to know is the the
first page is "1" and the last page is $page->last_page. Then it's easy
enough to create a loop that counts from 1 to $last_page to format and
display my data.

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

I think this is generally the approach I would take. Maybe:

my $q = new CGI;

# to generate a next page link, add or update the current_page variable
$q->param('current_page',$page->current_page+1);

my $link = $q->self_url;

	Mark
 
--
http://mark.stosberg.com/ 


---------------------------------------------------------------------
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.