jsf.js_next_gen 4.0.0-RC.2 → 4.0.0-RC.20
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 +783 -305
- 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 +783 -305
- 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 +74 -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 -96
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +1 -1
- 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 +196 -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 +40 -6
- 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 +66 -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 +1 -1
- 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 +200 -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 +35 -5
- 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,21 @@ 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
|
-
|
|
141
|
+
const shadowInnerHTML: string = <string>shadowBody.innerHTML;
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
const resultingBody = <DQ>ExtDomQuery.querySelectorAll(HTML_TAG_BODY);
|
|
144
|
+
const updateForms = resultingBody.querySelectorAll(HTML_TAG_FORM);
|
|
129
145
|
|
|
130
146
|
// main difference, we cannot replace the body itself, but only its content
|
|
131
147
|
// we need a separate step for post-processing the incoming
|
|
132
148
|
// attributes, like classes, styles etc...
|
|
133
|
-
resultingBody.copyAttrs(shadowBody);
|
|
134
|
-
|
|
149
|
+
(resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
|
|
150
|
+
this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
|
|
135
151
|
this.storeForPostProcessing(updateForms, resultingBody);
|
|
136
152
|
}
|
|
137
153
|
|
|
@@ -158,18 +174,18 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
158
174
|
* <error>
|
|
159
175
|
*/
|
|
160
176
|
|
|
161
|
-
|
|
177
|
+
const mergedErrorData = new ExtConfig({});
|
|
162
178
|
mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
|
|
163
179
|
mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
|
|
164
180
|
mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
|
|
165
181
|
|
|
166
|
-
|
|
182
|
+
const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
|
|
167
183
|
|
|
168
184
|
//we now store the response xml also in the error data for further details
|
|
169
185
|
mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
|
|
170
186
|
|
|
171
187
|
// error post-processing and enrichment (standard messages from keys)
|
|
172
|
-
|
|
188
|
+
const errorData = ErrorData.fromServerError(mergedErrorData);
|
|
173
189
|
|
|
174
190
|
// we now trigger an internally stored onError function which might be an attached to the context
|
|
175
191
|
// either we do not have an internal on error, or an on error has been based via params from the outside.
|
|
@@ -187,7 +203,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
187
203
|
redirect(node: XMLQuery) {
|
|
188
204
|
Assertions.assertUrlExists(node);
|
|
189
205
|
|
|
190
|
-
|
|
206
|
+
const redirectUrl = trim(node.attr(ATTR_URL).value);
|
|
191
207
|
if (redirectUrl != EMPTY_STR) {
|
|
192
208
|
window.location.href = redirectUrl;
|
|
193
209
|
}
|
|
@@ -199,8 +215,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
199
215
|
* @param cdataBlock the cdata block with the new html code
|
|
200
216
|
*/
|
|
201
217
|
update(node: XMLQuery, cdataBlock: string) {
|
|
202
|
-
|
|
203
|
-
|
|
218
|
+
const result = ExtDomQuery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
|
|
219
|
+
const sourceForm = result?.firstParent(HTML_TAG_FORM).orElseLazy(() => result.byTagName(HTML_TAG_FORM, true));
|
|
204
220
|
if (sourceForm) {
|
|
205
221
|
this.storeForPostProcessing(sourceForm, result);
|
|
206
222
|
}
|
|
@@ -220,9 +236,9 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
220
236
|
* @param node
|
|
221
237
|
*/
|
|
222
238
|
attributes(node: XMLQuery) {
|
|
223
|
-
|
|
239
|
+
const elem = DQ.byId(node.id.value, true);
|
|
224
240
|
|
|
225
|
-
node.byTagName(
|
|
241
|
+
node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
|
|
226
242
|
elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
|
|
227
243
|
});
|
|
228
244
|
}
|
|
@@ -243,17 +259,17 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
243
259
|
insert(node: XMLQuery) {
|
|
244
260
|
//let insertId = node.id; //not used atm
|
|
245
261
|
|
|
246
|
-
|
|
247
|
-
|
|
262
|
+
const before = node.attr(XML_TAG_BEFORE);
|
|
263
|
+
const after = node.attr(XML_TAG_AFTER);
|
|
248
264
|
|
|
249
|
-
|
|
265
|
+
const insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
|
|
250
266
|
|
|
251
267
|
if (before.isPresent()) {
|
|
252
268
|
DQ.byId(before.value, true).insertBefore(insertNodes);
|
|
253
269
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
254
270
|
}
|
|
255
271
|
if (after.isPresent()) {
|
|
256
|
-
|
|
272
|
+
const domQuery = DQ.byId(after.value, true);
|
|
257
273
|
domQuery.insertAfter(insertNodes);
|
|
258
274
|
|
|
259
275
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -266,12 +282,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
266
282
|
* @param node the node hosting the insert data
|
|
267
283
|
*/
|
|
268
284
|
insertWithSubTags(node: XMLQuery) {
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
const before = node.querySelectorAll(XML_TAG_BEFORE);
|
|
286
|
+
const after = node.querySelectorAll(XML_TAG_AFTER);
|
|
271
287
|
|
|
272
288
|
before.each(item => {
|
|
273
|
-
|
|
274
|
-
|
|
289
|
+
const insertId = item.attr(ATTR_ID);
|
|
290
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
275
291
|
if (insertId.isPresent()) {
|
|
276
292
|
DQ.byId(insertId.value, true).insertBefore(insertNodes);
|
|
277
293
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -279,8 +295,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
279
295
|
});
|
|
280
296
|
|
|
281
297
|
after.each(item => {
|
|
282
|
-
|
|
283
|
-
|
|
298
|
+
const insertId = item.attr(ATTR_ID);
|
|
299
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
284
300
|
if (insertId.isPresent()) {
|
|
285
301
|
DQ.byId(insertId.value, true).insertAfter(insertNodes);
|
|
286
302
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -295,7 +311,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
295
311
|
*/
|
|
296
312
|
processViewState(node: XMLQuery): boolean {
|
|
297
313
|
if (ResponseProcessor.isViewStateNode(node)) {
|
|
298
|
-
|
|
314
|
+
const state = node.cDATAAsString;
|
|
299
315
|
this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
300
316
|
return true;
|
|
301
317
|
}
|
|
@@ -304,7 +320,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
304
320
|
|
|
305
321
|
processClientWindow(node: XMLQuery): boolean {
|
|
306
322
|
if (ResponseProcessor.isClientWindowNode(node)) {
|
|
307
|
-
|
|
323
|
+
const state = node.cDATAAsString;
|
|
308
324
|
this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
309
325
|
return true;
|
|
310
326
|
}
|
|
@@ -333,29 +349,29 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
333
349
|
*/
|
|
334
350
|
fixViewStates() {
|
|
335
351
|
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);
|
|
352
|
+
.each(([, value]) => {
|
|
353
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
354
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
355
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
341
356
|
|
|
342
|
-
this.appendViewStateToForms(
|
|
357
|
+
this.appendViewStateToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
343
358
|
});
|
|
344
359
|
}
|
|
345
360
|
|
|
361
|
+
|
|
362
|
+
|
|
346
363
|
/**
|
|
347
364
|
* same as with view states before applies the incoming client windows as last step after the rest of the processing
|
|
348
365
|
* is done.
|
|
349
366
|
*/
|
|
350
367
|
fixClientWindow() {
|
|
351
368
|
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);
|
|
369
|
+
.each(([, value]) => {
|
|
370
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
371
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
372
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
357
373
|
|
|
358
|
-
this.appendClientWindowToForms(
|
|
374
|
+
this.appendClientWindowToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
359
375
|
});
|
|
360
376
|
}
|
|
361
377
|
|
|
@@ -363,10 +379,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
363
379
|
* all processing done we can close the request and send the appropriate events
|
|
364
380
|
*/
|
|
365
381
|
done() {
|
|
366
|
-
|
|
382
|
+
const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
|
|
367
383
|
|
|
368
384
|
//because some frameworks might decorate them over the context in the response
|
|
369
|
-
|
|
385
|
+
const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
|
|
370
386
|
Implementation.sendEvent(eventData, eventHandler);
|
|
371
387
|
}
|
|
372
388
|
|
|
@@ -375,9 +391,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
375
391
|
*
|
|
376
392
|
* @param forms the forms to append the viewState to
|
|
377
393
|
* @param viewState the final viewState
|
|
394
|
+
* @param namingContainerId
|
|
378
395
|
*/
|
|
379
|
-
private appendViewStateToForms(forms: DQ, viewState: string) {
|
|
380
|
-
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState);
|
|
396
|
+
private appendViewStateToForms(forms: DQ, viewState: string, namingContainerId = "") {
|
|
397
|
+
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState, namingContainerId);
|
|
381
398
|
}
|
|
382
399
|
|
|
383
400
|
|
|
@@ -386,9 +403,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
386
403
|
*
|
|
387
404
|
* @param forms the forms to append the viewState to
|
|
388
405
|
* @param clientWindow the final viewState
|
|
406
|
+
* @param namingContainerId
|
|
389
407
|
*/
|
|
390
|
-
private appendClientWindowToForms(forms: DQ, clientWindow: string) {
|
|
391
|
-
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow);
|
|
408
|
+
private appendClientWindowToForms(forms: DQ, clientWindow: string, namingContainerId = "") {
|
|
409
|
+
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow, namingContainerId);
|
|
392
410
|
}
|
|
393
411
|
|
|
394
412
|
/**
|
|
@@ -398,29 +416,28 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
398
416
|
* @param selector the selector for the state
|
|
399
417
|
* @param state the state itself which needs to be assigned
|
|
400
418
|
*
|
|
419
|
+
* @param namingContainerId
|
|
401
420
|
* @private
|
|
402
421
|
*/
|
|
403
|
-
private assignState(forms: DQ, selector: string, state: string) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
422
|
+
private assignState(forms: DQ, selector: string, state: string, namingContainerId: string) {
|
|
423
|
+
/**
|
|
424
|
+
* creates the viewState or client window id element
|
|
425
|
+
* @param form
|
|
426
|
+
*/
|
|
427
|
+
const createAndAppendHiddenInput = (form: DomQuery) => {
|
|
428
|
+
return new HiddenInputBuilder(selector)
|
|
429
|
+
.withNamingContainerId(namingContainerId)
|
|
430
|
+
.withParent(form)
|
|
431
|
+
.build();
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
forms.each(form => {
|
|
435
|
+
const hiddenInput = form.querySelectorAll(selector)
|
|
436
|
+
.orElseLazy(() => createAndAppendHiddenInput(form));
|
|
437
|
+
hiddenInput.val = state;
|
|
409
438
|
});
|
|
410
439
|
}
|
|
411
440
|
|
|
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
441
|
/**
|
|
425
442
|
* Stores certain aspects of the dom for later post-processing
|
|
426
443
|
*
|
|
@@ -457,10 +474,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
457
474
|
* @returns if it is a viewState node
|
|
458
475
|
*/
|
|
459
476
|
private static isViewStateNode(node: XMLQuery): boolean {
|
|
460
|
-
|
|
477
|
+
const SEP = $faces().separatorchar;
|
|
461
478
|
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),
|
|
479
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
|
|
480
|
+
node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), SEP].join(EMPTY_STR)) != -1);
|
|
464
481
|
}
|
|
465
482
|
|
|
466
483
|
/**
|
|
@@ -470,15 +487,59 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
470
487
|
* @returns true of it ii
|
|
471
488
|
*/
|
|
472
489
|
private static isClientWindowNode(node: XMLQuery): boolean {
|
|
473
|
-
|
|
490
|
+
const SEP = $faces().separatorchar;
|
|
474
491
|
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),
|
|
492
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
|
|
493
|
+
node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), SEP].join(EMPTY_STR)) != -1);
|
|
477
494
|
}
|
|
478
495
|
|
|
479
496
|
private triggerOnError(errorData: ErrorData) {
|
|
480
|
-
this.externalContext.getIf(ON_ERROR).
|
|
497
|
+
this.externalContext.getIf(ON_ERROR).orElseLazy(() => this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
|
|
481
498
|
}
|
|
482
499
|
|
|
500
|
+
/**
|
|
501
|
+
* filters the forms according to being member of the "execute" or "render" cycle
|
|
502
|
+
* @param affectedForm
|
|
503
|
+
* @private
|
|
504
|
+
*/
|
|
505
|
+
private isInExecuteOrRender(affectedForm) {
|
|
506
|
+
const executes = this.externalContext.getIf($nsp(P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
|
|
507
|
+
const renders = this.externalContext.getIf(P_RENDER_OVERRIDE)
|
|
508
|
+
.orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
|
|
509
|
+
.orElse(IDENT_NONE).value.split(/\s+/gi);
|
|
510
|
+
const executeAndRenders = executes.concat(...renders);
|
|
511
|
+
return LazyStream.of(...executeAndRenders).filter(nameOrId => {
|
|
512
|
+
if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
|
|
513
|
+
return true;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
|
|
517
|
+
//either the form directly is in execute or render or one of its children or one of its parents
|
|
518
|
+
return affectedForm.matchesSelector(NAME_OR_ID) ||
|
|
519
|
+
affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
|
|
520
|
+
affectedForm.firstParent(NAME_OR_ID).isPresent();
|
|
521
|
+
}).first().isPresent();
|
|
522
|
+
}
|
|
483
523
|
|
|
524
|
+
/**
|
|
525
|
+
* gets all forms under a single naming container id
|
|
526
|
+
* @param namingContainerId
|
|
527
|
+
* @private
|
|
528
|
+
*/
|
|
529
|
+
private getContainerForms(namingContainerId: Config) {
|
|
530
|
+
if (namingContainerId.isPresent()) {
|
|
531
|
+
//naming container mode, all forms under naming container id must be processed
|
|
532
|
+
return DQ$(this.getNameOrIdSelector(namingContainerId.value))
|
|
533
|
+
// missing condition if the naming container is not present we have to
|
|
534
|
+
// use the body as fallback
|
|
535
|
+
.orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
|
|
536
|
+
.byTagName(HTML_TAG_FORM, true);
|
|
537
|
+
} else {
|
|
538
|
+
return DQ.byTagName(HTML_TAG_FORM);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private getNameOrIdSelector(nameOrId) {
|
|
543
|
+
return `[id='${nameOrId}'], [name='${nameOrId}']`;
|
|
544
|
+
}
|
|
484
545
|
}
|
|
@@ -109,7 +109,7 @@ 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 viewState = form.
|
|
112
|
+
let viewState = form.querySelectorAllDeep(`[name*='${P_VIEWSTATE}'`).inputValue;
|
|
113
113
|
this.appendIf(viewState.isPresent(), P_VIEWSTATE).value = viewState.value;
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -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
|
}
|