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