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
@@ -32,7 +32,6 @@ export interface IResponseProcessor {
32
32
  */
33
33
  replaceHead(shadowHead: XMLQuery | DQ): void;
34
34
 
35
-
36
35
  /**
37
36
  * adds new elements to the head
38
37
  *
@@ -40,6 +39,14 @@ export interface IResponseProcessor {
40
39
  */
41
40
  addToHead(newElements: XMLQuery | DQ): void;
42
41
 
42
+
43
+ /**
44
+ * adds new elements to the head in a deferred manner
45
+ *
46
+ * @param newElements the elements which need addition
47
+ */
48
+ addToHeadDeferred(newElements: XMLQuery | DQ): void;
49
+
43
50
  /**
44
51
  * replace the body
45
52
  *
@@ -48,7 +55,7 @@ export interface IResponseProcessor {
48
55
  replaceBody(shadowBody: XMLQuery | DQ): void;
49
56
 
50
57
  /**
51
- * Leaf Tag eval... process whatever is in the evals cdata block
58
+ * Leaf Tag eval... process whatever is in the evaluated cdata block
52
59
  *
53
60
  * @param node
54
61
  */
@@ -91,11 +98,11 @@ export interface IResponseProcessor {
91
98
  attributes(node: XMLQuery): void;
92
99
 
93
100
  /**
94
- * replace the entire viewroot
101
+ * replace the entire viewRoot
95
102
  * with shadowResponse
96
- * @param shadownResponse
103
+ * @param shadowResponse
97
104
  */
98
- replaceViewRoot(shadownResponse: XMLQuery | DQ): void;
105
+ replaceViewRoot(shadowResponse: XMLQuery | DQ): void;
99
106
 
100
107
  /**
101
108
  * jsf insert resolution
@@ -106,34 +113,34 @@ export interface IResponseProcessor {
106
113
  insert(node: XMLQuery): void;
107
114
 
108
115
  /**
109
- * insert with before, after subtags
116
+ * insert with before, after sub-tags
110
117
  * @param node
111
118
  */
112
- insertWithSubtags(node: XMLQuery);
119
+ insertWithSubTags(node: XMLQuery);
113
120
 
114
121
  /**
115
122
  * process the viewState update, update the affected
116
- * forms with their respective new viewstate values
123
+ * forms with their respective new viewState values
117
124
  *
118
125
  */
119
126
  processViewState(node: XMLQuery): boolean;
120
127
 
121
128
  /**
122
129
  * process the viewState update, update the affected
123
- * forms with their respective new viewstate values
130
+ * forms with their respective new viewState values
124
131
  *
125
132
  */
126
133
  processClientWindow(node: XMLQuery): boolean;
127
134
 
128
135
 
129
136
  /**
130
- * evals all processed elements of so far
137
+ * Eval - all processed elements so far
131
138
  * and executes the embedded scripts
132
139
  */
133
140
  globalEval(): void;
134
141
 
135
142
  /**
136
- * fix the viewstates of all processed forms
143
+ * fix the viewStates of all processed forms
137
144
  */
138
145
  fixViewStates(): void;
139
146
 
@@ -142,4 +149,11 @@ export interface IResponseProcessor {
142
149
  * send last event
143
150
  */
144
151
  done(): void;
152
+
153
+ /**
154
+ * update internal state to
155
+ * check whether we still are in a named view root
156
+ * (can change after a navigation)
157
+ */
158
+ updateNamedViewRootState();
145
159
  }
@@ -16,18 +16,23 @@
16
16
 
17
17
  import {Config, DomQuery, DQ} from "mona-dish";
18
18
  import {
19
- CTX_PARAM_DELAY,
20
- CTX_PARAM_TIMEOUT,
19
+ $faces,
20
+ $nsp,
21
+ CTX_OPTIONS_DELAY,
22
+ CTX_OPTIONS_TIMEOUT,
23
+ DELAY_NONE,
21
24
  EMPTY_FUNC,
22
25
  EMPTY_STR,
23
- ENCODED_URL,
24
- MF_NONE,
26
+ ENCODED_URL, NAMED_VIEWROOT, NAMING_CONTAINER_ID,
27
+ P_VIEWSTATE,
25
28
  REQ_TYPE_GET,
26
29
  REQ_TYPE_POST
27
30
  } from "../core/Const";
28
31
  import {XhrFormData} from "./XhrFormData";
29
32
  import {ExtLang} from "../util/Lang";
30
- import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
33
+ import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
34
+ import {Assertions} from "../util/Assertions";
35
+
31
36
 
32
37
  /**
33
38
  * Resolver functions for various aspects of the request data
@@ -37,7 +42,7 @@ import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
37
42
  */
38
43
 
39
44
  /**
40
- * resolves the event handlers lazly
45
+ * resolves the event handlers lazily
41
46
  * so that if some decoration happens in between we can deal with it
42
47
  *
43
48
  * @param requestContext
@@ -45,6 +50,7 @@ import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
45
50
  * @param funcName
46
51
  */
47
52
  export function resolveHandlerFunc(requestContext: Config, responseContext: Config, funcName: string) {
53
+ responseContext = responseContext || new Config({});
48
54
  return responseContext.getIf(funcName)
49
55
  .orElseLazy(() =>requestContext.getIf(funcName).value)
50
56
  .orElse(EMPTY_FUNC).value;
@@ -67,20 +73,52 @@ export function resolveFinalUrl(sourceForm: DomQuery, formData: XhrFormData, aja
67
73
  * it is either the id or the parent form of the element or an embedded form
68
74
  * of the element
69
75
  *
70
- * @param requestCtx
71
76
  * @param elem
72
77
  * @param event
73
78
  */
74
- export function resolveForm(requestCtx: Config, elem: DQ, event: Event): DQ {
75
- const configId = requestCtx.value?.myfaces?.form ?? MF_NONE;
76
- return DQ
77
- .byId(configId, true)
78
- .orElseLazy(() => ExtLang.getForm(elem.getAsElem(0).value, event));
79
+ export function resolveForm(elem: DQ, event: Event): DQ {
80
+ return ExtLang.getForm(elem.getAsElem(0).value, event);
81
+ }
82
+
83
+ export function resolveViewId(form: DQ): string {
84
+ const viewState = form.querySelectorAll(`input[type='hidden'][name*='${$nsp(P_VIEWSTATE)}']`).id.orElse("").value;
85
+ const divider = $faces().separatorchar;
86
+ const viewId = viewState.split(divider, 2)[0];
87
+ const viewStateViewId = viewId.indexOf($nsp(P_VIEWSTATE)) === -1 ? viewId : "";
88
+ // myfaces specific, we in non portlet environments prepend the viewId
89
+ // even without being in a naming container, the other components ignore that
90
+ return form.id.value.indexOf(viewStateViewId) === 0 ? viewStateViewId : "";
91
+ }
92
+
93
+ export function resolveViewRootId(form: DQ): string {
94
+ const viewState = form.querySelectorAll(`input[type='hidden'][name*='${$nsp(P_VIEWSTATE)}']`).attr("name").orElse("").value;
95
+ const divider = $faces().separatorchar;
96
+ const viewId = viewState.split(divider, 2)[0];
97
+ //different to the identifier the form id is never prepended to the viewstate
98
+ return viewId.indexOf($nsp(P_VIEWSTATE)) === -1 ? viewId : "";
99
+ }
100
+
101
+ /**
102
+ * as per jsdoc before the request it must be ensured that every post argument
103
+ * is prefixed with the naming container id (there is an exception in mojarra with
104
+ * the element=element param, which we have to follow here as well.
105
+ * (inputs are prefixed by name anyway normally this only affects our standard parameters)
106
+ * @private
107
+ */
108
+ export function resoveNamingContainerMapper(internalContext: Config): (key: string, value: any) => [string, any] {
109
+ const isNamedViewRoot = internalContext.getIf(NAMED_VIEWROOT).isPresent();
110
+ if(!isNamedViewRoot) {
111
+ return (key, value) => [key, value];
112
+ }
113
+ const partialId = internalContext.getIf(NAMING_CONTAINER_ID).value;
114
+ const SEP = $faces().separatorchar;
115
+ const prefix = partialId + SEP;
116
+ return (key: string, value: any) => (key.indexOf(prefix) == 0) ? [key, value] : [prefix + key, value];
79
117
  }
80
118
 
81
119
  export function resolveTimeout(options: Config): number {
82
120
  let getCfg = ExtLang.getLocalOrGlobalConfig;
83
- return options.getIf(CTX_PARAM_TIMEOUT).value ?? getCfg(options.value, CTX_PARAM_TIMEOUT, 0);
121
+ return options.getIf(CTX_OPTIONS_TIMEOUT).value ?? getCfg(options.value, CTX_OPTIONS_TIMEOUT, 0);
84
122
  }
85
123
 
86
124
  /**
@@ -89,18 +127,24 @@ export function resolveTimeout(options: Config): number {
89
127
  * @param options ... the options object, in most cases it will host the delay value
90
128
  */
91
129
  export function resolveDelay(options: Config): number {
92
- let getCfg = ExtLang.getLocalOrGlobalConfig;
93
-
94
- return options.getIf(CTX_PARAM_DELAY).value ?? getCfg(options.value, CTX_PARAM_DELAY, 0);
130
+ // null, 'none', or undefined will automatically be mapped to 0 aka no delay
131
+ // the config delay will be dropped not needed anymore, it does not really
132
+ // make sense anymore now that it is part of a local spec
133
+ let ret = options.getIf(CTX_OPTIONS_DELAY).orElse(0).value;
134
+ // if delay === none, no delay must be used, aka delay 0
135
+ ret = (DELAY_NONE === ret) ? 0 : ret;
136
+ // negative, or invalid values will automatically get a js exception
137
+ Assertions.assertDelay(ret);
138
+ return ret;
95
139
  }
96
140
 
97
141
  /**
98
- * resolves the window Id from various sources
142
+ * resolves the window-id from various sources
99
143
  *
100
144
  * @param options
101
145
  */
102
146
  export function resolveWindowId(options: Config) {
103
- return options?.value?.windowId ?? ExtDomquery.windowId;
147
+ return options?.value?.windowId ?? ExtDomQuery.windowId;
104
148
  }
105
149
 
106
150
  /**
@@ -108,19 +152,20 @@ export function resolveWindowId(options: Config) {
108
152
  * browser save event resolution
109
153
  * @param evt the event object
110
154
  * (with a fallback for ie events if none is present)
155
+ * @deprecated soon will be removed
111
156
  */
112
157
  export function getEventTarget(evt: Event): Element {
113
- //ie6 and 7 fallback
158
+ // ie6 and 7 fallback
114
159
  let finalEvent = evt;
115
- /**
160
+ /*
116
161
  * evt source is defined in the jsf events
117
- * seems like some component authors use our code
162
+ * seems like some component authors use our code,
118
163
  * so we add it here see also
119
164
  * https://issues.apache.org/jira/browse/MYFACES-2458
120
165
  * not entirely a bug but makes sense to add this
121
- * behavior. I dont use it that way but nevertheless it
166
+ * behavior. I don´t use it that way but nevertheless it
122
167
  * does not break anything so why not
123
- * */
168
+ */
124
169
  let t = finalEvent?.srcElement ?? finalEvent?.target ?? (<any>finalEvent)?.source;
125
170
  while ((t) && (t.nodeType != 1)) {
126
171
  t = t.parentNode;
@@ -137,14 +182,15 @@ export function getEventTarget(evt: Event): Element {
137
182
  * @param opts
138
183
  * @param el
139
184
  */
140
- export function resolveDefaults(event: Event, opts: any = {}, el: Element | string = null) {
185
+ export function resolveDefaults(event: Event, opts: Options | [[string, any]] , el: Element | string = null): any {
141
186
  //deep copy the options, so that further transformations to not backfire into the callers
142
- const resolvedEvent = event,
143
- options = new ExtConfig(opts).deepCopy,
144
- elem = DQ.byId(el || <Element>resolvedEvent.target, true),
145
- elementId = elem.id.value, requestCtx = new ExtConfig({}),
146
- internalCtx = new ExtConfig({}), windowId = resolveWindowId(options),
147
- isResetValues = true === options.value?.resetValues;
148
-
149
- return {resolvedEvent, options, elem, elementId, requestCtx, internalCtx, windowId, isResetValues};
187
+ const elem = DQ.byId(el || <Element>event.target, true);
188
+ const options = new ExtConfig(opts).deepCopy as ExtConfig;
189
+ return {
190
+ options: options,
191
+ elem: elem,
192
+ elementId: elem.id.value,
193
+ windowId: resolveWindowId(options),
194
+ isResetValues: true === options.value?.resetValues
195
+ };
150
196
  }
@@ -25,7 +25,7 @@ import {
25
25
  CTX_PARAM_SRC_FRM_ID,
26
26
  SEL_RESPONSE_XML,
27
27
  SOURCE,
28
- TAG_FORM,
28
+ HTML_TAG_FORM,
29
29
  UPDATE_ELEMS,
30
30
  UPDATE_FORMS,
31
31
  DEFERRED_HEAD_INSERTS
@@ -45,7 +45,7 @@ import {ExtConfig} from "../util/ExtDomQuery";
45
45
  *
46
46
  * @param request the request hosting the responseXML
47
47
  *
48
- * Throws an error in case of non existent or wrong xml data
48
+ * Throws an error in case of non-existent or wrong xml data
49
49
  *
50
50
  */
51
51
  export function resolveResponseXML(request: Config): XMLQuery {
@@ -56,8 +56,8 @@ export function resolveResponseXML(request: Config): XMLQuery {
56
56
  }
57
57
 
58
58
  /**
59
- * Splits the incoming passthrough context apart
60
- * in an internal and an external nomalized context
59
+ * Splits the incoming pass-through context apart
60
+ * in an internal and an external normalized context
61
61
  * the internal one is just for our internal processing
62
62
  *
63
63
  * @param context the root context as associative array
@@ -83,10 +83,10 @@ export function resolveContexts(context: { [p: string]: any }): any {
83
83
  }
84
84
 
85
85
  /**
86
- * fetches the source element out of our conexts
86
+ * fetches the source element out of our contexts
87
87
  *
88
- * @param context the external context which shpuld host the source id
89
- * @param internalContext internal passthrough fall back
88
+ * @param context the external context which should host the source id
89
+ * @param internalContext internal pass-through fall back
90
90
  *
91
91
  */
92
92
  export function resolveSourceElement(context: Config, internalContext: Config): DQ {
@@ -106,9 +106,9 @@ export function resolveSourceForm(internalContext: Config, elem: DQ): DQ {
106
106
  let sourceFormId = internalContext.getIf(CTX_PARAM_SRC_FRM_ID);
107
107
  let sourceForm = new DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);
108
108
 
109
- sourceForm = sourceForm.orElseLazy(() => elem.parents(TAG_FORM))
110
- .orElseLazy(() => elem.querySelectorAll(TAG_FORM))
111
- .orElseLazy(() => DQ.querySelectorAll(TAG_FORM));
109
+ sourceForm = sourceForm.orElseLazy(() => elem.firstParent(HTML_TAG_FORM))
110
+ .orElseLazy(() => elem.querySelectorAll(HTML_TAG_FORM))
111
+ .orElseLazy(() => DQ.querySelectorAll(HTML_TAG_FORM));
112
112
 
113
113
  return sourceForm;
114
114
  }
@@ -20,23 +20,23 @@ import {ResponseProcessor} from "./ResponseProcessor";
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
21
21
  import {
22
22
  $nsp,
23
- CMD_ATTRIBUTES,
24
- CMD_CHANGES,
25
- CMD_DELETE,
26
- CMD_ERROR,
27
- CMD_EVAL,
28
- CMD_EXTENSION,
29
- CMD_INSERT,
30
- CMD_REDIRECT,
31
- CMD_UPDATE, P_RESOURCE,
23
+ XML_TAG_ATTRIBUTES,
24
+ XML_TAG_CHANGES,
25
+ XML_TAG_DELETE,
26
+ XML_TAG_ERROR,
27
+ XML_TAG_EVAL,
28
+ XML_TAG_EXTENSION,
29
+ XML_TAG_INSERT,
30
+ XML_TAG_REDIRECT,
31
+ XML_TAG_UPDATE, P_RESOURCE,
32
32
  P_VIEWBODY,
33
33
  P_VIEWHEAD,
34
34
  P_VIEWROOT,
35
- PARTIAL_ID,
36
- RESP_PARTIAL,
35
+ NAMING_CONTAINER_ID,
36
+ XML_TAG_PARTIAL_RESP,
37
37
  RESPONSE_XML,
38
- TAG_AFTER,
39
- TAG_BEFORE
38
+ XML_TAG_AFTER,
39
+ XML_TAG_BEFORE, NAMED_VIEWROOT, XML_ATTR_NAMED_VIEWROOT, P_VIEWSTATE, $faces
40
40
  } from "../core/Const";
41
41
  import {resolveContexts, resolveResponseXML} from "./ResonseDataResolver";
42
42
  import {ExtConfig} from "../util/ExtDomQuery";
@@ -66,16 +66,17 @@ export module Response {
66
66
 
67
67
  internalContext.assign(RESPONSE_XML).value = responseXML;
68
68
 
69
- //we now process the partial tags, or in none given raise an error
70
- responseXML.querySelectorAll(RESP_PARTIAL)
69
+ // we now process the partial tags, or in none given raise an error
70
+ responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP)
71
71
  .each(item => processPartialTag(<XMLQuery>item, responseProcessor, internalContext));
72
72
 
73
- //we now process the viewstates, client windows and the evals deferred
74
- //the reason for this is that often it is better
75
- //to wait until the document has caught up before
76
- //doing any evals even on embedded scripts
77
- //usually this does not matter, the client window comes in almost last always anyway
78
- //we maybe drop this deferred assignment in the future, but myfaces did it until now
73
+ // We now process the viewStates, client windows and the elements to be evaluated are delayed.
74
+ // The reason for this is that often it is better
75
+ // to wait until the document has caught up before
76
+ // doing any evaluations even on embedded scripts.
77
+ // Usually this does not matter, the client window comes in almost last always anyway
78
+ // we maybe drop this deferred assignment in the future, but myfaces did it until now.
79
+ responseProcessor.updateNamedViewRootState();
79
80
  responseProcessor.fixViewStates();
80
81
  responseProcessor.fixClientWindow();
81
82
  responseProcessor.globalEval();
@@ -86,35 +87,51 @@ export module Response {
86
87
  /**
87
88
  * highest node partial-response from there the main operations are triggered
88
89
  */
89
- function processPartialTag(node: XMLQuery, responseProcessor: IResponseProcessor, internalContext) {
90
+ function processPartialTag(node: XMLQuery, responseProcessor: IResponseProcessor, internalContext) {
90
91
 
91
- internalContext.assign(PARTIAL_ID).value = node.id;
92
- const SEL_SUB_TAGS = [CMD_ERROR, CMD_REDIRECT, CMD_CHANGES].join(",");
93
92
 
94
- //now we can process the main operations
93
+ /*
94
+ https://javaee.github.io/javaserverfaces/docs/2.2/javadocs/web-partialresponse.html#ns_xsd
95
+ The "partial-response" element is the root of the partial response information hierarchy,
96
+ and contains nested elements for all possible elements that can exist in the response.
97
+ This element must have an "id" attribute whose value is the return from calling getContainerClientId()
98
+ on the UIViewRoot to which this response pertains.
99
+ */
100
+ // we can determine whether we are in a naming container scenario by checking whether the passed view id is present in the page
101
+ // under or in body as identifier
102
+
103
+ let partialId:string = node?.id?.value;
104
+ internalContext.assignIf(!!partialId, NAMING_CONTAINER_ID).value = partialId; // second case mojarra
105
+
106
+ // there must be at least one container viewstate element resembling the viewroot that we know
107
+ // this is named
108
+ responseProcessor.updateNamedViewRootState();
109
+
110
+ const SEL_SUB_TAGS = [XML_TAG_ERROR, XML_TAG_REDIRECT, XML_TAG_CHANGES].join(",");
111
+
112
+ // now we can process the main operations
95
113
  node.querySelectorAll(SEL_SUB_TAGS).each((node: XMLQuery) => {
96
114
  switch (node.tagName.value) {
97
- case CMD_ERROR:
115
+ case XML_TAG_ERROR:
98
116
  responseProcessor.error(node);
99
117
  break;
100
- case CMD_REDIRECT:
118
+ case XML_TAG_REDIRECT:
101
119
  responseProcessor.redirect(node);
102
120
  break;
103
- case CMD_CHANGES:
121
+ case XML_TAG_CHANGES:
104
122
  processChangesTag(node, responseProcessor);
105
123
  break;
106
124
  }
107
125
  });
108
-
109
126
  }
110
127
 
111
128
  let processInsert = function (responseProcessor: IResponseProcessor, node: XMLQuery) {
112
- //path1 insert after as child tags
113
- if(node.querySelectorAll([TAG_BEFORE, TAG_AFTER].join(",")).length) {
114
- responseProcessor.insertWithSubtags(node);
115
- } else { //insert before after with id
116
- responseProcessor.insert(node);
117
- }
129
+ // path1 insert after as child tags
130
+ if(node.querySelectorAll([XML_TAG_BEFORE, XML_TAG_AFTER].join(",")).length) {
131
+ responseProcessor.insertWithSubTags(node);
132
+ } else { // insert before after with id
133
+ responseProcessor.insert(node);
134
+ }
118
135
 
119
136
  };
120
137
 
@@ -124,32 +141,32 @@ export module Response {
124
141
  * @param node
125
142
  * @param responseProcessor
126
143
  */
127
- function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {
128
- const ALLOWED_TAGS = [CMD_UPDATE, CMD_EVAL, CMD_INSERT, CMD_DELETE, CMD_ATTRIBUTES, CMD_EXTENSION].join(", ");
144
+ function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {
145
+ const ALLOWED_TAGS = [XML_TAG_UPDATE, XML_TAG_EVAL, XML_TAG_INSERT, XML_TAG_DELETE, XML_TAG_ATTRIBUTES, XML_TAG_EXTENSION].join(", ");
129
146
  node.querySelectorAll(ALLOWED_TAGS).each(
130
147
  (node: XMLQuery) => {
131
148
  switch (node.tagName.value) {
132
- case CMD_UPDATE:
149
+ case XML_TAG_UPDATE:
133
150
  processUpdateTag(node, responseProcessor);
134
151
  break;
135
152
 
136
- case CMD_EVAL:
153
+ case XML_TAG_EVAL:
137
154
  responseProcessor.eval(node);
138
155
  break;
139
156
 
140
- case CMD_INSERT:
157
+ case XML_TAG_INSERT:
141
158
  processInsert(responseProcessor, node);
142
159
  break;
143
160
 
144
- case CMD_DELETE:
161
+ case XML_TAG_DELETE:
145
162
  responseProcessor.delete(node);
146
163
  break;
147
164
 
148
- case CMD_ATTRIBUTES:
165
+ case XML_TAG_ATTRIBUTES:
149
166
  responseProcessor.attributes(node);
150
167
  break;
151
168
 
152
- case CMD_EXTENSION:
169
+ case XML_TAG_EXTENSION:
153
170
  break;
154
171
  }
155
172
  }
@@ -171,14 +188,14 @@ export module Response {
171
188
 
172
189
  /**
173
190
  * branch tag update. drill further down into the updates
174
- * special case viewstate in that case it is a leaf
175
- * and the viewstate must be processed
191
+ * special case viewState in that case it is a leaf
192
+ * and the viewState must be processed
176
193
  *
177
194
  * @param node
178
195
  * @param responseProcessor
179
196
  */
180
- function processUpdateTag(node: XMLQuery, responseProcessor: IResponseProcessor) {
181
- //early state storing, if no state we perform a normal update cycle
197
+ function processUpdateTag(node: XMLQuery, responseProcessor: IResponseProcessor) {
198
+ // early state storing, if no state we perform a normal update cycle
182
199
  if (!storeState(responseProcessor, node)) {
183
200
  handleElementUpdate(node, responseProcessor);
184
201
  }
@@ -190,7 +207,7 @@ export module Response {
190
207
  * @param node
191
208
  * @param responseProcessor
192
209
  */
193
- function handleElementUpdate(node: XMLQuery, responseProcessor: IResponseProcessor) {
210
+ function handleElementUpdate(node: XMLQuery, responseProcessor: IResponseProcessor) {
194
211
  let cdataBlock = node.cDATAAsString;
195
212
  switch (node.id.value) {
196
213
  case $nsp(P_VIEWROOT) :
@@ -209,7 +226,7 @@ export module Response {
209
226
  responseProcessor.addToHead(DQ.fromMarkup(cdataBlock))
210
227
  break;
211
228
 
212
- default://htmlItem replacement
229
+ default:// htmlItem replacement
213
230
  responseProcessor.update(node, cdataBlock);
214
231
  break;
215
232
  }