: # feed this into perl
	eval 'exec perl -S $0 ${1+"$@"}'
		if $running_under_some_shell;

#
# $Id: action,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: action,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 base qw(CGI::MxScreen::Screen);
use CGI::MxScreen::Error;

sub init {
	my $self = shift;
	$self->vars->{was_run} = 0;
	$self->vars->{cond_abort} = param("abort")
		unless exists $self->vars->{cond_abort};
}

sub display {
	my $self = shift;
	print h1($self->screen_title);

	my $amount = $self->record_field(
		-name		=> "amount",
		-default	=> 0,
		-override	=> 1,
		-mandatory	=> 1,
		-verify		=> 'is_num',	# held in Form::Utils
	);

	my $ok = $self->record_button(
		-name		=> "ok",
		-value		=> "OK",
		-target		=> "B",
		-action		=> [['validate', 1], 'cond_abort', 'must_run_also'],
	);

	print p("Run count =", $self->vars->{was_run}); 
	print p("Error:", $amount->error) if $amount->error;
	print p("Amount:", textfield($amount->properties));
	print submit($ok->properties);
}

sub must_run_also {
	my $self = shift;
	$self->vars->{was_run}++;
	return CGI_MX_OK;
}

sub cond_abort {
	my $self = shift;
	return $self->vars->{cond_abort} ? CGI_MX_ABORT : CGI_MX_OK;
}

package SCREEN_B;

use CGI qw/:standard/;
use base qw(CGI::MxScreen::Screen);

sub display {
	my $self = shift;
	print h1($self->screen_title);
	print p("Was run =", $self->vars->{was_run}); 
}

package main;

my $manager = CGI::MxScreen->make(
	-screens	=>
		{
			'A'	=> [-class => 'SCREEN_A',	-title => "Screen A" ],
			'B'	=> [-class => 'SCREEN_B',	-title => "Screen B" ],
		},
	-initial	=> ['A'],
);

$manager->play();

