I've been working with PerForm and XSP::Exception and ESQL modules to
create an on-line database interface.
Over all I've been pleased, however I have a couple things where I have
been unable to get the behavior I desire.
First thing I've noticed is that the server does not respond well when
the request ends up causing the XSP to be recompiled. IE, I have to hit
the button/link more than once before I get the page back I want, also
sometimes will get stuck with the redirect from the PerForm result.
second..
I'm using PerForm to edit my database records.. So..
I use the validate_<field> to check the individual values which seems to
work fine, however, when it has finished doing that and I go to update
the database in the submit_<button> handler, if there is an error I have
no way of stoping the redirect.. I would prefer to be able to have it
function similar to the validate handlers where if I call a die inside
the submit callback, it returns to the page with the error message
accessable to be placed somewhere on the screen, to give the user some
indication that there was a problem, instead of just giving a crash
message.
I tried using a <except:try> block around the <perform:form> tags but
that dosn't result in the desired behavior since the perform seems to be
using some sort of eval block to handle the redirect exception.
If anyone else has attempted similar with better result, I'd be
interested in hearing what solutions worked.
here's a copy of example submit callback.
sub submit_save {
my ($ctxt) = @_;
# save values to a database
my %args = $ctxt->{Apache}->args();
my $student = $args{student}|| $ctxt->{Form}{student};
my $dbh = DBI->connect('DBI:Pg:dbname=edu');
$dbh->do('
update student_contact
set
label = ?,
street = ?,
city = ?,
state = ?,
zip = ?,
phone = ?,
email = ?,
url = ?,
note = ?
where oid = ?
',undef,
$ctxt->{Form}{newlabel},
$ctxt->{Form}{street},
$ctxt->{Form}{city},
$ctxt->{Form}{state},
$ctxt->{Form}{zip},
$ctxt->{Form}{phone},
$ctxt->{Form}{email},
$ctxt->{Form}{url},
$ctxt->{Form}{note},
$ctxt->{Form}{oid},
) or die $dbh->errstr;
return "../?student=$student";
}
Thanks
Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]