122
|
1 use strict;
|
|
2 package IMPL::Web::TT::Form;
|
|
3
|
|
4 use base qw(IMPL::Web::TT::Control);
|
|
5
|
124
|
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 }
|
|
46
|
122
|
47
|
|
48 1;
|
|
49
|
|
50 __END__
|
|
51
|
|
52 =pod
|
|
53
|
|
54 =head1 NAME
|
|
55
|
|
56 C<IMPL::Web::TT::Form> - Форма с элементами
|
|
57
|
|
58 =head1 DESCRIPTION
|
|
59
|
|
60 Является элементом управления, тоесть для своего преобразования ипользует
|
|
61 шаблон
|
|
62
|
|
63 =cut |