diff Lib/IMPL/Web/TT/Form.pm @ 124:e30bdd040fe3

IMPL::Web::TT::Form concept
author wizard
date Thu, 10 Jun 2010 02:45:59 +0400
parents a7efb3117295
children c8dfbbdd8005
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Form.pm	Wed Jun 09 17:53:12 2010 +0400
+++ b/Lib/IMPL/Web/TT/Form.pm	Thu Jun 10 02:45:59 2010 +0400
@@ -3,6 +3,47 @@
 
 use base qw(IMPL::Web::TT::Control);
 
+use IMPL::Class::Property;
+use IMPL::DOM::Navigator::SchemaNavigator;
+use IMPL::DOM::Property qw(_dom);
+
+__PACKAGE__->PasssThroughArgs;
+
+BEGIN {
+	public property base => prop_all;
+	public property schema => prop_all;
+	public property errors => prop_all;
+	public property data => prop_all;
+}
+
+sub CTOR {
+	my ($this) = @_;
+	
+	$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 });
+}
+
+sub createControl {
+	my ($this, $path, $class, $hashArgs) = @_;
+	
+	my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
+	
+	$navi->NavigateName($_) or die new IMPL::InvalidAgrumentException(
+		"Can't find a definition for an element",
+		$_,
+		$path,
+		$this->element
+	) foreach $this->base, split /\./,$path;
+	
+	my $schema = $navi->Current;
+	my @errors = grep $_->Source == $navi->SourceSchemaNode
+}
+
 
 1;