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
@@ -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
  }