jsf.js_next_gen 4.0.0-RC.2 → 4.0.0-RC.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/docs/assets/main.js +56 -52
  2. package/dist/docs/assets/style.css +23 -0
  3. package/dist/docs/functions/myfaces.ab.html +2 -2
  4. package/dist/window/faces-development.js +783 -305
  5. package/dist/window/faces-development.js.br +0 -0
  6. package/dist/window/faces-development.js.gz +0 -0
  7. package/dist/window/faces-development.js.map +1 -1
  8. package/dist/window/faces.js +1 -1
  9. package/dist/window/faces.js.LICENSE.txt +0 -2
  10. package/dist/window/faces.js.br +0 -0
  11. package/dist/window/faces.js.gz +0 -0
  12. package/dist/window/faces.js.map +1 -1
  13. package/dist/window/jsf-development.js +783 -305
  14. package/dist/window/jsf-development.js.br +0 -0
  15. package/dist/window/jsf-development.js.gz +0 -0
  16. package/dist/window/jsf-development.js.map +1 -1
  17. package/dist/window/jsf.js +1 -1
  18. package/dist/window/jsf.js.LICENSE.txt +0 -2
  19. package/dist/window/jsf.js.br +0 -0
  20. package/dist/window/jsf.js.gz +0 -0
  21. package/dist/window/jsf.js.map +1 -1
  22. package/package.json +16 -16
  23. package/src/main/test.xml +23 -0
  24. package/src/main/typescript/@types/definitions/index.d.ts +19 -2
  25. package/src/main/typescript/api/_api.ts +5 -4
  26. package/src/main/typescript/impl/AjaxImpl.ts +109 -37
  27. package/src/main/typescript/impl/core/Const.ts +48 -38
  28. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  29. package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
  30. package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
  31. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +74 -0
  32. package/src/main/typescript/impl/util/Lang.ts +9 -11
  33. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  34. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  35. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -1
  36. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +40 -22
  37. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
  38. package/src/main/typescript/impl/xhrCore/Response.ts +25 -25
  39. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +157 -96
  40. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +1 -1
  41. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +24 -14
  42. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  43. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  44. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +72 -0
  45. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  46. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  47. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
  48. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  49. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +196 -0
  50. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  51. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +116 -9
  52. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +236 -11
  53. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  54. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +368 -31
  55. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +40 -6
  56. package/src/main/typescript/test.xml +6 -0
  57. package/src/main/typescript/tsconfig.json +1 -1
  58. package/src/tmp/test.html +12 -88
  59. package/target/api/_api.js +5 -4
  60. package/target/api/_api.js.map +1 -1
  61. package/target/impl/AjaxImpl.js +97 -26
  62. package/target/impl/AjaxImpl.js.map +1 -1
  63. package/target/impl/core/Const.js +48 -37
  64. package/target/impl/core/Const.js.map +1 -1
  65. package/target/impl/core/Context.js +10 -0
  66. package/target/impl/core/Context.js.map +1 -0
  67. package/target/impl/util/Assertions.js +12 -7
  68. package/target/impl/util/Assertions.js.map +1 -1
  69. package/target/impl/util/AsyncQueue.js.map +1 -1
  70. package/target/impl/util/ExtDomQuery.js +9 -2
  71. package/target/impl/util/ExtDomQuery.js.map +1 -1
  72. package/target/impl/util/HiddenElementBuilder.js +7 -0
  73. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  74. package/target/impl/util/HiddenInputBuilder.js +66 -0
  75. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  76. package/target/impl/util/Lang.js +8 -10
  77. package/target/impl/util/Lang.js.map +1 -1
  78. package/target/impl/xhrCore/ErrorData.js +10 -8
  79. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  80. package/target/impl/xhrCore/EventData.js +1 -1
  81. package/target/impl/xhrCore/EventData.js.map +1 -1
  82. package/target/impl/xhrCore/RequestContext.js +11 -0
  83. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  84. package/target/impl/xhrCore/RequestDataResolver.js +34 -15
  85. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  86. package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
  87. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  88. package/target/impl/xhrCore/Response.js +13 -13
  89. package/target/impl/xhrCore/Response.js.map +1 -1
  90. package/target/impl/xhrCore/ResponseProcessor.js +136 -82
  91. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  92. package/target/impl/xhrCore/XhrFormData.js +1 -1
  93. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  94. package/target/impl/xhrCore/XhrRequest.js +20 -11
  95. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  96. package/target/myfaces/OamSubmit.js +23 -14
  97. package/target/myfaces/OamSubmit.js.map +1 -1
  98. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
  99. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  100. package/target/test/frameworkBase/_ext/shared/StandardInits.js +63 -0
  101. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  102. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  103. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  104. package/target/test/impl/ImplTest.spec.js +2 -2
  105. package/target/test/impl/ImplTest.spec.js.map +1 -1
  106. package/target/test/impl/ImplTest_23.spec.js +2 -2
  107. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  108. package/target/test/xhrCore/EventTests.spec.js +1 -1
  109. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  110. package/target/test/xhrCore/NamespacesRequestTest.spec.js +200 -0
  111. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  112. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  113. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  114. package/target/test/xhrCore/RequestParamsTest.spec.js +101 -4
  115. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  116. package/target/test/xhrCore/RequestTest.spec.js +212 -9
  117. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  118. package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
  119. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  120. package/target/test/xhrCore/ResponseTest.spec.js +303 -22
  121. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  122. package/target/test/xhrCore/ResponseTest23.spec.js +35 -5
  123. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  124. package/tmp.xml +36 -0
  125. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
  126. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
  127. package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
  128. package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
  129. package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
  130. package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config, DomQuery, DQ, Lang, Stream, XMLQuery} from "mona-dish";
17
+ import {Config, DomQuery, DomQueryCollector, DQ, DQ$, Lang, LazyStream, Stream, XMLQuery} from "mona-dish";
18
18
  import {Implementation} from "../AjaxImpl";
19
19
  import {Assertions} from "../util/Assertions";
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
@@ -23,6 +23,7 @@ import {StateHolder} from "../core/ImplTypes";
23
23
  import {EventData} from "./EventData";
24
24
 
25
25
  import {
26
+ $faces,
26
27
  $nsp,
27
28
  APPLIED_CLIENT_WINDOW,
28
29
  APPLIED_VST,
@@ -30,32 +31,40 @@ import {
30
31
  ATTR_NAME,
31
32
  ATTR_URL,
32
33
  ATTR_VALUE,
34
+ DEFERRED_HEAD_INSERTS,
33
35
  EMPTY_FUNC,
34
36
  EMPTY_STR,
35
37
  ERROR_MESSAGE,
36
38
  ERROR_NAME,
37
- HTML_VIEWSTATE,
39
+ HTML_TAG_BODY,
40
+ HTML_TAG_FORM,
41
+ HTML_TAG_HEAD,
42
+ HTML_TAG_LINK,
43
+ HTML_TAG_SCRIPT,
44
+ HTML_TAG_STYLE, IDENT_ALL, IDENT_NONE,
38
45
  ON_ERROR,
39
- ON_EVENT, P_CLIENT_WINDOW,
46
+ ON_EVENT,
47
+ P_CLIENT_WINDOW,
48
+ P_EXECUTE,
40
49
  P_PARTIAL_SOURCE,
50
+ P_RENDER,
51
+ P_RENDER_OVERRIDE,
41
52
  P_VIEWSTATE,
42
- RESPONSE_XML, SEL_CLIENT_WINDOW_ELEM,
43
- SEL_SCRIPTS_STYLES,
53
+ PARTIAL_ID,
54
+ RESPONSE_XML,
55
+ SEL_CLIENT_WINDOW_ELEM,
44
56
  SEL_VIEWSTATE_ELEM,
45
57
  SOURCE,
46
58
  SUCCESS,
47
- TAG_AFTER,
48
- TAG_ATTR,
49
- TAG_BEFORE,
50
- TAG_BODY,
51
- TAG_FORM,
52
- TAG_HEAD,
53
59
  UPDATE_ELEMS,
54
60
  UPDATE_FORMS,
55
- DEFERRED_HEAD_INSERTS
61
+ XML_TAG_AFTER,
62
+ XML_TAG_ATTR,
63
+ XML_TAG_BEFORE
56
64
  } from "../core/Const";
57
- import trim = Lang.trim;
58
65
  import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
66
+ import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
67
+ import trim = Lang.trim;
59
68
 
60
69
 
61
70
  /**
@@ -82,31 +91,38 @@ export class ResponseProcessor implements IResponseProcessor {
82
91
  * the data incoming must represent the html representation of the head itself one way or the other
83
92
  */
84
93
  replaceHead(shadowDocument: XMLQuery | DQ) {
85
- let shadowHead = shadowDocument.querySelectorAll(TAG_HEAD);
94
+ const shadowHead = shadowDocument.querySelectorAll(HTML_TAG_HEAD);
86
95
  if (!shadowHead.isPresent()) {
87
96
  return;
88
97
  }
98
+ const head = ExtDomQuery.querySelectorAll(HTML_TAG_HEAD);
99
+ // full replace we delete everything
100
+ head.childNodes.delete();
101
+ this.addToHead(shadowHead);
102
+ //we copy the attributes as well (just in case myfaces introduces the id in head)
103
+ head.copyAttrs(shadowHead);
104
+ }
89
105
 
90
- let oldHead = ExtDomQuery.querySelectorAll(TAG_HEAD);
91
-
92
- //delete all to avoid script and style overlays
93
- oldHead.querySelectorAll(SEL_SCRIPTS_STYLES).delete();
106
+ addToHead(shadowHead: XMLQuery | DQ) {
107
+ const mappedHeadData = new ExtDomQuery(shadowHead);
108
+ const scriptTags = [HTML_TAG_SCRIPT];
109
+ const nonExecutables = mappedHeadData.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) == -1);
110
+ nonExecutables.runHeadInserts(true);
94
111
 
95
- // we cannot replace new elements in the head, but we can eval the elements
96
- // eval means the scripts will get attached (eval script attach method)
97
- // but this is done by DomQuery not in this code
98
- this.storeForEval(shadowHead);
99
112
  //incoming either the outer head tag or its children
100
- //shadowHead = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
101
- //this.addToHead(shadowHead);
113
+ const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
114
+ // this is stored for "post" processing
115
+ // after the rest of the "physical build up", head before body
116
+ const scriptElements = nodesToAdd.stream
117
+ .filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1).collect(new DomQueryCollector());
118
+
119
+ this.addToHeadDeferred(scriptElements);
102
120
  }
103
121
 
104
- addToHead(newElements: XMLQuery | DQ) {
122
+ addToHeadDeferred(newElements: XMLQuery | DQ) {
105
123
  this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(newElements);
106
124
  }
107
125
 
108
-
109
-
110
126
  /**
111
127
  * replaces the body in the expected manner
112
128
  * which means the entire body content is refreshed
@@ -117,21 +133,21 @@ export class ResponseProcessor implements IResponseProcessor {
117
133
  */
118
134
  replaceBody(shadowDocument: XMLQuery | DQ) {
119
135
 
120
- let shadowBody = shadowDocument.querySelectorAll(TAG_BODY);
136
+ const shadowBody = shadowDocument.querySelectorAll(HTML_TAG_BODY);
121
137
  if (!shadowBody.isPresent()) {
122
138
  return;
123
139
  }
124
140
 
125
- let shadowInnerHTML: string = <string>shadowBody.html().value;
141
+ const shadowInnerHTML: string = <string>shadowBody.innerHTML;
126
142
 
127
- let resultingBody = <DQ>ExtDomQuery.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
128
- let updateForms = resultingBody.querySelectorAll(TAG_FORM);
143
+ const resultingBody = <DQ>ExtDomQuery.querySelectorAll(HTML_TAG_BODY);
144
+ const updateForms = resultingBody.querySelectorAll(HTML_TAG_FORM);
129
145
 
130
146
  // main difference, we cannot replace the body itself, but only its content
131
147
  // we need a separate step for post-processing the incoming
132
148
  // attributes, like classes, styles etc...
133
- resultingBody.copyAttrs(shadowBody);
134
-
149
+ (resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
150
+ this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
135
151
  this.storeForPostProcessing(updateForms, resultingBody);
136
152
  }
137
153
 
@@ -158,18 +174,18 @@ export class ResponseProcessor implements IResponseProcessor {
158
174
  * <error>
159
175
  */
160
176
 
161
- let mergedErrorData = new ExtConfig({});
177
+ const mergedErrorData = new ExtConfig({});
162
178
  mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
163
179
  mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
164
180
  mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
165
181
 
166
- let hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
182
+ const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
167
183
 
168
184
  //we now store the response xml also in the error data for further details
169
185
  mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
170
186
 
171
187
  // error post-processing and enrichment (standard messages from keys)
172
- let errorData = ErrorData.fromServerError(mergedErrorData);
188
+ const errorData = ErrorData.fromServerError(mergedErrorData);
173
189
 
174
190
  // we now trigger an internally stored onError function which might be an attached to the context
175
191
  // either we do not have an internal on error, or an on error has been based via params from the outside.
@@ -187,7 +203,7 @@ export class ResponseProcessor implements IResponseProcessor {
187
203
  redirect(node: XMLQuery) {
188
204
  Assertions.assertUrlExists(node);
189
205
 
190
- let redirectUrl = trim(node.attr(ATTR_URL).value);
206
+ const redirectUrl = trim(node.attr(ATTR_URL).value);
191
207
  if (redirectUrl != EMPTY_STR) {
192
208
  window.location.href = redirectUrl;
193
209
  }
@@ -199,8 +215,8 @@ export class ResponseProcessor implements IResponseProcessor {
199
215
  * @param cdataBlock the cdata block with the new html code
200
216
  */
201
217
  update(node: XMLQuery, cdataBlock: string) {
202
- let result = ExtDomQuery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
203
- let sourceForm = result?.parents(TAG_FORM).orElseLazy(() => result.byTagName(TAG_FORM, true));
218
+ const result = ExtDomQuery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
219
+ const sourceForm = result?.firstParent(HTML_TAG_FORM).orElseLazy(() => result.byTagName(HTML_TAG_FORM, true));
204
220
  if (sourceForm) {
205
221
  this.storeForPostProcessing(sourceForm, result);
206
222
  }
@@ -220,9 +236,9 @@ export class ResponseProcessor implements IResponseProcessor {
220
236
  * @param node
221
237
  */
222
238
  attributes(node: XMLQuery) {
223
- let elem = DQ.byId(node.id.value, true);
239
+ const elem = DQ.byId(node.id.value, true);
224
240
 
225
- node.byTagName(TAG_ATTR).each((item: XMLQuery) => {
241
+ node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
226
242
  elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
227
243
  });
228
244
  }
@@ -243,17 +259,17 @@ export class ResponseProcessor implements IResponseProcessor {
243
259
  insert(node: XMLQuery) {
244
260
  //let insertId = node.id; //not used atm
245
261
 
246
- let before = node.attr(TAG_BEFORE);
247
- let after = node.attr(TAG_AFTER);
262
+ const before = node.attr(XML_TAG_BEFORE);
263
+ const after = node.attr(XML_TAG_AFTER);
248
264
 
249
- let insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
265
+ const insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
250
266
 
251
267
  if (before.isPresent()) {
252
268
  DQ.byId(before.value, true).insertBefore(insertNodes);
253
269
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
254
270
  }
255
271
  if (after.isPresent()) {
256
- let domQuery = DQ.byId(after.value, true);
272
+ const domQuery = DQ.byId(after.value, true);
257
273
  domQuery.insertAfter(insertNodes);
258
274
 
259
275
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -266,12 +282,12 @@ export class ResponseProcessor implements IResponseProcessor {
266
282
  * @param node the node hosting the insert data
267
283
  */
268
284
  insertWithSubTags(node: XMLQuery) {
269
- let before = node.querySelectorAll(TAG_BEFORE);
270
- let after = node.querySelectorAll(TAG_AFTER);
285
+ const before = node.querySelectorAll(XML_TAG_BEFORE);
286
+ const after = node.querySelectorAll(XML_TAG_AFTER);
271
287
 
272
288
  before.each(item => {
273
- let insertId = item.attr(ATTR_ID);
274
- let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
289
+ const insertId = item.attr(ATTR_ID);
290
+ const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
275
291
  if (insertId.isPresent()) {
276
292
  DQ.byId(insertId.value, true).insertBefore(insertNodes);
277
293
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -279,8 +295,8 @@ export class ResponseProcessor implements IResponseProcessor {
279
295
  });
280
296
 
281
297
  after.each(item => {
282
- let insertId = item.attr(ATTR_ID);
283
- let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
298
+ const insertId = item.attr(ATTR_ID);
299
+ const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
284
300
  if (insertId.isPresent()) {
285
301
  DQ.byId(insertId.value, true).insertAfter(insertNodes);
286
302
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -295,7 +311,7 @@ export class ResponseProcessor implements IResponseProcessor {
295
311
  */
296
312
  processViewState(node: XMLQuery): boolean {
297
313
  if (ResponseProcessor.isViewStateNode(node)) {
298
- let state = node.cDATAAsString;
314
+ const state = node.cDATAAsString;
299
315
  this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
300
316
  return true;
301
317
  }
@@ -304,7 +320,7 @@ export class ResponseProcessor implements IResponseProcessor {
304
320
 
305
321
  processClientWindow(node: XMLQuery): boolean {
306
322
  if (ResponseProcessor.isClientWindowNode(node)) {
307
- let state = node.cDATAAsString;
323
+ const state = node.cDATAAsString;
308
324
  this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
309
325
  return true;
310
326
  }
@@ -333,29 +349,29 @@ export class ResponseProcessor implements IResponseProcessor {
333
349
  */
334
350
  fixViewStates() {
335
351
  Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
336
- .each((item: Array<any>) => {
337
- let value: StateHolder = item[1];
338
- let nameSpace = DQ.byId(value.nameSpace, true).orElse(document.body);
339
- let affectedForms = nameSpace.byTagName(TAG_FORM);
340
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
352
+ .each(([, value]) => {
353
+ const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
354
+ const affectedForms = this.getContainerForms(namingContainerId)
355
+ .filter(affectedForm => this.isInExecuteOrRender(affectedForm));
341
356
 
342
- this.appendViewStateToForms(new DomQuery(affectedForms, affectedForms2), value.value);
357
+ this.appendViewStateToForms(affectedForms, value.value, namingContainerId.orElse("").value);
343
358
  });
344
359
  }
345
360
 
361
+
362
+
346
363
  /**
347
364
  * same as with view states before applies the incoming client windows as last step after the rest of the processing
348
365
  * is done.
349
366
  */
350
367
  fixClientWindow() {
351
368
  Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
352
- .each((item: Array<any>) => {
353
- let value: StateHolder = item[1];
354
- let nameSpace = DQ.byId(value.nameSpace, true).orElse(document.body);
355
- let affectedForms = nameSpace.byTagName(TAG_FORM);
356
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
369
+ .each(([, value]) => {
370
+ const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
371
+ const affectedForms = this.getContainerForms(namingContainerId)
372
+ .filter(affectedForm => this.isInExecuteOrRender(affectedForm));
357
373
 
358
- this.appendClientWindowToForms(new DomQuery(affectedForms, affectedForms2), value.value);
374
+ this.appendClientWindowToForms(affectedForms, value.value, namingContainerId.orElse("").value);
359
375
  });
360
376
  }
361
377
 
@@ -363,10 +379,10 @@ export class ResponseProcessor implements IResponseProcessor {
363
379
  * all processing done we can close the request and send the appropriate events
364
380
  */
365
381
  done() {
366
- let eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
382
+ const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
367
383
 
368
384
  //because some frameworks might decorate them over the context in the response
369
- let eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
385
+ const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
370
386
  Implementation.sendEvent(eventData, eventHandler);
371
387
  }
372
388
 
@@ -375,9 +391,10 @@ export class ResponseProcessor implements IResponseProcessor {
375
391
  *
376
392
  * @param forms the forms to append the viewState to
377
393
  * @param viewState the final viewState
394
+ * @param namingContainerId
378
395
  */
379
- private appendViewStateToForms(forms: DQ, viewState: string) {
380
- this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState);
396
+ private appendViewStateToForms(forms: DQ, viewState: string, namingContainerId = "") {
397
+ this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState, namingContainerId);
381
398
  }
382
399
 
383
400
 
@@ -386,9 +403,10 @@ export class ResponseProcessor implements IResponseProcessor {
386
403
  *
387
404
  * @param forms the forms to append the viewState to
388
405
  * @param clientWindow the final viewState
406
+ * @param namingContainerId
389
407
  */
390
- private appendClientWindowToForms(forms: DQ, clientWindow: string) {
391
- this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow);
408
+ private appendClientWindowToForms(forms: DQ, clientWindow: string, namingContainerId = "") {
409
+ this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow, namingContainerId);
392
410
  }
393
411
 
394
412
  /**
@@ -398,29 +416,28 @@ export class ResponseProcessor implements IResponseProcessor {
398
416
  * @param selector the selector for the state
399
417
  * @param state the state itself which needs to be assigned
400
418
  *
419
+ * @param namingContainerId
401
420
  * @private
402
421
  */
403
- private assignState(forms: DQ, selector: string, state: string) {
404
- forms.each((form: DQ) => {
405
- let stateHolders = form.querySelectorAll(selector)
406
- .orElseLazy(() => ResponseProcessor.newViewStateElement(form));
407
-
408
- stateHolders.attr("value").value = state;
422
+ private assignState(forms: DQ, selector: string, state: string, namingContainerId: string) {
423
+ /**
424
+ * creates the viewState or client window id element
425
+ * @param form
426
+ */
427
+ const createAndAppendHiddenInput = (form: DomQuery) => {
428
+ return new HiddenInputBuilder(selector)
429
+ .withNamingContainerId(namingContainerId)
430
+ .withParent(form)
431
+ .build();
432
+ };
433
+
434
+ forms.each(form => {
435
+ const hiddenInput = form.querySelectorAll(selector)
436
+ .orElseLazy(() => createAndAppendHiddenInput(form));
437
+ hiddenInput.val = state;
409
438
  });
410
439
  }
411
440
 
412
- /**
413
- * Helper to Create a new JSF ViewState Element
414
- *
415
- * @param parent, the parent node to attach the viewState element to
416
- * (usually a form node)
417
- */
418
- private static newViewStateElement(parent: DQ): DQ {
419
- let newViewState = DQ.fromMarkup($nsp(HTML_VIEWSTATE));
420
- newViewState.appendTo(parent);
421
- return newViewState;
422
- }
423
-
424
441
  /**
425
442
  * Stores certain aspects of the dom for later post-processing
426
443
  *
@@ -457,10 +474,10 @@ export class ResponseProcessor implements IResponseProcessor {
457
474
  * @returns if it is a viewState node
458
475
  */
459
476
  private static isViewStateNode(node: XMLQuery): boolean {
460
- let separatorChar = (window?.faces ?? window?.jsf).separatorchar;
477
+ const SEP = $faces().separatorchar;
461
478
  return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_VIEWSTATE) ||
462
- node?.id?.value?.indexOf([separatorChar, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
463
- node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), separatorChar].join(EMPTY_STR)) != -1);
479
+ node?.id?.value?.indexOf([SEP, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
480
+ node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), SEP].join(EMPTY_STR)) != -1);
464
481
  }
465
482
 
466
483
  /**
@@ -470,15 +487,59 @@ export class ResponseProcessor implements IResponseProcessor {
470
487
  * @returns true of it ii
471
488
  */
472
489
  private static isClientWindowNode(node: XMLQuery): boolean {
473
- let separatorChar = (window?.faces ?? window?.jsf).separatorchar;
490
+ const SEP = $faces().separatorchar;
474
491
  return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_CLIENT_WINDOW) ||
475
- node?.id?.value?.indexOf([separatorChar, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
476
- node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), separatorChar].join(EMPTY_STR)) != -1);
492
+ node?.id?.value?.indexOf([SEP, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
493
+ node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), SEP].join(EMPTY_STR)) != -1);
477
494
  }
478
495
 
479
496
  private triggerOnError(errorData: ErrorData) {
480
- this.externalContext.getIf(ON_ERROR).orElse(this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
497
+ this.externalContext.getIf(ON_ERROR).orElseLazy(() => this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
481
498
  }
482
499
 
500
+ /**
501
+ * filters the forms according to being member of the "execute" or "render" cycle
502
+ * @param affectedForm
503
+ * @private
504
+ */
505
+ private isInExecuteOrRender(affectedForm) {
506
+ const executes = this.externalContext.getIf($nsp(P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
507
+ const renders = this.externalContext.getIf(P_RENDER_OVERRIDE)
508
+ .orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
509
+ .orElse(IDENT_NONE).value.split(/\s+/gi);
510
+ const executeAndRenders = executes.concat(...renders);
511
+ return LazyStream.of(...executeAndRenders).filter(nameOrId => {
512
+ if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
513
+ return true;
514
+ }
515
+
516
+ const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
517
+ //either the form directly is in execute or render or one of its children or one of its parents
518
+ return affectedForm.matchesSelector(NAME_OR_ID) ||
519
+ affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
520
+ affectedForm.firstParent(NAME_OR_ID).isPresent();
521
+ }).first().isPresent();
522
+ }
483
523
 
524
+ /**
525
+ * gets all forms under a single naming container id
526
+ * @param namingContainerId
527
+ * @private
528
+ */
529
+ private getContainerForms(namingContainerId: Config) {
530
+ if (namingContainerId.isPresent()) {
531
+ //naming container mode, all forms under naming container id must be processed
532
+ return DQ$(this.getNameOrIdSelector(namingContainerId.value))
533
+ // missing condition if the naming container is not present we have to
534
+ // use the body as fallback
535
+ .orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
536
+ .byTagName(HTML_TAG_FORM, true);
537
+ } else {
538
+ return DQ.byTagName(HTML_TAG_FORM);
539
+ }
540
+ }
541
+
542
+ private getNameOrIdSelector(nameOrId) {
543
+ return `[id='${nameOrId}'], [name='${nameOrId}']`;
544
+ }
484
545
  }
@@ -109,7 +109,7 @@ export class XhrFormData extends Config {
109
109
  * @param form the form holding the view state value
110
110
  */
111
111
  private applyViewState(form: DQ) {
112
- let viewState = form.byId(P_VIEWSTATE, true).inputValue;
112
+ let viewState = form.querySelectorAllDeep(`[name*='${P_VIEWSTATE}'`).inputValue;
113
113
  this.appendIf(viewState.isPresent(), P_VIEWSTATE).value = viewState.value;
114
114
  }
115
115
 
@@ -23,20 +23,21 @@ import {ErrorData} from "./ErrorData";
23
23
  import {EventData} from "./EventData";
24
24
  import {ExtLang} from "../util/Lang";
25
25
  import {
26
+ $faces,
26
27
  BEGIN,
27
28
  COMPLETE,
28
29
  CONTENT_TYPE,
29
30
  CTX_PARAM_MF_INTERNAL,
30
- CTX_PARAM_PASS_THR,
31
+ CTX_PARAM_REQ_PASS_THR,
31
32
  ERROR,
32
33
  HEAD_FACES_REQ,
33
34
  MALFORMEDXML,
34
35
  NO_TIMEOUT,
35
36
  ON_ERROR,
36
- ON_EVENT, P_EXECUTE,
37
+ ON_EVENT, P_EXECUTE, P_PARTIAL_SOURCE,
37
38
  REQ_ACCEPT,
38
39
  REQ_TYPE_GET,
39
- REQ_TYPE_POST,
40
+ REQ_TYPE_POST, SOURCE,
40
41
  STATE_EVT_TIMEOUT,
41
42
  STD_ACCEPT,
42
43
  URL_ENCODED,
@@ -44,6 +45,7 @@ import {
44
45
  } from "../core/Const";
45
46
  import {resolveFinalUrl, resolveHandlerFunc} from "./RequestDataResolver";
46
47
  import failSaveExecute = ExtLang.failSaveExecute;
48
+ import {ExtConfig} from "../util/ExtDomQuery";
47
49
 
48
50
  /**
49
51
  * Faces XHR Request Wrapper
@@ -86,7 +88,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
86
88
  constructor(
87
89
  private source: DQ,
88
90
  private sourceForm: DQ,
89
- private requestContext: Config,
91
+ private requestContext: ExtConfig,
90
92
  private internalContext: Config,
91
93
  private partialIdsArray = [],
92
94
  private timeout = NO_TIMEOUT,
@@ -111,12 +113,12 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
111
113
  let xhrObject = this.xhrObject;
112
114
 
113
115
  let executesArr = () => {
114
- return this.requestContext.getIf(CTX_PARAM_PASS_THR, P_EXECUTE).get("none").value.split(/\s+/gi);
116
+ return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get("none").value.split(/\s+/gi);
115
117
  };
116
118
  try {
117
119
 
118
120
  let formElement = this.sourceForm.getAsElem(0).value;
119
- let viewState = (window?.faces ?? window?.jsf).getViewState(formElement);
121
+ let viewState = $faces().getViewState(formElement);
120
122
  // encoded we need to decode
121
123
  // We generated a base representation of the current form
122
124
  // in case someone has overloaded the viewState with additional decorators we merge
@@ -131,15 +133,22 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
131
133
  this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
132
134
 
133
135
  // next step the pass through parameters are merged in for post params
136
+ this.requestContext.$nspEnabled = false;
134
137
  let requestContext = this.requestContext;
135
- let passThroughParams = requestContext.getIf(CTX_PARAM_PASS_THR);
136
-
138
+ let requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
139
+ requestPassThroughParams.$nspEnabled = false;
137
140
  // this is an extension where we allow pass through parameters to be sent down additionally
138
141
  // this can be used and is used in the impl to enrich the post request parameters with additional
139
142
  // information
140
- formData.shallowMerge(passThroughParams, true, true);
141
143
 
142
- this.responseContext = passThroughParams.deepCopy;
144
+ try {
145
+ formData.shallowMerge(requestPassThroughParams, true, true);
146
+ } finally {
147
+ this.requestContext.$nspEnabled = true;
148
+ requestPassThroughParams.$nspEnabled = true;
149
+ }
150
+
151
+ this.responseContext = requestPassThroughParams.deepCopy;
143
152
 
144
153
  // we have to shift the internal passthroughs around to build up our response context
145
154
  let responseContext = this.responseContext;
@@ -290,7 +299,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
290
299
  return;
291
300
  }
292
301
 
293
- (window?.faces ?? window.jsf).ajax.response(this.xhrObject, this.responseContext.value ?? {});
302
+ $faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
294
303
  }
295
304
 
296
305
  private handleMalFormedXML(resolve: Function) {
@@ -300,9 +309,9 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
300
309
  status: MALFORMEDXML,
301
310
  responseCode: 200,
302
311
  responseText: this.xhrObject?.responseText,
303
- source: {
304
- id: this.source.id.value
305
- }
312
+ // we remap the element just in case it gets replaced
313
+ // it will be unremapped
314
+ source: this.source.id.value
306
315
  };
307
316
  try {
308
317
  this.handleError(errorData, true);
@@ -352,6 +361,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
352
361
 
353
362
  Implementation.sendEvent(eventData, eventHandler);
354
363
  } catch (e) {
364
+ e.source = e?.source ?? this.requestContext.getIf(SOURCE).value;
355
365
  this.handleError(e);
356
366
  throw e;
357
367
  }