%doc>
Generic confirmation dialog. Meant to be called from other components
in order to ask for confirmation of a certain action.
%doc>
<%args>
$target # This is the original component that needs input
$message => undef # Message to be displayed for confirmation
$sid => undef # Session ID
$submit => undef # Controls execution flow
%args>
<%init>
my $DEBUG = 0;
print '%ARGS is
', Dumper(%ARGS), '
' if $DEBUG;
%init>
<%perl>
if ( $submit && ($submit eq 'confirm') ){
$m->comp('/generic/error.mhtml', error=>"Missing required session id")
unless ( $sid );
my $sess = $ui->get_session($sid);
map { $ARGS{$_} = $sess->{$_} } keys %$sess;
print '%ARGS after recovering session is ', Dumper(%ARGS), '
' if $DEBUG;
# Now back to the calling component
# Make sure to delete our own args
foreach my $arg ( qw(message target sid) ){
delete $ARGS{$arg};
}
$m->comp($target, %ARGS);
}else{
$m->comp('/generic/error.mhtml', error=>"Missing required arguments: message, target")
unless ( $message && $target );
# Create a session with current arguments
my $sess = $ui->mk_session();
while ( my($k,$v) = each %ARGS ){
$sess->{$k} = $v;
}
my $sid = $sess->{_session_id};
%perl>
<%perl>
# We need to stop execution of the calling component
$m->abort;
%perl>
%}