diff Lib/IMPL/Web/TT/Form.pm @ 138:c5bc900eefd3

IMPL::Web::Application: Fixed file uploading Minor improvements in the IMPL::Web::TT::Form
author wizard
date Thu, 01 Jul 2010 04:25:07 +0400
parents 0dce0470a3d8
children b56ebc31bf18
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Form.pm	Tue Jun 29 00:37:05 2010 +0400
+++ b/Lib/IMPL/Web/TT/Form.pm	Thu Jul 01 04:25:07 2010 +0400
@@ -5,8 +5,6 @@
 
 use IMPL::Class::Property;
 use IMPL::DOM::Navigator::SchemaNavigator;
-use IMPL::DOM::Property qw(_dom);
-
 __PACKAGE__->PassThroughArgs;
 
 BEGIN {
@@ -14,19 +12,30 @@
 	public property schema => prop_all;
 	public property errors => prop_all;
 	public property data => prop_all;
+	public property state => prop_all;
+	public property formResult => prop_all;
 }
 
 sub CTOR {
 	my ($this) = @_;
 	
-	$this->base($this->nodeName) unless $this->base;
+	if (my $form = $this->formResult) {
+		$this->base($form->{formName});
+		$this->errors($form->{formErrors});
+		$this->data($form->{formData});
+		$this->schema($form->{formSchema});
+		$this->state($form->{state});
+	} else {
 	
-	die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName)
-		unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) };
-	
-	die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base)
-		unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
+		$this->base($this->nodeName) unless $this->base;
+		
+		die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName)
+			unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) };
 		
+		die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base)
+			unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
+	}
+			
 	$this->errors([]) unless $this->errors;
 }
 
@@ -47,7 +56,7 @@
 	my $sourceSchema = $navi->SourceSchemaNode;
 	my $queryParameter = join '/', @path;
 	shift @path;
-	my $node = $this->data->selectSingleNode(@path);
+	my $node = $this->data ? $this->data->selectSingleNode(@path) : undef;
 	
 	my @errors;