annotate Lib/IMPL/Web/TT/Form.pm @ 129:e4f15cbc3f1a

Fixed utf-8 problem
author wizard
date Tue, 15 Jun 2010 20:12:58 +0400
parents 0dce0470a3d8
children c5bc900eefd3
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
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
10 __PACKAGE__->PassThroughArgs;
124
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 });
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
29
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
30 $this->errors([]) unless $this->errors;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
31 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
32
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
33 sub makeControlArgs{
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
34 my ($this,$path) = @_;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
35
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
36 my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
37 my @path = ($this->base, split /\./,$path);
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
38
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
39 $navi->NavigateName($_) or die new IMPL::InvalidArgumentException(
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
40 "Can't find a definition for an element",
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
41 $_,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
42 $path,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
43 $this->element,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
44 ) foreach @path;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
45
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
46 my $schema = $navi->Current;
127
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
47 my $sourceSchema = $navi->SourceSchemaNode;
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
48 my $queryParameter = join '/', @path;
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
49 shift @path;
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
50 my $node = $this->data->selectSingleNode(@path);
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
51
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
52 my @errors;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
53
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
54 if ($node) {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
55 @errors = grep { ( $_->Node || $_->Parent) == $node } @{$this->errors};
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
56 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
57
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
58 return {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
59 schema => $schema,
127
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
60 sourceSchema => $sourceSchema,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
61 errors => \@errors,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
62 data => $node,
127
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
63 nodeValue => $node && $node->nodeValue, # small hack set a non dom class property through
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
64 queryParameter => $queryParameter
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
65 };
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
66 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
67
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
68 sub formErrors {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
69 my ($this) = @_;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
70
127
0dce0470a3d8 In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction
wizard
parents: 126
diff changeset
71 if (my $node = $this->data ) {
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
72 return [
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
73 grep {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
74 ( $_->Node || $_->Parent) == $node
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
75 } @{$this->errors}
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
76 ];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
77 } else {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
78 return [];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
79 }
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
80 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
81
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
82
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
83 1;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
84
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
85 __END__
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
86
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
87 =pod
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
88
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
89 =head1 NAME
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
90
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
91 C<IMPL::Web::TT::Form> - Форма с элементами
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
92
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
93 =head1 DESCRIPTION
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
94
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
95 Является элементом управления, тоесть для своего преобразования ипользует
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
96 шаблон
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
97
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
98 =cut