This provides a proper API to set the page error, particularly for non-child classes. Use it in CollectionBlock.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 8 ++++++-- testbot/lib/ObjectModel/CGI/Page.pm | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm index 053b22545..58ece69f3 100644 --- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm +++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm @@ -617,8 +617,12 @@ sub OnItemAction($$$) if ($Action eq "Delete") { my $ErrMessage = $self->{Collection}->DeleteItem($Item); - $self->{EnclosingPage}->{ErrMessage} = $ErrMessage; - return ! defined($ErrMessage); + if (defined $ErrMessage) + { + $self->{EnclosingPage}->SetError(undef, $ErrMessage); + return 0; + } + return 1; }
$self->{EnclosingPage}->SetError(undef, "No per-Item action defined for $Action"); diff --git a/testbot/lib/ObjectModel/CGI/Page.pm b/testbot/lib/ObjectModel/CGI/Page.pm index f7e3c93b8..a79155950 100644 --- a/testbot/lib/ObjectModel/CGI/Page.pm +++ b/testbot/lib/ObjectModel/CGI/Page.pm @@ -309,6 +309,14 @@ sub GetErrMessage($) return $self->{ErrMessage}; }
+sub SetError($$$) +{ + my ($self, $ErrField, $ErrMessage) = @_; + + $self->{ErrField} = $ErrField; + $self->{ErrMessage} = $ErrMessage; +} + sub GenerateErrorDiv($) { my ($self) = @_;