comparison 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
comparison
equal deleted inserted replaced
123:1d7e370a91fa 124:e30bdd040fe3
1 use strict; 1 use strict;
2 package IMPL::Web::TT::Form; 2 package IMPL::Web::TT::Form;
3 3
4 use base qw(IMPL::Web::TT::Control); 4 use base qw(IMPL::Web::TT::Control);
5
6 use IMPL::Class::Property;
7 use IMPL::DOM::Navigator::SchemaNavigator;
8 use IMPL::DOM::Property qw(_dom);
9
10 __PACKAGE__->PasssThroughArgs;
11
12 BEGIN {
13 public property base => prop_all;
14 public property schema => prop_all;
15 public property errors => prop_all;
16 public property data => prop_all;
17 }
18
19 sub CTOR {
20 my ($this) = @_;
21
22 $this->base($this->nodeName) unless $this->base;
23
24 die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName)
25 unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) };
26
27 die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base)
28 unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
29 }
30
31 sub createControl {
32 my ($this, $path, $class, $hashArgs) = @_;
33
34 my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
35
36 $navi->NavigateName($_) or die new IMPL::InvalidAgrumentException(
37 "Can't find a definition for an element",
38 $_,
39 $path,
40 $this->element
41 ) foreach $this->base, split /\./,$path;
42
43 my $schema = $navi->Current;
44 my @errors = grep $_->Source == $navi->SourceSchemaNode
45 }
5 46
6 47
7 1; 48 1;
8 49
9 __END__ 50 __END__