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

[cgiapp] Re: ANNOUNCE: CGI::Application::Plugin::Apache 0.08


Mark Stosberg wrote:
In gmane.comp.lang.perl.modules.cgi-appplication, you wrote:

The uploaded file

    CGI-Application-Plugin-Apache-0.08.tar.gz

has entered CPAN as


Thanks for the contribution Michael.

May I ask: Without CGI.pm, how do you generate popup form widgets
from dynamic data?

You mean <select> list's ? I think that whether you use a select list or a radio button group, or multiple select boxes is a design decision, not a programming one. They are in essence, a list of values to choose from. I try to put the decision to use either into the templates. This should be pretty easy to do in both HTML::Template and TT. Just itereate over a list or loop.

In terms of making it 'sticky' I've become very fond of HTML::FillInForm. To illustrate I use something very similar to this in my base classes to fill in my templates (I use TT now) with their data and then pass it into HTML::FillInForm.

sub tt_process {
    my ( $self, %args) = @_;
    my $output      = '';


    my $template = Template->new(
        INCLUDE_PATH    => $self->config_param('paths.tmpl'),
    );


    $template->process( $args{tmpl}, $args{tmpl_data}, \$output )
      || $logger->error_die($template->error );


    #if we want to use HTML::FillInForm
    if ($args{fill} || $args{fill_data}) {
        my $fif = HTML::FillInForm->new();


        if( $args{fill_data} ) {
            #if we have data then use as a hashref
return $fif->fill( scalarref => \$output, fdat => $args{fill_data} );
        } else {
            #else we don't have data so use the query object
            return $fif->fill(
                scalarref   => \$output,
                fobject     => $self->query,
                fill_passwd => 0
            );
        }
    } else {
        return $output;
    }
}


and then I use it like this when I want to fill in a form with some data (%some_other_hash) I got from somewhere like a database.

return $self->tt_process(
    tmpl      => 'my_file.tmpl',
    tmpl_data => \%some_hash,
    fill_data => \%some_other_hash,
);

Or like this when I want it to use the query object (in my case Apache::Request) to produce a sticky form when something wasn't valid

return $self->tt_process(
    tmpl      => 'my_other_file.tmpl',
    tmpl_data => \%some_hash,
    filll     => 1,
);


Hope that helps to clarify why I don't use CGI.pm. Don't get me wrong, if you need html generation, then CGI.pm does a good, standards following way of doing it. I just think that sort of thing belongs in the template.

--
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
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.