jsf.js_next_gen 4.0.0-RC.2 → 4.0.0-RC.21
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.
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/myfaces.ab.html +2 -2
- package/dist/window/faces-development.js +789 -306
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.LICENSE.txt +0 -2
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +789 -306
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.LICENSE.txt +0 -2
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +16 -16
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +19 -2
- package/src/main/typescript/api/_api.ts +5 -4
- package/src/main/typescript/impl/AjaxImpl.ts +109 -37
- package/src/main/typescript/impl/core/Const.ts +48 -38
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +78 -0
- package/src/main/typescript/impl/util/Lang.ts +9 -11
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -1
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +40 -22
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
- package/src/main/typescript/impl/xhrCore/Response.ts +25 -25
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +157 -98
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +4 -2
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +24 -14
- package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +72 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +116 -9
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +236 -11
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +368 -31
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +41 -7
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +5 -4
- package/target/api/_api.js.map +1 -1
- package/target/impl/AjaxImpl.js +97 -26
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +48 -37
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +9 -2
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +69 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +8 -10
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +1 -1
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +34 -15
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +13 -13
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +136 -82
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +4 -2
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +20 -11
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +23 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +63 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +2 -2
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +2 -2
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +1 -1
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +203 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +101 -4
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +212 -9
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +303 -22
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +36 -6
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/tmp.xml +36 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
- package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
- package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
|
@@ -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
|
-
|
|
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,
|
|
38
45
|
ON_ERROR,
|
|
39
|
-
ON_EVENT,
|
|
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
|
-
|
|
43
|
-
|
|
53
|
+
PARTIAL_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
|
-
|
|
61
|
+
XML_TAG_AFTER,
|
|
62
|
+
XML_TAG_ATTR,
|
|
63
|
+
XML_TAG_BEFORE
|
|
56
64
|
} from "../core/Const";
|
|
57
|
-
import trim = Lang.trim;
|
|
58
65
|
import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
66
|
+
import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
|
|
67
|
+
import trim = Lang.trim;
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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);
|
|
94
111
|
|
|
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
112
|
//incoming either the outer head tag or its children
|
|
100
|
-
|
|
101
|
-
//this
|
|
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());
|
|
118
|
+
|
|
119
|
+
this.addToHeadDeferred(scriptElements);
|
|
102
120
|
}
|
|
103
121
|
|
|
104
|
-
|
|
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,21 +133,20 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
117
133
|
*/
|
|
118
134
|
replaceBody(shadowDocument: XMLQuery | DQ) {
|
|
119
135
|
|
|
120
|
-
|
|
136
|
+
const shadowBody = shadowDocument.querySelectorAll(HTML_TAG_BODY);
|
|
121
137
|
if (!shadowBody.isPresent()) {
|
|
122
138
|
return;
|
|
123
139
|
}
|
|
124
140
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
146
|
// we need a separate step for post-processing the incoming
|
|
132
147
|
// attributes, like classes, styles etc...
|
|
133
|
-
resultingBody.copyAttrs(shadowBody);
|
|
134
|
-
|
|
148
|
+
(resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
|
|
149
|
+
this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
|
|
135
150
|
this.storeForPostProcessing(updateForms, resultingBody);
|
|
136
151
|
}
|
|
137
152
|
|
|
@@ -158,18 +173,18 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
158
173
|
* <error>
|
|
159
174
|
*/
|
|
160
175
|
|
|
161
|
-
|
|
176
|
+
const mergedErrorData = new ExtConfig({});
|
|
162
177
|
mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
|
|
163
178
|
mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
|
|
164
179
|
mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
|
|
165
180
|
|
|
166
|
-
|
|
181
|
+
const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
|
|
167
182
|
|
|
168
183
|
//we now store the response xml also in the error data for further details
|
|
169
184
|
mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
|
|
170
185
|
|
|
171
186
|
// error post-processing and enrichment (standard messages from keys)
|
|
172
|
-
|
|
187
|
+
const errorData = ErrorData.fromServerError(mergedErrorData);
|
|
173
188
|
|
|
174
189
|
// we now trigger an internally stored onError function which might be an attached to the context
|
|
175
190
|
// either we do not have an internal on error, or an on error has been based via params from the outside.
|
|
@@ -187,7 +202,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
187
202
|
redirect(node: XMLQuery) {
|
|
188
203
|
Assertions.assertUrlExists(node);
|
|
189
204
|
|
|
190
|
-
|
|
205
|
+
const redirectUrl = trim(node.attr(ATTR_URL).value);
|
|
191
206
|
if (redirectUrl != EMPTY_STR) {
|
|
192
207
|
window.location.href = redirectUrl;
|
|
193
208
|
}
|
|
@@ -199,8 +214,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
199
214
|
* @param cdataBlock the cdata block with the new html code
|
|
200
215
|
*/
|
|
201
216
|
update(node: XMLQuery, cdataBlock: string) {
|
|
202
|
-
|
|
203
|
-
|
|
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));
|
|
204
219
|
if (sourceForm) {
|
|
205
220
|
this.storeForPostProcessing(sourceForm, result);
|
|
206
221
|
}
|
|
@@ -220,9 +235,9 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
220
235
|
* @param node
|
|
221
236
|
*/
|
|
222
237
|
attributes(node: XMLQuery) {
|
|
223
|
-
|
|
238
|
+
const elem = DQ.byId(node.id.value, true);
|
|
224
239
|
|
|
225
|
-
node.byTagName(
|
|
240
|
+
node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
|
|
226
241
|
elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
|
|
227
242
|
});
|
|
228
243
|
}
|
|
@@ -243,17 +258,16 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
243
258
|
insert(node: XMLQuery) {
|
|
244
259
|
//let insertId = node.id; //not used atm
|
|
245
260
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
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);
|
|
250
264
|
|
|
251
265
|
if (before.isPresent()) {
|
|
252
266
|
DQ.byId(before.value, true).insertBefore(insertNodes);
|
|
253
267
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
254
268
|
}
|
|
255
269
|
if (after.isPresent()) {
|
|
256
|
-
|
|
270
|
+
const domQuery = DQ.byId(after.value, true);
|
|
257
271
|
domQuery.insertAfter(insertNodes);
|
|
258
272
|
|
|
259
273
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -266,12 +280,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
266
280
|
* @param node the node hosting the insert data
|
|
267
281
|
*/
|
|
268
282
|
insertWithSubTags(node: XMLQuery) {
|
|
269
|
-
|
|
270
|
-
|
|
283
|
+
const before = node.querySelectorAll(XML_TAG_BEFORE);
|
|
284
|
+
const after = node.querySelectorAll(XML_TAG_AFTER);
|
|
271
285
|
|
|
272
286
|
before.each(item => {
|
|
273
|
-
|
|
274
|
-
|
|
287
|
+
const insertId = item.attr(ATTR_ID);
|
|
288
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
275
289
|
if (insertId.isPresent()) {
|
|
276
290
|
DQ.byId(insertId.value, true).insertBefore(insertNodes);
|
|
277
291
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -279,8 +293,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
279
293
|
});
|
|
280
294
|
|
|
281
295
|
after.each(item => {
|
|
282
|
-
|
|
283
|
-
|
|
296
|
+
const insertId = item.attr(ATTR_ID);
|
|
297
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
284
298
|
if (insertId.isPresent()) {
|
|
285
299
|
DQ.byId(insertId.value, true).insertAfter(insertNodes);
|
|
286
300
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -295,7 +309,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
295
309
|
*/
|
|
296
310
|
processViewState(node: XMLQuery): boolean {
|
|
297
311
|
if (ResponseProcessor.isViewStateNode(node)) {
|
|
298
|
-
|
|
312
|
+
const state = node.cDATAAsString;
|
|
299
313
|
this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
300
314
|
return true;
|
|
301
315
|
}
|
|
@@ -304,7 +318,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
304
318
|
|
|
305
319
|
processClientWindow(node: XMLQuery): boolean {
|
|
306
320
|
if (ResponseProcessor.isClientWindowNode(node)) {
|
|
307
|
-
|
|
321
|
+
const state = node.cDATAAsString;
|
|
308
322
|
this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
309
323
|
return true;
|
|
310
324
|
}
|
|
@@ -333,29 +347,29 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
333
347
|
*/
|
|
334
348
|
fixViewStates() {
|
|
335
349
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
|
|
336
|
-
.each((
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
|
|
350
|
+
.each(([, value]) => {
|
|
351
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
352
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
353
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
341
354
|
|
|
342
|
-
this.appendViewStateToForms(
|
|
355
|
+
this.appendViewStateToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
343
356
|
});
|
|
344
357
|
}
|
|
345
358
|
|
|
359
|
+
|
|
360
|
+
|
|
346
361
|
/**
|
|
347
362
|
* same as with view states before applies the incoming client windows as last step after the rest of the processing
|
|
348
363
|
* is done.
|
|
349
364
|
*/
|
|
350
365
|
fixClientWindow() {
|
|
351
366
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
|
|
352
|
-
.each((
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
let affectedForms2 = nameSpace.filter(item => item.tagName.orElse(EMPTY_STR).value.toLowerCase() == TAG_FORM);
|
|
367
|
+
.each(([, value]) => {
|
|
368
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
369
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
370
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
357
371
|
|
|
358
|
-
this.appendClientWindowToForms(
|
|
372
|
+
this.appendClientWindowToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
359
373
|
});
|
|
360
374
|
}
|
|
361
375
|
|
|
@@ -363,10 +377,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
363
377
|
* all processing done we can close the request and send the appropriate events
|
|
364
378
|
*/
|
|
365
379
|
done() {
|
|
366
|
-
|
|
380
|
+
const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
|
|
367
381
|
|
|
368
382
|
//because some frameworks might decorate them over the context in the response
|
|
369
|
-
|
|
383
|
+
const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
|
|
370
384
|
Implementation.sendEvent(eventData, eventHandler);
|
|
371
385
|
}
|
|
372
386
|
|
|
@@ -375,9 +389,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
375
389
|
*
|
|
376
390
|
* @param forms the forms to append the viewState to
|
|
377
391
|
* @param viewState the final viewState
|
|
392
|
+
* @param namingContainerId
|
|
378
393
|
*/
|
|
379
|
-
private appendViewStateToForms(forms: DQ, viewState: string) {
|
|
380
|
-
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState);
|
|
394
|
+
private appendViewStateToForms(forms: DQ, viewState: string, namingContainerId = "") {
|
|
395
|
+
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState, namingContainerId);
|
|
381
396
|
}
|
|
382
397
|
|
|
383
398
|
|
|
@@ -386,9 +401,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
386
401
|
*
|
|
387
402
|
* @param forms the forms to append the viewState to
|
|
388
403
|
* @param clientWindow the final viewState
|
|
404
|
+
* @param namingContainerId
|
|
389
405
|
*/
|
|
390
|
-
private appendClientWindowToForms(forms: DQ, clientWindow: string) {
|
|
391
|
-
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow);
|
|
406
|
+
private appendClientWindowToForms(forms: DQ, clientWindow: string, namingContainerId = "") {
|
|
407
|
+
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow, namingContainerId);
|
|
392
408
|
}
|
|
393
409
|
|
|
394
410
|
/**
|
|
@@ -398,29 +414,28 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
398
414
|
* @param selector the selector for the state
|
|
399
415
|
* @param state the state itself which needs to be assigned
|
|
400
416
|
*
|
|
417
|
+
* @param namingContainerId
|
|
401
418
|
* @private
|
|
402
419
|
*/
|
|
403
|
-
private assignState(forms: DQ, selector: string, state: string) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
420
|
+
private assignState(forms: DQ, selector: string, state: string, namingContainerId: string) {
|
|
421
|
+
/**
|
|
422
|
+
* creates the viewState or client window id element
|
|
423
|
+
* @param form
|
|
424
|
+
*/
|
|
425
|
+
const createAndAppendHiddenInput = (form: DomQuery) => {
|
|
426
|
+
return new HiddenInputBuilder(selector)
|
|
427
|
+
.withNamingContainerId(namingContainerId)
|
|
428
|
+
.withParent(form)
|
|
429
|
+
.build();
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
forms.each(form => {
|
|
433
|
+
const hiddenInput = form.querySelectorAll(selector)
|
|
434
|
+
.orElseLazy(() => createAndAppendHiddenInput(form));
|
|
435
|
+
hiddenInput.val = state;
|
|
409
436
|
});
|
|
410
437
|
}
|
|
411
438
|
|
|
412
|
-
/**
|
|
413
|
-
* Helper to Create a new JSF ViewState Element
|
|
414
|
-
*
|
|
415
|
-
* @param parent, the parent node to attach the viewState element to
|
|
416
|
-
* (usually a form node)
|
|
417
|
-
*/
|
|
418
|
-
private static newViewStateElement(parent: DQ): DQ {
|
|
419
|
-
let newViewState = DQ.fromMarkup($nsp(HTML_VIEWSTATE));
|
|
420
|
-
newViewState.appendTo(parent);
|
|
421
|
-
return newViewState;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
439
|
/**
|
|
425
440
|
* Stores certain aspects of the dom for later post-processing
|
|
426
441
|
*
|
|
@@ -457,10 +472,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
457
472
|
* @returns if it is a viewState node
|
|
458
473
|
*/
|
|
459
474
|
private static isViewStateNode(node: XMLQuery): boolean {
|
|
460
|
-
|
|
475
|
+
const SEP = $faces().separatorchar;
|
|
461
476
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_VIEWSTATE) ||
|
|
462
|
-
node?.id?.value?.indexOf([
|
|
463
|
-
node?.id?.value?.indexOf([$nsp(P_VIEWSTATE),
|
|
477
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
|
|
478
|
+
node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), SEP].join(EMPTY_STR)) != -1);
|
|
464
479
|
}
|
|
465
480
|
|
|
466
481
|
/**
|
|
@@ -470,15 +485,59 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
470
485
|
* @returns true of it ii
|
|
471
486
|
*/
|
|
472
487
|
private static isClientWindowNode(node: XMLQuery): boolean {
|
|
473
|
-
|
|
488
|
+
const SEP = $faces().separatorchar;
|
|
474
489
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_CLIENT_WINDOW) ||
|
|
475
|
-
node?.id?.value?.indexOf([
|
|
476
|
-
node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW),
|
|
490
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
|
|
491
|
+
node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), SEP].join(EMPTY_STR)) != -1);
|
|
477
492
|
}
|
|
478
493
|
|
|
479
494
|
private triggerOnError(errorData: ErrorData) {
|
|
480
|
-
this.externalContext.getIf(ON_ERROR).
|
|
495
|
+
this.externalContext.getIf(ON_ERROR).orElseLazy(() => this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* filters the forms according to being member of the "execute" or "render" cycle
|
|
500
|
+
* @param affectedForm
|
|
501
|
+
* @private
|
|
502
|
+
*/
|
|
503
|
+
private isInExecuteOrRender(affectedForm) {
|
|
504
|
+
const executes = this.externalContext.getIf($nsp(P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
|
|
505
|
+
const renders = this.externalContext.getIf(P_RENDER_OVERRIDE)
|
|
506
|
+
.orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
|
|
507
|
+
.orElse(IDENT_NONE).value.split(/\s+/gi);
|
|
508
|
+
const executeAndRenders = executes.concat(...renders);
|
|
509
|
+
return LazyStream.of(...executeAndRenders).filter(nameOrId => {
|
|
510
|
+
if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
|
|
515
|
+
//either the form directly is in execute or render or one of its children or one of its parents
|
|
516
|
+
return affectedForm.matchesSelector(NAME_OR_ID) ||
|
|
517
|
+
affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
|
|
518
|
+
affectedForm.firstParent(NAME_OR_ID).isPresent();
|
|
519
|
+
}).first().isPresent();
|
|
481
520
|
}
|
|
482
521
|
|
|
522
|
+
/**
|
|
523
|
+
* gets all forms under a single naming container id
|
|
524
|
+
* @param namingContainerId
|
|
525
|
+
* @private
|
|
526
|
+
*/
|
|
527
|
+
private getContainerForms(namingContainerId: Config) {
|
|
528
|
+
if (namingContainerId.isPresent()) {
|
|
529
|
+
//naming container mode, all forms under naming container id must be processed
|
|
530
|
+
return DQ$(this.getNameOrIdSelector(namingContainerId.value))
|
|
531
|
+
// missing condition if the naming container is not present we have to
|
|
532
|
+
// use the body as fallback
|
|
533
|
+
.orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
|
|
534
|
+
.byTagName(HTML_TAG_FORM, true);
|
|
535
|
+
} else {
|
|
536
|
+
return DQ.byTagName(HTML_TAG_FORM);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
483
539
|
|
|
540
|
+
private getNameOrIdSelector(nameOrId) {
|
|
541
|
+
return `[id='${nameOrId}'], [name='${nameOrId}']`;
|
|
542
|
+
}
|
|
484
543
|
}
|
|
@@ -109,8 +109,10 @@ export class XhrFormData extends Config {
|
|
|
109
109
|
* @param form the form holding the view state value
|
|
110
110
|
*/
|
|
111
111
|
private applyViewState(form: DQ) {
|
|
112
|
-
let
|
|
113
|
-
|
|
112
|
+
let viewStateElement = form.querySelectorAllDeep(`[name*='${P_VIEWSTATE}'`);
|
|
113
|
+
let viewState = viewStateElement.inputValue;
|
|
114
|
+
// this.appendIf(viewState.isPresent(), P_VIEWSTATE).value = viewState.value;
|
|
115
|
+
this.appendIf(viewState.isPresent(), viewStateElement.name.value).value = viewState.value;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
/**
|
|
@@ -23,20 +23,21 @@ import {ErrorData} from "./ErrorData";
|
|
|
23
23
|
import {EventData} from "./EventData";
|
|
24
24
|
import {ExtLang} from "../util/Lang";
|
|
25
25
|
import {
|
|
26
|
+
$faces,
|
|
26
27
|
BEGIN,
|
|
27
28
|
COMPLETE,
|
|
28
29
|
CONTENT_TYPE,
|
|
29
30
|
CTX_PARAM_MF_INTERNAL,
|
|
30
|
-
|
|
31
|
+
CTX_PARAM_REQ_PASS_THR,
|
|
31
32
|
ERROR,
|
|
32
33
|
HEAD_FACES_REQ,
|
|
33
34
|
MALFORMEDXML,
|
|
34
35
|
NO_TIMEOUT,
|
|
35
36
|
ON_ERROR,
|
|
36
|
-
ON_EVENT, P_EXECUTE,
|
|
37
|
+
ON_EVENT, P_EXECUTE, P_PARTIAL_SOURCE,
|
|
37
38
|
REQ_ACCEPT,
|
|
38
39
|
REQ_TYPE_GET,
|
|
39
|
-
REQ_TYPE_POST,
|
|
40
|
+
REQ_TYPE_POST, SOURCE,
|
|
40
41
|
STATE_EVT_TIMEOUT,
|
|
41
42
|
STD_ACCEPT,
|
|
42
43
|
URL_ENCODED,
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
} from "../core/Const";
|
|
45
46
|
import {resolveFinalUrl, resolveHandlerFunc} from "./RequestDataResolver";
|
|
46
47
|
import failSaveExecute = ExtLang.failSaveExecute;
|
|
48
|
+
import {ExtConfig} from "../util/ExtDomQuery";
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
51
|
* Faces XHR Request Wrapper
|
|
@@ -86,7 +88,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
86
88
|
constructor(
|
|
87
89
|
private source: DQ,
|
|
88
90
|
private sourceForm: DQ,
|
|
89
|
-
private requestContext:
|
|
91
|
+
private requestContext: ExtConfig,
|
|
90
92
|
private internalContext: Config,
|
|
91
93
|
private partialIdsArray = [],
|
|
92
94
|
private timeout = NO_TIMEOUT,
|
|
@@ -111,12 +113,12 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
111
113
|
let xhrObject = this.xhrObject;
|
|
112
114
|
|
|
113
115
|
let executesArr = () => {
|
|
114
|
-
return this.requestContext.getIf(
|
|
116
|
+
return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get("none").value.split(/\s+/gi);
|
|
115
117
|
};
|
|
116
118
|
try {
|
|
117
119
|
|
|
118
120
|
let formElement = this.sourceForm.getAsElem(0).value;
|
|
119
|
-
let viewState = (
|
|
121
|
+
let viewState = $faces().getViewState(formElement);
|
|
120
122
|
// encoded we need to decode
|
|
121
123
|
// We generated a base representation of the current form
|
|
122
124
|
// in case someone has overloaded the viewState with additional decorators we merge
|
|
@@ -131,15 +133,22 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
131
133
|
this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
|
|
132
134
|
|
|
133
135
|
// next step the pass through parameters are merged in for post params
|
|
136
|
+
this.requestContext.$nspEnabled = false;
|
|
134
137
|
let requestContext = this.requestContext;
|
|
135
|
-
let
|
|
136
|
-
|
|
138
|
+
let requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
|
|
139
|
+
requestPassThroughParams.$nspEnabled = false;
|
|
137
140
|
// this is an extension where we allow pass through parameters to be sent down additionally
|
|
138
141
|
// this can be used and is used in the impl to enrich the post request parameters with additional
|
|
139
142
|
// information
|
|
140
|
-
formData.shallowMerge(passThroughParams, true, true);
|
|
141
143
|
|
|
142
|
-
|
|
144
|
+
try {
|
|
145
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
146
|
+
} finally {
|
|
147
|
+
this.requestContext.$nspEnabled = true;
|
|
148
|
+
requestPassThroughParams.$nspEnabled = true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
143
152
|
|
|
144
153
|
// we have to shift the internal passthroughs around to build up our response context
|
|
145
154
|
let responseContext = this.responseContext;
|
|
@@ -290,7 +299,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
290
299
|
return;
|
|
291
300
|
}
|
|
292
301
|
|
|
293
|
-
(
|
|
302
|
+
$faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
private handleMalFormedXML(resolve: Function) {
|
|
@@ -300,9 +309,9 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
300
309
|
status: MALFORMEDXML,
|
|
301
310
|
responseCode: 200,
|
|
302
311
|
responseText: this.xhrObject?.responseText,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
312
|
+
// we remap the element just in case it gets replaced
|
|
313
|
+
// it will be unremapped
|
|
314
|
+
source: this.source.id.value
|
|
306
315
|
};
|
|
307
316
|
try {
|
|
308
317
|
this.handleError(errorData, true);
|
|
@@ -352,6 +361,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
352
361
|
|
|
353
362
|
Implementation.sendEvent(eventData, eventHandler);
|
|
354
363
|
} catch (e) {
|
|
364
|
+
e.source = e?.source ?? this.requestContext.getIf(SOURCE).value;
|
|
355
365
|
this.handleError(e);
|
|
356
366
|
throw e;
|
|
357
367
|
}
|