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
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config, DomQuery, DQ, Lang, Stream, XMLQuery} from "mona-dish";
17
+ import {Config, DomQuery, DomQueryCollector, DQ, DQ$, Lang, LazyStream, Stream, XMLQuery} from "mona-dish";
18
18
  import {Implementation} from "../AjaxImpl";
19
19
  import {Assertions} from "../util/Assertions";
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
@@ -23,6 +23,7 @@ import {StateHolder} from "../core/ImplTypes";
23
23
  import {EventData} from "./EventData";
24
24
 
25
25
  import {
26
+ $faces,
26
27
  $nsp,
27
28
  APPLIED_CLIENT_WINDOW,
28
29
  APPLIED_VST,
@@ -30,32 +31,40 @@ import {
30
31
  ATTR_NAME,
31
32
  ATTR_URL,
32
33
  ATTR_VALUE,
34
+ DEFERRED_HEAD_INSERTS,
33
35
  EMPTY_FUNC,
34
36
  EMPTY_STR,
35
37
  ERROR_MESSAGE,
36
38
  ERROR_NAME,
37
- HTML_VIEWSTATE,
39
+ HTML_TAG_BODY,
40
+ HTML_TAG_FORM,
41
+ HTML_TAG_HEAD,
42
+ HTML_TAG_LINK,
43
+ HTML_TAG_SCRIPT,
44
+ HTML_TAG_STYLE, IDENT_ALL, IDENT_NONE, NAMED_VIEWROOT,
38
45
  ON_ERROR,
39
- ON_EVENT, P_CLIENT_WINDOW,
46
+ ON_EVENT,
47
+ P_CLIENT_WINDOW,
48
+ P_EXECUTE,
40
49
  P_PARTIAL_SOURCE,
50
+ P_RENDER,
51
+ P_RENDER_OVERRIDE,
41
52
  P_VIEWSTATE,
42
- RESPONSE_XML, SEL_CLIENT_WINDOW_ELEM,
43
- SEL_SCRIPTS_STYLES,
53
+ NAMING_CONTAINER_ID,
54
+ RESPONSE_XML,
55
+ SEL_CLIENT_WINDOW_ELEM,
44
56
  SEL_VIEWSTATE_ELEM,
45
57
  SOURCE,
46
58
  SUCCESS,
47
- TAG_AFTER,
48
- TAG_ATTR,
49
- TAG_BEFORE,
50
- TAG_BODY,
51
- TAG_FORM,
52
- TAG_HEAD,
53
59
  UPDATE_ELEMS,
54
60
  UPDATE_FORMS,
55
- DEFERRED_HEAD_INSERTS
61
+ XML_TAG_AFTER,
62
+ XML_TAG_ATTR,
63
+ XML_TAG_BEFORE
56
64
  } from "../core/Const";
65
+ import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
66
+ import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
57
67
  import trim = Lang.trim;
58
- import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
59
68
 
60
69
 
61
70
  /**
@@ -82,31 +91,38 @@ export class ResponseProcessor implements IResponseProcessor {
82
91
  * the data incoming must represent the html representation of the head itself one way or the other
83
92
  */
84
93
  replaceHead(shadowDocument: XMLQuery | DQ) {
85
- let shadowHead = shadowDocument.querySelectorAll(TAG_HEAD);
94
+ const shadowHead = shadowDocument.querySelectorAll(HTML_TAG_HEAD);
86
95
  if (!shadowHead.isPresent()) {
87
96
  return;
88
97
  }
98
+ const head = ExtDomQuery.querySelectorAll(HTML_TAG_HEAD);
99
+ // full replace we delete everything
100
+ head.childNodes.delete();
101
+ this.addToHead(shadowHead);
102
+ //we copy the attributes as well (just in case myfaces introduces the id in head)
103
+ head.copyAttrs(shadowHead);
104
+ }
89
105
 
90
- let oldHead = ExtDomquery.querySelectorAll(TAG_HEAD);
106
+ addToHead(shadowHead: XMLQuery | DQ) {
107
+ const mappedHeadData = new ExtDomQuery(shadowHead);
108
+ const scriptTags = [HTML_TAG_SCRIPT];
109
+ const nonExecutables = mappedHeadData.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) == -1);
110
+ nonExecutables.runHeadInserts(true);
91
111
 
92
- //delete all to avoid script and style overlays
93
- oldHead.querySelectorAll(SEL_SCRIPTS_STYLES).delete();
112
+ //incoming either the outer head tag or its children
113
+ const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
114
+ // this is stored for "post" processing
115
+ // after the rest of the "physical build up", head before body
116
+ const scriptElements = nodesToAdd.stream
117
+ .filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1).collect(new DomQueryCollector());
94
118
 
95
- // we cannot replace new elements in the head, but we can eval the elements
96
- // eval means the scripts will get attached (eval script attach method)
97
- // but this is done by DomQuery not in this code
98
- this.storeForEval(shadowHead);
99
- //incoming either the outer head tag or its childs
100
- //shadowHead = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
101
- //this.addToHead(shadowHead);
119
+ this.addToHeadDeferred(scriptElements);
102
120
  }
103
121
 
104
- addToHead(newElements: XMLQuery | DQ) {
122
+ addToHeadDeferred(newElements: XMLQuery | DQ) {
105
123
  this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(newElements);
106
124
  }
107
125
 
108
-
109
-
110
126
  /**
111
127
  * replaces the body in the expected manner
112
128
  * which means the entire body content is refreshed
@@ -117,30 +133,30 @@ export class ResponseProcessor implements IResponseProcessor {
117
133
  */
118
134
  replaceBody(shadowDocument: XMLQuery | DQ) {
119
135
 
120
- let shadowBody = shadowDocument.querySelectorAll(TAG_BODY);
136
+ const shadowBody = shadowDocument.querySelectorAll(HTML_TAG_BODY);
121
137
  if (!shadowBody.isPresent()) {
122
138
  return;
123
139
  }
124
140
 
125
- let shadowInnerHTML: string = <string>shadowBody.html().value;
126
-
127
- let resultingBody = <DQ>ExtDomquery.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
128
- let updateForms = resultingBody.querySelectorAll(TAG_FORM);
141
+ const shadowInnerHTML: string = <string>shadowBody.innerHTML;
142
+ const resultingBody = <DQ>ExtDomQuery.querySelectorAll(HTML_TAG_BODY);
143
+ const updateForms = resultingBody.querySelectorAll(HTML_TAG_FORM);
129
144
 
130
145
  // main difference, we cannot replace the body itself, but only its content
131
- // we need a separate step for post processing the incoming attributes, like classes, styles etc...
132
- resultingBody.copyAttrs(shadowBody);
133
-
146
+ // we need a separate step for post-processing the incoming
147
+ // attributes, like classes, styles etc...
148
+ (resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
149
+ this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
134
150
  this.storeForPostProcessing(updateForms, resultingBody);
135
151
  }
136
152
 
137
153
  /**
138
- * Leaf Tag eval... process whatever is in the evals cdata block
154
+ * Leaf Tag eval... process whatever is in the eval cdata block
139
155
  *
140
156
  * @param node the node to eval
141
157
  */
142
158
  eval(node: XMLQuery) {
143
- ExtDomquery.globalEval(node.cDATAAsString);
159
+ ExtDomQuery.globalEval(node.cDATAAsString);
144
160
  }
145
161
 
146
162
  /**
@@ -157,22 +173,22 @@ export class ResponseProcessor implements IResponseProcessor {
157
173
  * <error>
158
174
  */
159
175
 
160
- let mergedErrorData = new ExtConfig({});
176
+ const mergedErrorData = new ExtConfig({});
161
177
  mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
162
178
  mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
163
179
  mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
164
180
 
165
- let hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
181
+ const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
166
182
 
167
183
  //we now store the response xml also in the error data for further details
168
184
  mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
169
185
 
170
- // error post processing and enrichment (standard messages from keys)
171
- let errorData = ErrorData.fromServerError(mergedErrorData);
186
+ // error post-processing and enrichment (standard messages from keys)
187
+ const errorData = ErrorData.fromServerError(mergedErrorData);
172
188
 
173
- // we now trigger an internally stored onError function which might be a attached to the context
174
- // either we haven an internal on error, or an on error has been bassed via params from the outside
175
- // in both cases they are attached to our contexts
189
+ // we now trigger an internally stored onError function which might be an attached to the context
190
+ // either we do not have an internal on error, or an on error has been based via params from the outside.
191
+ // In both cases they are attached to our contexts
176
192
 
177
193
  this.triggerOnError(errorData);
178
194
  Implementation.sendError(errorData);
@@ -186,7 +202,7 @@ export class ResponseProcessor implements IResponseProcessor {
186
202
  redirect(node: XMLQuery) {
187
203
  Assertions.assertUrlExists(node);
188
204
 
189
- let redirectUrl = trim(node.attr(ATTR_URL).value);
205
+ const redirectUrl = trim(node.attr(ATTR_URL).value);
190
206
  if (redirectUrl != EMPTY_STR) {
191
207
  window.location.href = redirectUrl;
192
208
  }
@@ -198,15 +214,15 @@ export class ResponseProcessor implements IResponseProcessor {
198
214
  * @param cdataBlock the cdata block with the new html code
199
215
  */
200
216
  update(node: XMLQuery, cdataBlock: string) {
201
- let result = ExtDomquery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
202
- let sourceForm = result?.parents(TAG_FORM).orElseLazy(() => result.byTagName(TAG_FORM, true));
217
+ const result = ExtDomQuery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
218
+ const sourceForm = result?.firstParent(HTML_TAG_FORM).orElseLazy(() => result.byTagName(HTML_TAG_FORM, true));
203
219
  if (sourceForm) {
204
220
  this.storeForPostProcessing(sourceForm, result);
205
221
  }
206
222
  }
207
223
 
208
224
  /**
209
- * Delete handler, simply deleetes the node referenced by the xml data
225
+ * Delete handler, simply deletes the node referenced by the xml data
210
226
  * @param node
211
227
  */
212
228
  delete(node: XMLQuery) {
@@ -219,9 +235,9 @@ export class ResponseProcessor implements IResponseProcessor {
219
235
  * @param node
220
236
  */
221
237
  attributes(node: XMLQuery) {
222
- let elem = DQ.byId(node.id.value, true);
238
+ const elem = DQ.byId(node.id.value, true);
223
239
 
224
- node.byTagName(TAG_ATTR).each((item: XMLQuery) => {
240
+ node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
225
241
  elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
226
242
  });
227
243
  }
@@ -242,17 +258,16 @@ export class ResponseProcessor implements IResponseProcessor {
242
258
  insert(node: XMLQuery) {
243
259
  //let insertId = node.id; //not used atm
244
260
 
245
- let before = node.attr(TAG_BEFORE);
246
- let after = node.attr(TAG_AFTER);
247
-
248
- let insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
261
+ const before = node.attr(XML_TAG_BEFORE);
262
+ const after = node.attr(XML_TAG_AFTER);
263
+ const insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
249
264
 
250
265
  if (before.isPresent()) {
251
266
  DQ.byId(before.value, true).insertBefore(insertNodes);
252
267
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
253
268
  }
254
269
  if (after.isPresent()) {
255
- let domQuery = DQ.byId(after.value, true);
270
+ const domQuery = DQ.byId(after.value, true);
256
271
  domQuery.insertAfter(insertNodes);
257
272
 
258
273
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -264,13 +279,13 @@ export class ResponseProcessor implements IResponseProcessor {
264
279
  *
265
280
  * @param node the node hosting the insert data
266
281
  */
267
- insertWithSubtags(node: XMLQuery) {
268
- let before = node.querySelectorAll(TAG_BEFORE);
269
- let after = node.querySelectorAll(TAG_AFTER);
282
+ insertWithSubTags(node: XMLQuery) {
283
+ const before = node.querySelectorAll(XML_TAG_BEFORE);
284
+ const after = node.querySelectorAll(XML_TAG_AFTER);
270
285
 
271
286
  before.each(item => {
272
- let insertId = item.attr(ATTR_ID);
273
- let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
287
+ const insertId = item.attr(ATTR_ID);
288
+ const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
274
289
  if (insertId.isPresent()) {
275
290
  DQ.byId(insertId.value, true).insertBefore(insertNodes);
276
291
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -278,8 +293,8 @@ export class ResponseProcessor implements IResponseProcessor {
278
293
  });
279
294
 
280
295
  after.each(item => {
281
- let insertId = item.attr(ATTR_ID);
282
- let insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
296
+ const insertId = item.attr(ATTR_ID);
297
+ const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
283
298
  if (insertId.isPresent()) {
284
299
  DQ.byId(insertId.value, true).insertAfter(insertNodes);
285
300
  this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
@@ -289,12 +304,12 @@ export class ResponseProcessor implements IResponseProcessor {
289
304
 
290
305
  /**
291
306
  * Process the viewState update, update the affected
292
- * forms with their respective new viewstate values
307
+ * forms with their respective new viewState values
293
308
  *
294
309
  */
295
310
  processViewState(node: XMLQuery): boolean {
296
311
  if (ResponseProcessor.isViewStateNode(node)) {
297
- let state = node.cDATAAsString;
312
+ const state = node.cDATAAsString;
298
313
  this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
299
314
  return true;
300
315
  }
@@ -303,7 +318,7 @@ export class ResponseProcessor implements IResponseProcessor {
303
318
 
304
319
  processClientWindow(node: XMLQuery): boolean {
305
320
  if (ResponseProcessor.isClientWindowNode(node)) {
306
- let state = node.cDATAAsString;
321
+ const state = node.cDATAAsString;
307
322
  this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
308
323
  return true;
309
324
  }
@@ -314,11 +329,11 @@ export class ResponseProcessor implements IResponseProcessor {
314
329
  */
315
330
  globalEval() {
316
331
  // phase one, if we have head inserts, we build up those before going into the script eval phase
317
- let insertHeadElems = new ExtDomquery(...this.internalContext.getIf(DEFERRED_HEAD_INSERTS).value);
332
+ let insertHeadElems = new ExtDomQuery(...this.internalContext.getIf(DEFERRED_HEAD_INSERTS).value);
318
333
  insertHeadElems.runHeadInserts(true);
319
334
 
320
335
  // phase 2 we run a script eval on all updated elements in the body
321
- let updateElems = new ExtDomquery(...this.internalContext.getIf(UPDATE_ELEMS).value);
336
+ let updateElems = new ExtDomQuery(...this.internalContext.getIf(UPDATE_ELEMS).value);
322
337
  updateElems.runCss();
323
338
  // phase 3, we do the same for the css
324
339
  updateElems.runScripts();
@@ -332,62 +347,78 @@ export class ResponseProcessor implements IResponseProcessor {
332
347
  */
333
348
  fixViewStates() {
334
349
  Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
335
- .each((item: Array<any>) => {
336
- let value: StateHolder = item[1];
337
- let nameSpace = DQ.byId(value.nameSpace, true).orElse(document.body);
338
- let affectedForms = nameSpace.byTagName(TAG_FORM);
339
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
350
+ .each(([, value]) => {
351
+ const namingContainerId = this.internalContext.getIf(NAMING_CONTAINER_ID);
352
+ const namedViewRoot = !!this.internalContext.getIf(NAMED_VIEWROOT).value
353
+ const affectedForms = this.getContainerForms(namingContainerId)
354
+ .filter(affectedForm => this.isInExecuteOrRender(affectedForm));
340
355
 
341
- this.appendViewStateToForms(new DomQuery(affectedForms, affectedForms2), value.value);
356
+ this.appendViewStateToForms(affectedForms, namedViewRoot, value.value, namingContainerId.orElse("").value);
342
357
  });
343
358
  }
344
359
 
360
+
361
+
345
362
  /**
346
363
  * same as with view states before applies the incoming client windows as last step after the rest of the processing
347
364
  * is done.
348
365
  */
349
366
  fixClientWindow() {
350
367
  Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
351
- .each((item: Array<any>) => {
352
- let value: StateHolder = item[1];
353
- let nameSpace = DQ.byId(value.nameSpace, true).orElse(document.body);
354
- let affectedForms = nameSpace.byTagName(TAG_FORM);
355
- let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
368
+ .each(([, value]) => {
369
+ const namingContainerId = this.internalContext.getIf(NAMING_CONTAINER_ID);
370
+ const namedViewRoot = !!this.internalContext.getIf(NAMED_VIEWROOT).value;
371
+ const affectedForms = this.getContainerForms(namingContainerId)
372
+ .filter(affectedForm => this.isInExecuteOrRender(affectedForm));
356
373
 
357
- this.appendClientWindowToForms(new DomQuery(affectedForms, affectedForms2), value.value);
374
+ this.appendClientWindowToForms(affectedForms, namedViewRoot, value.value, namingContainerId.orElse("").value);
358
375
  });
359
376
  }
360
377
 
378
+ updateNamedViewRootState() {
379
+ let partialId = this.internalContext.getIf(NAMING_CONTAINER_ID);
380
+ let namedViewRoot = this.internalContext.getIf(NAMED_VIEWROOT);
381
+ if(partialId.isPresent() &&
382
+ (namedViewRoot.isAbsent() ||
383
+ !namedViewRoot.value)) {
384
+ const SEP = $faces().separatorchar;
385
+ this.internalContext.assign(NAMED_VIEWROOT).value = (!!document.getElementById(partialId.value)) || DQ$(`input[name*='${$nsp(P_VIEWSTATE)}']`)
386
+ .filter(node => node.attr("name").value.indexOf(partialId.value + SEP) == 0).length > 0;
387
+ }
388
+ }
389
+
361
390
  /**
362
391
  * all processing done we can close the request and send the appropriate events
363
392
  */
364
393
  done() {
365
- let eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
394
+ const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
366
395
 
367
396
  //because some frameworks might decorate them over the context in the response
368
- let eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
397
+ const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
369
398
  Implementation.sendEvent(eventData, eventHandler);
370
399
  }
371
400
 
372
401
  /**
373
- * proper viewstate -> form assignment
402
+ * proper viewState -> form assignment
374
403
  *
375
- * @param forms the forms to append the viewstate to
376
- * @param viewState the final viewstate
404
+ * @param forms the forms to append the viewState to
405
+ * @param viewState the final viewState
406
+ * @param namingContainerId
377
407
  */
378
- private appendViewStateToForms(forms: DQ, viewState: string) {
379
- this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState);
408
+ private appendViewStateToForms(forms: DQ, namedViewRoot: boolean, viewState: string, namingContainerId = "") {
409
+ this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), namedViewRoot, viewState, namingContainerId);
380
410
  }
381
411
 
382
412
 
383
413
  /**
384
- * proper clientwindow -> form assignment
414
+ * proper clientWindow -> form assignment
385
415
  *
386
- * @param forms the forms to append the viewstate to
387
- * @param clientWindow the final viewstate
416
+ * @param forms the forms to append the viewState to
417
+ * @param clientWindow the final viewState
418
+ * @param namingContainerId
388
419
  */
389
- private appendClientWindowToForms(forms: DQ, clientWindow: string) {
390
- this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow);
420
+ private appendClientWindowToForms(forms: DQ, namedViewRoot: boolean, clientWindow: string, namingContainerId = "") {
421
+ this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), namedViewRoot, clientWindow, namingContainerId);
391
422
  }
392
423
 
393
424
  /**
@@ -395,44 +426,45 @@ export class ResponseProcessor implements IResponseProcessor {
395
426
  *
396
427
  * @param forms the forms to append or change to
397
428
  * @param selector the selector for the state
429
+ * @param namedViewRoot if set to true, the name is also prefixed
398
430
  * @param state the state itself which needs to be assigned
399
431
  *
432
+ * @param namingContainerId
400
433
  * @private
401
434
  */
402
- private assignState(forms: DQ, selector: string, state: string) {
403
- forms.each((form: DQ) => {
404
- let stateHolders = form.querySelectorAll(selector)
405
- .orElseLazy(() => ResponseProcessor.newViewStateElement(form));
406
-
407
- stateHolders.attr("value").value = state;
435
+ private assignState(forms: DQ, selector: string, namedViewRoot: boolean, state: string, namingContainerId: string) {
436
+ /**
437
+ * creates the viewState or client window id element
438
+ * @param form
439
+ */
440
+ const createAndAppendHiddenInput = (form: DomQuery) => {
441
+ return new HiddenInputBuilder(selector)
442
+ .withNamingContainerId(namingContainerId)
443
+ .withParent(form)
444
+ .withNamedViewRoot(namedViewRoot)
445
+ .build();
446
+ };
447
+
448
+ forms.each(form => {
449
+ const hiddenInput = form.querySelectorAll(selector)
450
+ .orElseLazy(() => createAndAppendHiddenInput(form));
451
+ hiddenInput.val = state;
408
452
  });
409
453
  }
410
454
 
411
455
  /**
412
- * Helper to Create a new JSF ViewState Element
413
- *
414
- * @param parent, the parent node to attach the viewstate element to
415
- * (usually a form node)
416
- */
417
- private static newViewStateElement(parent: DQ): DQ {
418
- let newViewState = DQ.fromMarkup($nsp(HTML_VIEWSTATE));
419
- newViewState.appendTo(parent);
420
- return newViewState;
421
- }
422
-
423
- /**
424
- * Stores certain aspects of the dom for later post processing
456
+ * Stores certain aspects of the dom for later post-processing
425
457
  *
426
458
  * @param updateForms the update forms which should receive standardized internal jsf data
427
- * @param toBeEvaled the resulting elements which should be evaled
459
+ * @param toBeEvaluated the resulting elements which should be evaluated
428
460
  */
429
- private storeForPostProcessing(updateForms: DQ, toBeEvaled: DQ) {
461
+ private storeForPostProcessing(updateForms: DQ, toBeEvaluated: DQ) {
430
462
  this.storeForUpdate(updateForms);
431
- this.storeForEval(toBeEvaled);
463
+ this.storeForEval(toBeEvaluated);
432
464
  }
433
465
 
434
466
  /**
435
- * helper to store a given form for the update post processing (viewstate)
467
+ * helper to store a given form for the update post-processing (viewState)
436
468
  *
437
469
  * @param updateForms the dom query object pointing to the forms which need to be updated
438
470
  */
@@ -443,28 +475,23 @@ export class ResponseProcessor implements IResponseProcessor {
443
475
  /**
444
476
  * same for eval (js and css)
445
477
  *
446
- * @param toBeEvaled
478
+ * @param toBeEvaluated
447
479
  */
448
- private storeForEval(toBeEvaled: DQ) {
449
- this.internalContext.assign(UPDATE_ELEMS).value.push(toBeEvaled);
450
- }
451
-
452
- // head eval is always sticky
453
- private storeForHeadEval(toBeEvaled: DQ, sticky) {
454
- this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(toBeEvaled);
480
+ private storeForEval(toBeEvaluated: DQ) {
481
+ this.internalContext.assign(UPDATE_ELEMS).value.push(toBeEvaluated);
455
482
  }
456
483
 
457
484
  /**
458
- * check whether a given XMLQuery node is an explicit viewstate node
485
+ * check whether a given XMLQuery node is an explicit viewState node
459
486
  *
460
487
  * @param node the node to check
461
- * @returns true of it ii
488
+ * @returns if it is a viewState node
462
489
  */
463
490
  private static isViewStateNode(node: XMLQuery): boolean {
464
- let separatorChar = (window?.faces ?? window?.jsf).separatorchar;
491
+ const SEP = $faces().separatorchar;
465
492
  return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_VIEWSTATE) ||
466
- node?.id?.value?.indexOf([separatorChar, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
467
- node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), separatorChar].join(EMPTY_STR)) != -1);
493
+ node?.id?.value?.indexOf([SEP, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
494
+ node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), SEP].join(EMPTY_STR)) != -1);
468
495
  }
469
496
 
470
497
  /**
@@ -474,15 +501,59 @@ export class ResponseProcessor implements IResponseProcessor {
474
501
  * @returns true of it ii
475
502
  */
476
503
  private static isClientWindowNode(node: XMLQuery): boolean {
477
- let separatorChar = (window?.faces ?? window?.jsf).separatorchar;
504
+ const SEP = $faces().separatorchar;
478
505
  return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_CLIENT_WINDOW) ||
479
- node?.id?.value?.indexOf([separatorChar, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
480
- node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), separatorChar].join(EMPTY_STR)) != -1);
506
+ node?.id?.value?.indexOf([SEP, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
507
+ node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), SEP].join(EMPTY_STR)) != -1);
481
508
  }
482
509
 
483
510
  private triggerOnError(errorData: ErrorData) {
484
- this.externalContext.getIf(ON_ERROR).orElse(this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
511
+ this.externalContext.getIf(ON_ERROR).orElseLazy(() => this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
485
512
  }
486
513
 
514
+ /**
515
+ * filters the forms according to being member of the "execute" or "render" cycle
516
+ * @param affectedForm
517
+ * @private
518
+ */
519
+ private isInExecuteOrRender(affectedForm) {
520
+ const executes = this.externalContext.getIf($nsp(P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
521
+ const renders = this.externalContext.getIf(P_RENDER_OVERRIDE)
522
+ .orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
523
+ .orElse(IDENT_NONE).value.split(/\s+/gi);
524
+ const executeAndRenders = executes.concat(...renders);
525
+ return LazyStream.of(...executeAndRenders).filter(nameOrId => {
526
+ if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
527
+ return true;
528
+ }
487
529
 
530
+ const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
531
+ //either the form directly is in execute or render or one of its children or one of its parents
532
+ return affectedForm.matchesSelector(NAME_OR_ID) ||
533
+ affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
534
+ affectedForm.firstParent(NAME_OR_ID).isPresent();
535
+ }).first().isPresent();
536
+ }
537
+
538
+ /**
539
+ * gets all forms under a single naming container id
540
+ * @param namingContainerId
541
+ * @private
542
+ */
543
+ private getContainerForms(namingContainerId: Config) {
544
+ if (namingContainerId.isPresent()) {
545
+ //naming container mode, all forms under naming container id must be processed
546
+ return DQ$(this.getNameOrIdSelector(namingContainerId.value))
547
+ // missing condition if the naming container is not present we have to
548
+ // use the body as fallback
549
+ .orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
550
+ .byTagName(HTML_TAG_FORM, true);
551
+ } else {
552
+ return DQ.byTagName(HTML_TAG_FORM);
553
+ }
554
+ }
555
+
556
+ private getNameOrIdSelector(nameOrId) {
557
+ return `[id='${nameOrId}'], [name='${nameOrId}']`;
558
+ }
488
559
  }