jsf.js_next_gen 4.0.0-beta-23 → 4.0.0

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 (200) hide show
  1. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  2. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  3. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  4. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/README.md +7 -22
  7. package/dist/docs/assets/main.js +56 -52
  8. package/dist/docs/assets/search.js +1 -1
  9. package/dist/docs/assets/style.css +23 -0
  10. package/dist/docs/functions/faces.ajax.addOnError.html +6 -4
  11. package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
  12. package/dist/docs/functions/faces.ajax.request.html +7 -7
  13. package/dist/docs/functions/faces.ajax.response.html +0 -1
  14. package/dist/docs/functions/faces.push.close.html +4 -2
  15. package/dist/docs/functions/faces.push.init.html +19 -7
  16. package/dist/docs/functions/faces.push.open.html +4 -2
  17. package/dist/docs/functions/faces.util.chain.html +3 -3
  18. package/dist/docs/functions/myfaces.ab.html +9 -4
  19. package/dist/docs/functions/myfaces.onOnDomReady.html +72 -0
  20. package/dist/docs/index.html +7 -18
  21. package/dist/docs/modules/myfaces.html +3 -1
  22. package/dist/docs/variables/myfaces.oam.html +2 -1
  23. package/dist/window/faces-development.js +2147 -1779
  24. package/dist/window/faces-development.js.br +0 -0
  25. package/dist/window/faces-development.js.gz +0 -0
  26. package/dist/window/faces-development.js.map +1 -1
  27. package/dist/window/faces.js +1 -1
  28. package/dist/window/faces.js.LICENSE.txt +17 -2
  29. package/dist/window/faces.js.br +0 -0
  30. package/dist/window/faces.js.gz +0 -0
  31. package/dist/window/faces.js.map +1 -1
  32. package/dist/window/jsf-development.js +2156 -1777
  33. package/dist/window/jsf-development.js.br +0 -0
  34. package/dist/window/jsf-development.js.gz +0 -0
  35. package/dist/window/jsf-development.js.map +1 -1
  36. package/dist/window/jsf.js +1 -1
  37. package/dist/window/jsf.js.LICENSE.txt +17 -2
  38. package/dist/window/jsf.js.br +0 -0
  39. package/dist/window/jsf.js.gz +0 -0
  40. package/dist/window/jsf.js.map +1 -1
  41. package/package.json +19 -18
  42. package/pom.xml +1 -1
  43. package/src/main/test.xml +23 -0
  44. package/src/main/typescript/@types/definitions/index.d.ts +24 -7
  45. package/src/main/typescript/api/_api.ts +79 -37
  46. package/src/main/typescript/api/jsf.ts +18 -0
  47. package/src/main/typescript/impl/AjaxImpl.ts +168 -78
  48. package/src/main/typescript/impl/PushImpl.ts +63 -38
  49. package/src/main/typescript/impl/core/Const.ts +52 -39
  50. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  51. package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
  52. package/src/main/typescript/impl/util/AsyncRunnable.ts +4 -4
  53. package/src/main/typescript/impl/util/ExtDomQuery.ts +58 -45
  54. package/src/main/typescript/impl/util/FileUtils.ts +104 -0
  55. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
  56. package/src/main/typescript/impl/util/Lang.ts +30 -31
  57. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  58. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  59. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
  60. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
  61. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
  62. package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
  63. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +202 -131
  64. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +79 -166
  65. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -68
  66. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  67. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +19 -22
  68. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +108 -1
  69. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  70. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  71. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
  72. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  73. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  74. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  75. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  76. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  77. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +242 -11
  78. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  79. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +373 -35
  80. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  81. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
  82. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  83. package/src/main/typescript/test.xml +6 -0
  84. package/src/main/typescript/tsconfig.json +1 -1
  85. package/src/test/resources/jsf-development.js +1 -1
  86. package/src/tmp/test.html +12 -88
  87. package/target/api/_api.js +72 -31
  88. package/target/api/_api.js.map +1 -1
  89. package/target/api/jsf.js +11 -0
  90. package/target/api/jsf.js.map +1 -1
  91. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  92. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  93. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  94. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  95. package/target/impl/AjaxImpl.js +144 -59
  96. package/target/impl/AjaxImpl.js.map +1 -1
  97. package/target/impl/PushImpl.js +66 -35
  98. package/target/impl/PushImpl.js.map +1 -1
  99. package/target/impl/core/Const.js +51 -38
  100. package/target/impl/core/Const.js.map +1 -1
  101. package/target/impl/core/Context.js +10 -0
  102. package/target/impl/core/Context.js.map +1 -0
  103. package/target/impl/util/Assertions.js +12 -7
  104. package/target/impl/util/Assertions.js.map +1 -1
  105. package/target/impl/util/AsyncQueue.js.map +1 -1
  106. package/target/impl/util/ExtDomQuery.js +58 -40
  107. package/target/impl/util/ExtDomQuery.js.map +1 -1
  108. package/target/impl/util/FileUtils.js +96 -0
  109. package/target/impl/util/FileUtils.js.map +1 -0
  110. package/target/impl/util/HiddenElementBuilder.js +7 -0
  111. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  112. package/target/impl/util/HiddenInputBuilder.js +79 -0
  113. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  114. package/target/impl/util/Lang.js +29 -30
  115. package/target/impl/util/Lang.js.map +1 -1
  116. package/target/impl/util/URLCodec.js +77 -0
  117. package/target/impl/util/URLCodec.js.map +1 -0
  118. package/target/impl/util/XhrQueueController.js +82 -0
  119. package/target/impl/util/XhrQueueController.js.map +1 -0
  120. package/target/impl/xhrCore/ErrorData.js +10 -8
  121. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  122. package/target/impl/xhrCore/EventData.js +1 -1
  123. package/target/impl/xhrCore/EventData.js.map +1 -1
  124. package/target/impl/xhrCore/RequestContext.js +11 -0
  125. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  126. package/target/impl/xhrCore/RequestDataResolver.js +70 -23
  127. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  128. package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
  129. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  130. package/target/impl/xhrCore/Response.js +44 -29
  131. package/target/impl/xhrCore/Response.js.map +1 -1
  132. package/target/impl/xhrCore/ResponseProcessor.js +182 -116
  133. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  134. package/target/impl/xhrCore/XhrFormData.js +68 -156
  135. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  136. package/target/impl/xhrCore/XhrQueHandler.js +11 -0
  137. package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
  138. package/target/impl/xhrCore/XhrQueueController.js +62 -0
  139. package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
  140. package/target/impl/xhrCore/XhrRequest.js +68 -59
  141. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  142. package/target/myfaces/OamSubmit.js +23 -14
  143. package/target/myfaces/OamSubmit.js.map +1 -1
  144. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +16 -16
  145. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  146. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
  147. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
  148. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
  149. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
  150. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
  151. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
  152. package/target/test/frameworkBase/_ext/shared/StandardInits.js +100 -1
  153. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  154. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  155. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  156. package/target/test/impl/ImplTest.spec.js +2 -2
  157. package/target/test/impl/ImplTest.spec.js.map +1 -1
  158. package/target/test/impl/ImplTest_23.spec.js +2 -2
  159. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  160. package/target/test/myfaces/OnLoadSpec.js +57 -0
  161. package/target/test/myfaces/OnLoadSpec.js.map +1 -0
  162. package/target/test/xhrCore/EventTests.spec.js +1 -1
  163. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  164. package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
  165. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  166. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  167. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  168. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  169. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  170. package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
  171. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  172. package/target/test/xhrCore/RequestTest.spec.js +217 -9
  173. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  174. package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
  175. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  176. package/target/test/xhrCore/ResponseTest.spec.js +308 -24
  177. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  178. package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
  179. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  180. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
  181. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
  182. package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
  183. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  184. package/target/test-classes/.gz +0 -0
  185. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  186. package/target/test-classes/fileuploadtest.html +24 -0
  187. package/target/test-classes/jsf-development.js +3559 -0
  188. package/target/test-classes/jsf-development.js.br +0 -0
  189. package/target/test-classes/jsf-development.js.gz +0 -0
  190. package/target/test-classes/jsf-development.js.map +1 -0
  191. package/target/test-classes/jsf.js +3 -0
  192. package/target/test-classes/jsf.js.br +0 -0
  193. package/target/test-classes/jsf.js.gz +0 -0
  194. package/tmp.xml +36 -0
  195. package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  196. package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  197. package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  198. package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  199. package/target/types/index.js +0 -18
  200. package/target/types/index.js.map +0 -1
@@ -20,19 +20,16 @@ import {XhrRequest} from "./xhrCore/XhrRequest";
20
20
  import {AsynchronousQueue} from "./util/AsyncQueue";
21
21
  import {AssocArrayCollector, Config, DQ, Lang, LazyStream, Optional, Stream} from "mona-dish";
22
22
  import {Assertions} from "./util/Assertions";
23
- import {XhrFormData} from "./xhrCore/XhrFormData";
24
- import {ExtDomquery} from "./util/ExtDomQuery";
23
+ import {ExtConfig, ExtDomQuery} from "./util/ExtDomQuery";
25
24
  import {ErrorData} from "./xhrCore/ErrorData";
26
25
  import {EventData} from "./xhrCore/EventData";
27
26
  import {ExtLang} from "./util/Lang";
28
27
 
29
28
  import {
30
- $nsp,
31
- CTX_PARAM_EXECUTE,
32
- CTX_PARAM_PASS_THR,
29
+ CTX_OPTIONS_EXECUTE,
30
+ CTX_PARAM_REQ_PASS_THR,
33
31
  CTX_PARAM_SRC_CTL_ID,
34
32
  CTX_PARAM_SRC_FRM_ID,
35
- CTX_PARAM_TR_TYPE,
36
33
  IDENT_ALL,
37
34
  IDENT_FORM,
38
35
  IDENT_NONE,
@@ -49,19 +46,23 @@ import {
49
46
  P_RESET_VALUES,
50
47
  P_WINDOW_ID,
51
48
  CTX_PARAM_RENDER,
52
- REQ_TYPE_POST,
53
49
  SOURCE,
54
- TAG_FORM
50
+ HTML_TAG_FORM,
51
+ CTX_OPTIONS_PARAMS,
52
+ VIEW_ID,
53
+ $faces,
54
+ EMPTY_STR,
55
+ CTX_PARAM_MF_INTERNAL,
56
+ NAMED_VIEWROOT,
57
+ NAMING_CONTAINER_ID
55
58
  } from "./core/Const";
56
59
  import {
57
60
  resolveDefaults,
58
61
  resolveDelay,
59
62
  resolveForm,
60
- resolveTimeout
63
+ resolveTimeout, resolveViewId, resolveViewRootId, resoveNamingContainerMapper
61
64
  } from "./xhrCore/RequestDataResolver";
62
-
63
-
64
- declare var faces: any;
65
+ import {encodeFormData} from "./util/FileUtils";
65
66
 
66
67
  /*
67
68
  * allowed project stages
@@ -74,8 +75,8 @@ enum ProjectStages {
74
75
  }
75
76
 
76
77
  /*
77
- * blockfilter for the passthrough filtering; the attributes given here
78
- * will not be transmitted from the options into the passthrough
78
+ * Block-filter for the pass-through filtering; the attributes given here
79
+ * will not be transmitted from the options into the pass-through
79
80
  */
80
81
  enum BlockFilter {
81
82
  onerror = "onerror",
@@ -85,7 +86,9 @@ enum BlockFilter {
85
86
  myfaces = "myfaces",
86
87
  delay = "delay",
87
88
  timeout = "timeout",
88
- windowId = "windowId"
89
+ resetValues = "resetValues",
90
+ windowId = "windowId",
91
+ params = "params"
89
92
  }
90
93
 
91
94
  /**
@@ -109,11 +112,15 @@ export module Implementation {
109
112
  a) Monad like structures for querying because this keeps the code denser and adds abstractions
110
113
  that always was the strong point of jquery and it still is better in this regard than what ecmascript provides
111
114
 
112
- b) Streams and lazystreams like java has, a pull like construct, ecmascript does not have anything like Lazystreams.
115
+ b) Streams and lazy streams like java has, a pull stream construct, ecmascript does not have anything like it.
116
+ (it has array filters and maps, but ES2015 does not support flatMap)
113
117
  Another option would have been rxjs but that would have introduced a code dependency and probably more code. We might
114
- move to RXJS if the need arises however. But for now I would rather stick with my small self grown library which works
118
+ move to RXJS if the need arises, however. But for now I would rather stick with my small self grown library which works
115
119
  quite well and where I can patch quickly (I have used it in several industrial projects, so it works well
116
120
  and is heavily fortified by unit tests (140 testcases as time of writing this))
121
+ The long term plan is to eliminate the Stream usage as soon as we can move up to ES2019 (adding the missing
122
+ functions as shims, is a no go, because we are a library, and absolutey do not Shim anything which can leak
123
+ into the global namespace!)
117
124
 
118
125
  c) A neutral json like configuration which allows assignments of arbitrary values with reduce code which then can be
119
126
  transformed into different data representations
@@ -167,21 +174,9 @@ export module Implementation {
167
174
  export function getSeparatorChar(): string {
168
175
  return resolveGlobalConfig()?.separator ??
169
176
  this?.separator ??
170
- (separator = ExtDomquery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
177
+ (separator = ExtDomQuery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
171
178
  }
172
179
 
173
- /**
174
- * fetches the separator char from the given script tags
175
- *
176
- * @return {string} the separator char for the given script tags
177
- */
178
- export function getContextPath(): string {
179
- return resolveGlobalConfig()?.separator ??
180
- this?.separator ??
181
- (separator = ExtDomquery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
182
- }
183
-
184
-
185
180
  /**
186
181
  * this is for testing purposes only, since AjaxImpl is a module
187
182
  * we need to reset for every unit test its internal states
@@ -197,7 +192,7 @@ export module Implementation {
197
192
  /**
198
193
  * @return the project stage also emitted by the server:
199
194
  * it cannot be cached and must be delivered over the server
200
- * The value for it comes from the requestInternal parameter of the faces.js script called "stage".
195
+ * The value for it comes from the request parameter of the faces.js script called "stage".
201
196
  */
202
197
  export function getProjectStage(): string | null {
203
198
  return resolveGlobalConfig()?.projectStage ??
@@ -212,8 +207,8 @@ export module Implementation {
212
207
  export function resolveProjectStateFromURL(): string | null {
213
208
 
214
209
  /* run through all script tags and try to find the one that includes faces.js */
215
- const foundStage = ExtDomquery.searchJsfJsFor(/stage=([^&;]*)/).value as string;
216
- return (foundStage in ProjectStages) ? foundStage : null;
210
+ const foundStage = ExtDomQuery.searchJsfJsFor(/stage=([^&;]*)/).value as string;
211
+ return (foundStage in ProjectStages) ? foundStage : ProjectStages.Production; // MYFACES-4572: default is production
217
212
  }
218
213
 
219
214
  /**
@@ -223,7 +218,7 @@ export module Implementation {
223
218
  * @param event
224
219
  * @param funcs
225
220
  */
226
- export function chain(source: any, event: Event, ...funcs: EvalFuncs): boolean {
221
+ export function chain(source: HTMLElement | string, event: Event | null, ...funcs: EvalFuncs): boolean {
227
222
  // we can use our lazy stream each functionality to run our chain here..
228
223
  // by passing a boolean as return value into the onElem call
229
224
  // we can stop early at the first false, just like the spec requests
@@ -257,15 +252,14 @@ export module Implementation {
257
252
  export function request(el: ElemDef, event?: Event, opts ?: Options) {
258
253
 
259
254
  const {
260
- resolvedEvent,
261
255
  options,
262
256
  elem,
263
257
  elementId,
264
- requestCtx,
265
- internalCtx,
266
258
  windowId,
267
259
  isResetValues
268
260
  } = resolveDefaults(event, opts, el);
261
+ const requestCtx = new ExtConfig({});
262
+ const internalCtx = new ExtConfig({});
269
263
 
270
264
  Assertions.assertRequestIntegrity(options, elem);
271
265
 
@@ -276,15 +270,28 @@ export module Implementation {
276
270
  * so that people can use dummy forms and work
277
271
  * with detached objects
278
272
  */
279
- const form: DQ = resolveForm(requestCtx, elem, resolvedEvent);
273
+ const form: DQ = resolveForm(elem, event);
274
+ const viewId: string = resolveViewId(form);
280
275
  const formId = form.id.value;
281
276
  const delay: number = resolveDelay(options);
282
277
  const timeout: number = resolveTimeout(options);
283
278
 
284
279
  requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;
285
280
 
286
- requestCtx.assign(CTX_PARAM_PASS_THR).value = filterPassthroughValues(options.value);
287
- requestCtx.assignIf(!!resolvedEvent, CTX_PARAM_PASS_THR, P_EVT).value = resolvedEvent?.type;
281
+ // old non spec behavior will be removed after it is clear whether the removal breaks any code
282
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR).value = extractLegacyParams(options.value);
283
+
284
+ // spec conform behavior, all passthrough params must be under "passthrough
285
+ const params = remapArrayToAssocArr(options.getIf(CTX_OPTIONS_PARAMS).orElse({}).value);
286
+ //we turn off the remapping for the param merge, because we do not want to have
287
+ //any namespacing to be remapped
288
+
289
+ let ctxPassthrough = requestCtx.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
290
+ ctxPassthrough.$nspEnabled = false;
291
+ ctxPassthrough.shallowMerge(new Config(params), true);
292
+ //now we turn it on again
293
+ ctxPassthrough.$nspEnabled = true;
294
+ requestCtx.assignIf(!!event, CTX_PARAM_REQ_PASS_THR, P_EVT).value = event?.type;
288
295
 
289
296
  /**
290
297
  * ajax pass through context with the source
@@ -292,6 +299,8 @@ export module Implementation {
292
299
  */
293
300
  requestCtx.assign(SOURCE).value = elementId;
294
301
 
302
+ requestCtx.assign(VIEW_ID).value = viewId;
303
+
295
304
  /**
296
305
  * on resolvedEvent and onError...
297
306
  * those values will be traversed later on
@@ -308,12 +317,12 @@ export module Implementation {
308
317
  /**
309
318
  * binding contract the jakarta.faces.source must be set
310
319
  */
311
- requestCtx.assign(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
320
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
312
321
 
313
322
  /**
314
323
  * jakarta.faces.partial.ajax must be set to true
315
324
  */
316
- requestCtx.assign(CTX_PARAM_PASS_THR, P_AJAX).value = true;
325
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_AJAX).value = true;
317
326
 
318
327
  /**
319
328
  * if resetValues is set to true
@@ -322,7 +331,7 @@ export module Implementation {
322
331
  * the value has to be explicitly true, according to
323
332
  * the specs jsdoc
324
333
  */
325
- requestCtx.assignIf(isResetValues, CTX_PARAM_PASS_THR, P_RESET_VALUES).value = true;
334
+ requestCtx.assignIf(isResetValues, CTX_PARAM_REQ_PASS_THR, P_RESET_VALUES).value = true;
326
335
 
327
336
  // additional meta information to speed things up, note internal non jsf
328
337
  // pass through options are stored under _mfInternal in the context
@@ -333,13 +342,13 @@ export module Implementation {
333
342
  // mojarra under blackbox conditions.
334
343
  // I assume it does the same as our formId_submit=1 so leaving it out
335
344
  // won't hurt but for the sake of compatibility we are going to add it
336
- requestCtx.assign(CTX_PARAM_PASS_THR, formId).value = formId;
345
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, formId).value = formId;
337
346
  internalCtx.assign(CTX_PARAM_SRC_CTL_ID).value = elementId;
338
- internalCtx.assign(CTX_PARAM_TR_TYPE).value = REQ_TYPE_POST;
339
347
 
340
348
  assignClientWindowId(form, requestCtx);
341
349
  assignExecute(options, requestCtx, form, elementId);
342
350
  assignRender(options, requestCtx, form, elementId);
351
+ assignNamingContainerData(internalCtx, form);
343
352
 
344
353
  //now we enqueue the request as asynchronous runnable into our request
345
354
  //queue and let the queue take over the rest
@@ -455,17 +464,17 @@ export module Implementation {
455
464
  const ALTERED = "___mf_id_altered__";
456
465
  const INIT = "___init____";
457
466
 
458
- /**
467
+ /*
459
468
  * the search root for the dom element search
460
469
  */
461
470
  let searchRoot = new DQ(node || document.body).querySelectorAll(`form input [name='${P_CLIENT_WINDOW}']`);
462
471
 
463
- /**
472
+ /*
464
473
  * lazy helper to fetch the window id from the window url
465
474
  */
466
- let fetchWindowIdFromUrl = () => ExtDomquery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;
475
+ let fetchWindowIdFromUrl = () => ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;
467
476
 
468
- /**
477
+ /*
469
478
  * functional double check based on stream reduction
470
479
  * the values should be identical or on INIT value which is a premise to
471
480
  * skip the first check
@@ -482,27 +491,26 @@ export module Implementation {
482
491
  return value2;
483
492
  };
484
493
 
485
- /**
494
+ /*
486
495
  * helper for cleaner code, maps the value from an item
487
496
  *
488
497
  * @param item
489
498
  */
490
499
  let getValue = (item: DQ) => item.attr("value").value;
491
- /**
500
+ /*
492
501
  * fetch the window id from the forms
493
502
  * window ids must be present in all forms
494
- * or non existent. If they exist all of them must be the same
503
+ * or non-existent. If they exist all of them must be the same
495
504
  */
496
505
 
497
- let formWindowId: Optional<string> = searchRoot.stream.map<string>(getValue).reduce(differenceCheck, INIT);
506
+ let formWindowId: Optional<string> = searchRoot.stream.map(getValue).reduce(differenceCheck, INIT);
498
507
 
499
508
 
500
509
  //if the resulting window id is set on altered then we have an unresolvable problem
501
510
  assert(ALTERED != formWindowId.value, "Multiple different windowIds found in document");
502
511
 
503
- /**
512
+ /*
504
513
  * return the window id or null
505
- * prio, forms under node/document and if not given then from the url
506
514
  */
507
515
  return formWindowId.value != INIT ? formWindowId.value : fetchWindowIdFromUrl();
508
516
  }
@@ -517,17 +525,23 @@ export module Implementation {
517
525
  */
518
526
  export function getViewState(form: Element | string): string {
519
527
  /**
520
- * typecheck assert!, we opt for strong typing here
528
+ * type-check assert!, we opt for strong typing here
521
529
  * because it makes it easier to detect bugs
522
530
  */
523
531
 
524
532
  let element: DQ = DQ.byId(form, true);
525
- if (!element.isTag(TAG_FORM)) {
533
+ if (!element.isTag(HTML_TAG_FORM)) {
526
534
  throw new Error(getMessage("ERR_VIEWSTATE"));
527
535
  }
528
536
 
529
- let formData = new XhrFormData(element);
530
- return formData.toString();
537
+ // determine the naming container scenario
538
+ const dummyContext = new Config({});
539
+ assignNamingContainerData(dummyContext, DQ.byId(form))
540
+ // fetch all non file input form elements
541
+ let formElements = element.deepElements.encodeFormElement()
542
+
543
+ // encode them! (file inputs are handled differently and are not part of the viewstate)
544
+ return encodeFormData(formElements, resoveNamingContainerMapper(dummyContext));
531
545
  }
532
546
 
533
547
  /**
@@ -537,11 +551,11 @@ export module Implementation {
537
551
  */
538
552
  export let queueHandler = {
539
553
  /**
540
- * public to make it shimmable for tests
554
+ * public to make it accessible for tests
541
555
  *
542
556
  * adds a new request to our queue for further processing
543
557
  */
544
- addRequestToQueue: function (elem: DQ, form: DQ, reqCtx: Config, respPassThr: Config, delay = 0, timeout = 0) {
558
+ addRequestToQueue: function (elem: DQ, form: DQ, reqCtx: ExtConfig, respPassThr: Config, delay = 0, timeout = 0) {
545
559
  requestQueue = requestQueue ?? new AsynchronousQueue<XhrRequest>();
546
560
  requestQueue.enqueue(new XhrRequest(elem, form, reqCtx, respPassThr, [], timeout), delay);
547
561
  }
@@ -563,7 +577,7 @@ export module Implementation {
563
577
  */
564
578
  function assignRender(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
565
579
  if (requestOptions.getIf(CTX_PARAM_RENDER).isPresent()) {
566
- remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_RENDER, <string>requestOptions.getIf(CTX_PARAM_RENDER).value, issuingForm, <any>sourceElementId);
580
+ remapDefaultConstants(targetContext.getIf(CTX_PARAM_REQ_PASS_THR).get({}), P_RENDER, <string>requestOptions.getIf(CTX_PARAM_RENDER).value, issuingForm, <any>sourceElementId, targetContext.getIf(VIEW_ID).value);
567
581
  }
568
582
  }
569
583
 
@@ -581,15 +595,15 @@ export module Implementation {
581
595
  */
582
596
  function assignExecute(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
583
597
 
584
- if (requestOptions.getIf(CTX_PARAM_EXECUTE).isPresent()) {
598
+ if (requestOptions.getIf(CTX_OPTIONS_EXECUTE).isPresent()) {
585
599
  /*the options must be a blank delimited list of strings*/
586
600
  /*compliance with Mojarra which automatically adds @this to an execute
587
601
  * the spec rev 2.0a however states, if none is issued nothing at all should be sent down
588
602
  */
589
- requestOptions.assign(CTX_PARAM_EXECUTE).value = [requestOptions.getIf(CTX_PARAM_EXECUTE).value, IDENT_THIS].join(" ");
590
- remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_EXECUTE, <string>requestOptions.getIf(CTX_PARAM_EXECUTE).value, issuingForm, <any>sourceElementId);
603
+ requestOptions.assign(CTX_OPTIONS_EXECUTE).value = [requestOptions.getIf(CTX_OPTIONS_EXECUTE).value, IDENT_THIS].join(" ");
604
+ remapDefaultConstants(targetContext.getIf(CTX_PARAM_REQ_PASS_THR).get({}), P_EXECUTE, <string>requestOptions.getIf(CTX_OPTIONS_EXECUTE).value, issuingForm, <any>sourceElementId, targetContext.getIf(VIEW_ID).value);
591
605
  } else {
592
- targetContext.assign(CTX_PARAM_PASS_THR, P_EXECUTE).value = sourceElementId;
606
+ targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value = sourceElementId;
593
607
  }
594
608
  }
595
609
 
@@ -601,16 +615,33 @@ export module Implementation {
601
615
  */
602
616
  function assignClientWindowId(form: DQ, targetContext: Config) {
603
617
 
604
- let clientWindow = (window?.faces ?? window?.jsf).getClientWindow(form.getAsElem(0).value);
618
+ let clientWindow = $faces().getClientWindow(form.getAsElem(0).value);
605
619
  if (clientWindow) {
606
- targetContext.assign(CTX_PARAM_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;
620
+ targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;
621
+ }
622
+ }
623
+
624
+ /**
625
+ * determines the current naming container
626
+ * and assigns it internally
627
+ *
628
+ * @param internalContext
629
+ * @param formElement
630
+ * @private
631
+ */
632
+ function assignNamingContainerData(internalContext: Config, formElement: DQ) {
633
+ const viewRootId = resolveViewRootId(formElement);
634
+
635
+ if(!!viewRootId) {
636
+ internalContext.assign(NAMED_VIEWROOT).value = true;
637
+ internalContext.assign(NAMING_CONTAINER_ID).value = viewRootId;
607
638
  }
608
639
  }
609
640
 
610
641
  /**
611
642
  * transforms the user values to the expected one
612
643
  * with the proper none all form and this handling
613
- * (note we also could use a simple string replace but then
644
+ * (note we also could use a simple string replace, but then
614
645
  * we would have had double entries under some circumstances)
615
646
  *
616
647
  * there are several standardized constants which need a special treatment
@@ -621,14 +652,60 @@ export module Implementation {
621
652
  * @param userValues the passed user values (aka input string which needs to be transformed)
622
653
  * @param issuingForm the form where the issuing element originates
623
654
  * @param issuingElementId the issuing element
655
+ * @param rootNamingContainerId the naming container id ("" default if none is given)
624
656
  */
625
- function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string): Config {
657
+ function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string, rootNamingContainerId: string = ""): Config {
626
658
  //a cleaner implementation of the transform list method
627
-
659
+ const SEP = $faces().separatorchar;
628
660
  let iterValues: string[] = (userValues) ? trim(userValues).split(/\s+/gi) : [];
629
661
  let ret = [];
630
662
  let processed: {[key: string]: boolean} = {};
631
663
 
664
+ /**
665
+ * remaps the client ids for the portlet case so that the server
666
+ * can deal with them either prefixed ir not
667
+ * also resolves the absolute id case (it was assumed the server does this, but
668
+ * apparently the RI does not, so we have to follow the RI behavior here)
669
+ * @param componentIdToTransform the componentId which needs post processing
670
+ */
671
+ const remapNamingContainer = componentIdToTransform => {
672
+ // pattern :<anything> must be prepended by viewRoot if there is one,
673
+ // otherwise we are in a not namespaced then only the id has to match
674
+ const rootNamingContainerPrefix = (rootNamingContainerId.length) ? rootNamingContainerId+SEP : EMPTY_STR;
675
+ let formClientId = issuingForm.id.value;
676
+ // nearest parent naming container relative to the form
677
+ const nearestNamingContainer = formClientId.substring(0, formClientId.lastIndexOf(SEP));
678
+ const nearestNamingContainerPrefix = (nearestNamingContainer.length) ? nearestNamingContainer + SEP : EMPTY_STR;
679
+ // Absolute search expressions, always start with SEP or the name of the root naming container
680
+ const hasLeadingSep = componentIdToTransform.indexOf(SEP) === 0;
681
+ const isAbsolutSearchExpr = hasLeadingSep || (rootNamingContainerId.length
682
+ && componentIdToTransform.indexOf(rootNamingContainerPrefix) == 0);
683
+ let finalIdentifier = "";
684
+ if (isAbsolutSearchExpr) {
685
+ //we cut off the leading sep if there is one
686
+ componentIdToTransform = hasLeadingSep ? componentIdToTransform.substring(1) : componentIdToTransform;
687
+ componentIdToTransform = componentIdToTransform.indexOf(rootNamingContainerPrefix) == 0 ? componentIdToTransform.substring(rootNamingContainerPrefix.length) : componentIdToTransform;
688
+ //now we prepend either the prefix or "" from the cut-off string to get the final result
689
+ finalIdentifier = [rootNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR);
690
+ } else { //relative search according to the javadoc
691
+ //we cut off the root naming container id from the form
692
+ if (formClientId.indexOf(rootNamingContainerPrefix) == 0) {
693
+ formClientId = formClientId.substring(rootNamingContainerPrefix.length);
694
+ }
695
+
696
+ //If prependId = true, the outer form id must be present in the id if same form
697
+ let hasPrependId = componentIdToTransform.indexOf(formClientId) == 0;
698
+ finalIdentifier = hasPrependId ?
699
+ [rootNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR) :
700
+ [nearestNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR);
701
+ }
702
+ // We need to double check because we have scenarios where we have a naming container
703
+ // and no prepend (aka tobago testcase "must handle ':' in IDs properly", scenario 3,
704
+ // in this case we return the component id, and be happy
705
+ // we can roll a dom check here
706
+ return (!!document.getElementById(finalIdentifier)) ? finalIdentifier : componentIdToTransform;
707
+ };
708
+
632
709
  // in this case we do not use lazy stream because it wont bring any code reduction
633
710
  // or speedup
634
711
  for (let cnt = 0; cnt < iterValues.length; cnt++) {
@@ -646,33 +723,39 @@ export module Implementation {
646
723
  return targetConfig;
647
724
  //@form pushes the issuing form id into our list
648
725
  case IDENT_FORM:
649
- ret.push(issuingForm.id.value);
726
+ ret.push(remapNamingContainer(issuingForm.id.value));
650
727
  processed[issuingForm.id.value] = true;
651
728
  break;
652
729
  //@this is replaced with the current issuing element id
653
730
  case IDENT_THIS:
654
731
  if (!(issuingElementId in processed)) {
655
- ret.push(issuingElementId);
732
+ ret.push(remapNamingContainer(issuingElementId));
656
733
  processed[issuingElementId] = true;
657
734
  }
658
735
  break;
659
736
  default:
660
- ret.push(iterValues[cnt]);
737
+ ret.push(remapNamingContainer(iterValues[cnt]));
661
738
  processed[iterValues[cnt]] = true;
662
739
  }
663
740
  }
664
- //We now add the target as joined list
741
+
665
742
  targetConfig.assign(targetKey).value = ret.join(" ");
666
743
  return targetConfig;
667
744
  }
668
745
 
669
746
  /**
670
- * filter the options given with a blacklist so that only
671
- * the values required for passthough land in the ajax request
747
+ * Filter the options given with a blacklist, so that only
748
+ * the values required for params-through are processed in the ajax request
749
+ *
750
+ * Note this is a bug carried over from the old implementation
751
+ * the spec conform behavior is to use params for passthrough values
752
+ * this will be removed soon, after it is cleared up whether removing
753
+ * it breaks any legacy code
672
754
  *
673
755
  * @param {Context} mappedOpts the options to be filtered
756
+ * @deprecated
674
757
  */
675
- function filterPassthroughValues(mappedOpts: Context): Context {
758
+ function extractLegacyParams(mappedOpts: Options): Context {
676
759
  //we now can use the full code reduction given by our stream api
677
760
  //to filter
678
761
  return Stream.ofAssoc(mappedOpts)
@@ -680,6 +763,13 @@ export module Implementation {
680
763
  .collect(new AssocArrayCollector());
681
764
  }
682
765
 
766
+ function remapArrayToAssocArr(arrayedParams: [[string, any]] | {[key: string]: any}): {[key: string]: any} {
767
+ if(Array.isArray(arrayedParams)) {
768
+ return Stream.of(... arrayedParams).collect(new AssocArrayCollector());
769
+ }
770
+ return arrayedParams;
771
+ }
772
+
683
773
  function resolveGlobalConfig(): any {
684
774
  return window?.[MYFACES]?.config ?? {};
685
775
  }