: # feed this into perl
eval 'exec perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
#
# $Id: dyn_target,v 0.1 2001/04/22 17:57:04 ram Exp $
#
# Copyright (c) 1998-2001, Raphael Manfredi
# Copyright (c) 2000-2001, Christophe Dehaudt
#
# You may redistribute only under the terms of the Artistic License,
# as specified in the README file that comes with the distribution.
#
# HISTORY
# $Log: dyn_target,v $
# Revision 0.1 2001/04/22 17:57:04 ram
# Baseline for first Alpha release.
#
# $EndLog$
#
require CGI::MxScreen;
package SCREEN_A;
use CGI qw/:standard/;
use CGI::MxScreen::HTML;
use base qw(CGI::MxScreen::Screen);
sub display {
my $self = shift;
print center(h1($self->screen_title));
print "Name: ", textfield("name"), br;
my $password = $self->record_field(
-name => "passwd",
-mandatory => 0,
-size => 10,
-maxlength => 20,
);
print "Password: ", password_field($password->properties), br;
my $ok = $self->record_button(
-name => "ok",
-action => ['validate'],
-value => "OK",
-dyn_target => ['next_state', $password],
);
my $redraw = $self->record_button(
-name => "redraw",
-value => "Redraw",
-target => $self->current_screen,
);
print submit($ok->properties), submit($redraw->properties);
}
sub next_state {
my $self = shift;
my ($pass) = @_;
return "C" if $pass->value eq "toc";
return "B";
}
package SCREEN_B;
use CGI qw/:standard/;
use CGI::MxScreen::HTML;
use base qw(CGI::MxScreen::Screen);
sub display {
my $self = shift;
print center(h1($self->screen_title));
print "<P>\n";
print "Your name is ", scalar param("name"), br;
print "Your password is ", scalar param("passwd"), br;
print "</P>\n";
my $back = $self->record_button(
-name => "back",
-value => "Back",
-target => $self->spring_screen,
);
print submit($back->properties);
}
package SCREEN_C;
use CGI qw/:standard/;
use CGI::MxScreen::HTML;
use base qw(CGI::MxScreen::Screen);
sub display {
my $self = shift;
print center(h1($self->screen_title));
my $back = $self->record_button(
-name => "back",
-value => "Back",
-target => $self->spring_screen,
);
print submit($back->properties);
}
package main;
my $manager = CGI::MxScreen->make(
-screens =>
{
'A' => [-class => 'SCREEN_A', -title => "Welcome to A" ],
'B' => [-class => 'SCREEN_B', -title => "Welcome to B" ],
'C' => [-class => 'SCREEN_C', -title => "Bad password" ],
},
-initial => ['A'],
);
$manager->play();