annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
1 use strict;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
2 package IMPL::Web::TT::Form;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
3
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
4 use base qw(IMPL::Web::TT::Control);
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
5
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
6 use IMPL::Class::Property;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
7 use IMPL::DOM::Navigator::SchemaNavigator;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
8 use IMPL::DOM::Property qw(_dom);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
9
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
10 __PACKAGE__->PasssThroughArgs;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
11
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
12 BEGIN {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
13 public property base => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
14 public property schema => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
15 public property errors => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
16 public property data => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
17 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
18
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
19 sub CTOR {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
20 my ($this) = @_;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
21
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
22 $this->base($this->nodeName) unless $this->base;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
23
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
24 die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName)
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
25 unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
26
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
27 die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base)
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
28 unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
29 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
30
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
31 sub createControl {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
32 my ($this, $path, $class, $hashArgs) = @_;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
33
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
34 my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
35
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
36 $navi->NavigateName($_) or die new IMPL::InvalidAgrumentException(
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
37 "Can't find a definition for an element",
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
38 $_,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
39 $path,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
40 $this->element
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
41 ) foreach $this->base, split /\./,$path;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
42
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
43 my $schema = $navi->Current;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
44 my @errors = grep $_->Source == $navi->SourceSchemaNode
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
45 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
46
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
47
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
48 1;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
49
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
50 __END__
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
51
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
52 =pod
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
53
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
54 =head1 NAME
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
55
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
56 C<IMPL::Web::TT::Form> - Форма с элементами
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
57
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
58 =head1 DESCRIPTION
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
59
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
60 Является элементом управления, тоесть для своего преобразования ипользует
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
61 шаблон
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
62
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
63 =cut