Apache2-Autocomplete

 view release on metacpan or  search on metacpan

lib/Apache2/Autocomplete.pm  view on Meta::CPAN


=item * $names

This is an array reference of results to be used as the list of
suggested completions.

=item * $values

This is an array reference of values that are usually shown on
the right-hand side of the drop-down box in the front end;
Google uses it for the estimated result count.

=item * $prefix

As discussed in L<JavaScript::Autocomplete::Backend>,
the purpose of I<$prefix> is not certain at this time. It
appears that if the array is empty, the drop-down menu appears
but the word in the input box itself is not completed,
while if the array is not empty (for example,
contains an empty string as its only element), the word
in the input box is completed as well.

=back

The Apache handler itself:

  sub handler {
    my $r = shift;
    my $ac = __PACKAGE__->new($r);
    $ac->run();
    return Apache2::Const::OK;
  }

creates the object and calls the I<run> method on it, which
returns the autocomplete results in the form of JavaScript code that
the original form then uses to fill in the suggestions.

=head1 Methods

The following methods are available.

=over

=item * my $ac = __PACKAGE__-E<gt>new($r);

This creates the object, and takes a mandatory
argument of the L<Apache2::RequestRec> object I<$r>.

=item * $ac-E<gt>run();

This is the main method which calls the I<expand> method
to find and format the results to be returned for the
autocompletion.

By default, the only header Apache::Autocomplete sets is
the I<Content-Type>, for which I<text/html> is used.
If additional headers are required, they may
be passed as an optional argument into I<run()>in the
form of a hash reference, as in

  my $header = {'Content-Type' => 'text/html; charset=utf-8',
		'X-err_header_out' => 'err_headers_out',
	       };
  $ac->run($header);

=item * my $r = $ac-E<gt>r;

This returns the L<Apache2::RequestRec> object passed into
the I<new> method.

=item * my $cgi = $ac-E<gt>cgi;

This returns the CGI.pm-compatible object used to
supply the I<param()> and I<header()> methods needed
by L<JavaScript::Autocomplete::Backend>.

=back

=head1 SEE ALSO

For a description of the JavaScript backend, see
L<JavaScript::Autocomplete::Backend> and
L<http://serversideguy.blogspot.com/2004/12/google-suggest-dissected.html>.

If using L<CGI> is a concern due to the memory
footprint, see L<CGI::Apache2::Wrapper>
for a minimal CGI.pm-compatible module
that uses methods of L<mod_perl2>
and L<Apache2::Request>.

Development of this package takes place at
L<http://cpan-search.svn.sourceforge.net/viewvc/cpan-search/Apache2-Autocomplete/>.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Apache2::Autocomplete

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Apache2-Autocomplete>

=item * CPAN::Forum: Discussion forum

L<http:///www.cpanforum.com/dist/Apache2-Autocomplete>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/Apache2-Autocomplete>

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-Autocomplete>

=item * Search CPAN



( run in 1.399 second using v1.01-cache-2.11-cpan-39bf76dae61 )