annotate Lib/IMPL/Web/TT/Form.pm @ 150:4369d5458bb6

minor fixes
author wizard
date Fri, 20 Aug 2010 08:28:43 +0400
parents e6447ad85cb4
children a9f4ba4783eb
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;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
7 use IMPL::DOM::Navigator::SchemaNavigator();
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
8
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
9 __PACKAGE__->PassThroughArgs;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
10
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
11 BEGIN {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
12 public property base => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
13 public property schema => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
14 public property errors => prop_all;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
15 public property data => prop_all;
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
16 public property state => prop_all;
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
17 public property formResult => prop_all;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
18 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
19
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
20 sub CTOR {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
21 my ($this) = @_;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
22
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
23 if (my $form = $this->formResult) {
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
24 $this->base($form->{formName});
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
25 $this->errors($form->{formErrors});
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
26 $this->data($form->{formData});
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
27 $this->schema($form->{formSchema});
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
28 $this->state($form->{state});
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
29 } else {
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
30
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
31 $this->base($this->nodeName) unless $this->base;
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
32
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
33 die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName)
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
34 unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) };
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
35
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
36 die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base)
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
37 unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
38 }
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
39
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
40 $this->errors([]) unless $this->errors;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
41 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
42
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
43 sub fillContents {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
44 my ($this) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
45
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
46 my $schema = $this->schema->selectSingleNode(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base });
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
47
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
48 $this->buildContainer(
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
49 $schema,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
50 $schema,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
51 $this->data->isComplex ? $this->data : undef,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
52 $this
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
53 );
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
54 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
55
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
56 sub buildContainer {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
57 my ($this,$schemaSource,$schema,$domNode,$container,$path) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
58
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
59 $path = [@{$path || []},{node => $domNode, schemaSource => $schemaSource}];
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
60
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
61 $container ||= $this->document->Create($schemaSource->name,'IMPL::Web::TT::Collection');
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
62
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
63 foreach my $schemaItem ( $schema->content->childNodes ) {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
64 my $schemaItemSource = $schemaItem;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
65
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
66 $schemaItem = $this->schema->resolveType($schemaItem->type)
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
67 if typeof $schemaItem eq typeof IMPL::DOM::Schema::Node;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
68
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
69 my @nodesData = $domNode->selectNodes(sub { $_->schemaSource == $schemaItemSource } ) if $domNode;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
70
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
71 push @nodesData, undef unless @nodesData;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
72
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
73 if ($schemaItem->isa(typeof IMPL::DOM::Schema::ComplexNode) ) {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
74 $this->appendChild( $this->buildContainer($schemaItemSource,$schemaItem,$_,undef,$path) ) foreach @nodesData;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
75 } elsif ($schemaItem->isa(typeof IMPL::DOM::Schema::SimpleNode)) {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
76 $this->appendChild( $this->buildControl($schemaItemSource,$schemaItem,$_,$path) ) foreach @nodesData;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
77 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
78 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
79
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
80 return $container;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
81 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
82
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
83 sub buildControl {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
84 my ($this,$schemaSource,$schema,$node,$path) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
85
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
86 my @errors;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
87
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
88 if ($node) {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
89 @errors = grep { ($_->Node || $_->Parent) == $node } @{$this->errors};
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
90 } else {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
91 @errors = grep $_->Schema == $schemaSource, @{$this->errors};
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
92 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
93
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
94 return $this->document->CreateControl(
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
95 $schemaSource->name,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
96 $this->mapType($schemaSource),
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
97 {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
98 schema => $schema,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
99 sourceSchema => $schemaSource,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
100 errors => \@errors,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
101 data => $node,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
102 nodeValue => $node && $node->nodeValue, # small hack set a non dom class property through
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
103 queryParameter => $this->makeParameterName([@$path,{ node => $node, schemaSource => $schemaSource}])
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
104 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
105 );
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
106 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
107
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
108 sub mapType {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
109 my ($this,$schema) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
110
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
111 $schema->nodeProperty('control') ||
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
112 ( $schema->type && $this->schema->resolveType($schema->type)->nodeProperty('control') )
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
113 or die new IMPL::Exception("Unable to get control class for the form element",$schema->path);
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
114 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
115
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
116 sub makeParameterName {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
117 my ($this,$path) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
118
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
119 join '/', map {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
120 $_->{node} ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
121 (
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
122 $_->{node}->nodeProperty('instanceId') ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
123 $_->{node}->nodeName . '['. ']' :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
124 $_->{node}->nodeName
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
125 ) :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
126 (
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
127 $_->{schemaSource}->maxOccur eq 'unbounded' || $_->{schemaSource}->maxOccur > 1 ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
128 $_->{schemaSource}->name . '[0]' :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
129 $_->{schemaSource}->name
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
130 )
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
131 } @$path;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
132 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
133
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
134 sub makeControlArgs{
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
135 my ($this,$path) = @_;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
136
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
137 my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
138 my @path = ($this->base, split /\./,$path);
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
139
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
140 $navi->NavigateName($_) or die new IMPL::InvalidArgumentException(
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
141 "Can't find a definition for an element",
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
142 $_,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
143 $path,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
144 $this->element,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
145 ) foreach @path;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
146
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
147 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
148 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
149 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
150 shift @path;
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
151 my $node = $this->data ? $this->data->selectSingleNode(@path) : undef;
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
152
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
153 my @errors;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
154
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
155 if ($node) {
144
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 138
diff changeset
156 @errors = grep { ($_->Node || $_->Parent) == $node } @{$this->errors};
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 138
diff changeset
157 } else {
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 138
diff changeset
158 @errors = grep $_->Schema == $sourceSchema, @{$this->errors};
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
159 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
160
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
161 return {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
162 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
163 sourceSchema => $sourceSchema,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
164 errors => \@errors,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
165 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
166 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
167 queryParameter => $queryParameter
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
168 };
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
169 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
170
145
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
171 sub makeContent {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
172 my ($this,$mappings) = @_;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
173
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
174 my $formSchema = $this->schema->selectSingleNode(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base } )
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
175 or die new Exception("Cant find a schema element for the specified form", $this->base);
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
176
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
177 my $doc = $this->document;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
178 foreach my $itemSchema ( $formSchema->content->childNodes ) {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
179 my $itemName = $itemSchema->name;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
180 if (my $controlClass = $mappings->{$itemName} ) {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
181 my $contorl = $doc->CreateControl($itemName,$controlClass,$this->makeControlArgs($itemName));
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
182 $this->appendChild($contorl);
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
183 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
184 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
185 return;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
186 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
187
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
188 sub formErrors {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
189 my ($this) = @_;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
190
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
191 if (my $node = $this->data ) {
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
192 return [
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
193 grep {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
194 ( $_->Node || $_->Parent) == $node
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
195 } @{$this->errors}
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
196 ];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
197 } else {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
198 return [];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
199 }
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
200 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
201
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
202 1;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
203 __END__
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
204
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
205 =pod
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
206
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
207 =head1 NAME
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
208
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
209 C<IMPL::Web::TT::Form> - Форма с элементами
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
210
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
211 =head1 DESCRIPTION
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
212
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
213 Является элементом управления, тоесть для своего преобразования ипользует
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
214 шаблон
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
215
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
216 =cut