annotate Lib/IMPL/Web/TT/Form.pm @ 176:74c27daf2e7b

minor changes
author sergey
date Wed, 05 Oct 2011 16:23:45 +0400
parents aaab45153411
children d1676be8afcc
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
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 158
diff changeset
4 use parent qw(IMPL::Web::TT::Control);
122
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,
158
a9f4ba4783eb Minor changes
wizard
parents: 148
diff changeset
102 inputType => $schemaSource->nodeProperty('inputType') || $schema->nodeProperty('inputType'),
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
103 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
104 queryParameter => $this->makeParameterName([@$path,{ node => $node, schemaSource => $schemaSource}])
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
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
109 sub mapType {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
110 my ($this,$schema) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
111
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
112 $schema->nodeProperty('control') ||
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
113 ( $schema->type && $this->schema->resolveType($schema->type)->nodeProperty('control') )
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
114 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
115 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
116
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
117 sub makeParameterName {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
118 my ($this,$path) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
119
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
120 join '/', map {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
121 $_->{node} ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
122 (
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
123 $_->{node}->nodeProperty('instanceId') ?
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 $_->{node}->nodeName
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 (
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
128 $_->{schemaSource}->maxOccur eq 'unbounded' || $_->{schemaSource}->maxOccur > 1 ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
129 $_->{schemaSource}->name . '[0]' :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
130 $_->{schemaSource}->name
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
131 )
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
132 } @$path;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
133 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 145
diff changeset
134
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
135 sub makeControlArgs{
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
136 my ($this,$path) = @_;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
137
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
138 my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema);
173
aaab45153411 minor bugfixes
sourcer
parents: 166
diff changeset
139 my @path = ($this->base, split(/\./,$path) );
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
140
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
141 $navi->NavigateName($_) or die new IMPL::InvalidArgumentException(
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
142 "Can't find a definition for an element",
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
143 $_,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
144 $path,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
145 $this->element,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
146 ) foreach @path;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
147
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
148 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
149 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
150 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
151 shift @path;
138
c5bc900eefd3 IMPL::Web::Application: Fixed file uploading
wizard
parents: 127
diff changeset
152 my $node = $this->data ? $this->data->selectSingleNode(@path) : undef;
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
153
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
154 my @errors;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
155
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
156 if ($node) {
144
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 138
diff changeset
157 @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
158 } else {
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 138
diff changeset
159 @errors = grep $_->Schema == $sourceSchema, @{$this->errors};
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
160 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
161
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
162 return {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
163 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
164 sourceSchema => $sourceSchema,
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
165 errors => \@errors,
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
166 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
167 nodeValue => $node && $node->nodeValue, # small hack set a non dom class property through
158
a9f4ba4783eb Minor changes
wizard
parents: 148
diff changeset
168 queryParameter => $queryParameter,
a9f4ba4783eb Minor changes
wizard
parents: 148
diff changeset
169 inputType => $sourceSchema->nodeProperty('inputType') || $schema->nodeProperty('inputType')
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
170 };
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
171 }
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
172
145
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
173 sub makeContent {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
174 my ($this,$mappings) = @_;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
175
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
176 my $formSchema = $this->schema->selectSingleNode(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base } )
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
177 or die new Exception("Cant find a schema element for the specified form", $this->base);
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
178
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
179 my $doc = $this->document;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
180 foreach my $itemSchema ( $formSchema->content->childNodes ) {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
181 my $itemName = $itemSchema->name;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
182 if (my $controlClass = $mappings->{$itemName} ) {
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
183 my $contorl = $doc->CreateControl($itemName,$controlClass,$this->makeControlArgs($itemName));
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
184 $this->appendChild($contorl);
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
185 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
186 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
187 return;
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
188 }
bd10093bb122 Minor changes
wizard
parents: 144
diff changeset
189
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
190 sub formErrors {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
191 my ($this) = @_;
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
192
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
193 if (my $node = $this->data ) {
126
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
194 return [
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
195 grep {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
196 ( $_->Node || $_->Parent) == $node
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
197 } @{$this->errors}
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
198 ];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
199 } else {
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
200 return [];
c8dfbbdd8005 Several bug fixes
wizard
parents: 124
diff changeset
201 }
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
202 }
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
203
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
204 1;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
205 __END__
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 =pod
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 =head1 NAME
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 C<IMPL::Web::TT::Form> - Форма с элементами
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 =head1 DESCRIPTION
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 шаблон
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
217
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents:
diff changeset
218 =cut