Jifty::Action::Autocomplete - An action for making autocompletion suggestions


Jifty documentation Contained in the Jifty distribution.

Index


Code Index:

NAME

Top

Jifty::Action::Autocomplete - An action for making autocompletion suggestions

DESCRIPTION

Top

A built-in Jifty::Action which returns suggested autocompletions for a given argument of an action. Generally this is called by Jifty's internals through /__jifty/autocomplete.xml.

This action gets its data to /__jifty/autocomplete.xml by filling in the completions of the content in Jifty::Result.

arguments

The arguments for Autocomplete are:

action

The moniker (moniker in Jifty::Manual::Glossary) of an action we want to pull a field to autocomplete from.

argument

The fully qualified name of the argument (argument in Jifty::Manual::Glossary) to action that we want to complete.

take_action

Find the submitted action in the Jifty::Request named by the action above, and ask it for autocompletion possibilities for the argument in question.

SEE ALSO

Top

Jifty::Action

LICENSE

Top

Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself.


Jifty documentation Contained in the Jifty distribution.
use warnings;
use strict;



package Jifty::Action::Autocomplete;
use base qw/Jifty::Action/;

sub arguments {
    {
        moniker => {},
        argument => {}
    }
}

sub take_action {
    my $self = shift;

    # Load the arguments
    my $moniker = $self->argument_value('moniker');
    my $argument = $self->argument_value('argument');

    # Load the action associated with the moniker
    my $request_action = Jifty->web->request->action($moniker);
    my $action = Jifty->web->new_action_from_request($request_action);

    # Call the autocompleter for that action and argument and set the result
    my @completions = $action->_autocomplete_argument($argument);
    $self->result->content->{completions} = \@completions;

    return 1;
}

1;