Thread CGI::Application: run_modes (28 answers)
Opened by esskar at 2005-01-22 03:40

esskar
 2005-02-14 00:32
#4217 #4217
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
hab es jetzt doch nochmal mit CGI::Application (bzw. mit CGI::Application::Plus)

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package Ox::WebMail;

use strict;
use warnings;

use base 'CGI::Application::Plus';
use Ox::WebMail::Consts;

sub cgiapp_get_query {
    require CGI::Simple;

    my $cgi = CGI::Simple->new();
    $cgi->parse_query_string();

    return $cgi;
}

sub setup {
    my $self = shift;

    $self->tmpl_path(&Ox::WebMail::Consts::TEMPLATE_PATH);
    $self->header_props(
        -type      =>    'text/html',
        -charset    =>    &Ox::WebMail::Consts::CONTENT_CHARSET,
    );

    $self->mode_param('action');
    $self->start_mode('login');
    $self->run_modes({
        'login' => sub {
            require Ox::WebMail::Login;
            return Ox::WebMail::Login->new()->run()
        }
    });
}

1;


Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Ox::WebMail::Login;

use strict;
use warnings;

use base 'CGI::Application::Plus';

sub setup {
    my $self = shift;

    $self->tmpl_path(&Ox::WebMail::Consts::TEMPLATE_PATH_LOGIN);
    $self->header_type('none');
    $self->mode_param('login');
    $self->start_mode('form');
    $self->run_modes({
        'form' => 'show_form',
    });
}

sub show_form {
    my $self = shift;

    my $tmpl = $self->load_tmpl(
        'form.tpl',
        die_on_bad_params => 0,
        cache => 1
    );


    return $tmpl->output;
}

1;


wenn ich das jetzt laufen lasse, wird die Template-Form (show_form) vor dem HTTP-Header ausgegeben!
Wenn ich anstatt 'CGI::Application::Plus' 'CGI::Application' verwende, wird zuerst dir form, dann den header und dann die form wieder ausgegen... wo ist mein Fehler?\n\n

<!--EDIT|esskar|1108333989-->

View full thread CGI::Application: run_modes