fixing the propertyDefinitions.

This commit is contained in:
Matthew Wilson 2005-10-13 21:55:15 +00:00
parent 768c8987ee
commit 27dd87faa0

View file

@ -41,6 +41,8 @@ use WebGUI::SQL;
use WebGUI::TabForm;
use WebGUI::URL;
use WebGUI::Utility;
our $propertyDefinitions;
=head1 NAME
@ -470,6 +472,29 @@ sub getDefault {
}
#-------------------------------------------------------------------
=head2 getDefaultValue ( )
Returns the defaultValue for the key for the className of the calling object instance.
=cut
sub getDefaultValue {
my $self = shift;
my $key = shift;
unless (exists $propertyDefinitions->{$self->getValue("className")}) { # check to see if the definitions have been merged and cached
my %properties;
foreach my $definition (@{$self->definition}) {
%properties = (%properties, %{$definition->{properties}});
}
our $propertyDefinitions;
$propertyDefinitions->{$self->getValue("className")} = \%properties;
}
return $propertyDefinitions->{$self->getValue("className")}->{$key}{defaultValue};
}
#-------------------------------------------------------------------
=head2 getEditForm ( )
@ -930,17 +955,10 @@ sub getValue {
my $self = shift;
my $key = shift;
if (defined $key) {
unless (exists $self->{_propertyDefinitions}) { # check to see if the definitions have been merged and cached
my %properties;
foreach my $definition (@{$self->definition}) {
%properties = (%properties, %{$definition->{properties}});
}
$self->{_propertyDefinitions} = \%properties;
}
return $session{form}{$key} if (exists $session{form}{$key});
my $storedValue = $self->get($key);
return $storedValue if (defined $storedValue);
return $self->{_propertyDefinitions}{$key}{defaultValue};
return $self->getDefaultValue($key);
}
return undef;
}