From 27dd87faa0c3cff9535bcac7de065fa465b32e02 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Thu, 13 Oct 2005 21:55:15 +0000 Subject: [PATCH] fixing the propertyDefinitions. --- lib/WebGUI/Asset.pm | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index ce7bc5b7a..328e9de7e 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -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; }