jsf.js_next_gen 4.0.0-RC.13 → 4.0.0-RC.15
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/window/faces-development.js +344 -231
- 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 +344 -231
- 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 +4 -4
- package/src/main/typescript/@types/definitions/index.d.ts +2 -0
- package/src/main/typescript/api/_api.ts +2 -2
- package/src/main/typescript/impl/AjaxImpl.ts +78 -38
- package/src/main/typescript/impl/core/Const.ts +42 -38
- package/src/main/typescript/impl/util/Assertions.ts +2 -2
- package/src/main/typescript/impl/util/ExtDomQuery.ts +2 -2
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +63 -0
- package/src/main/typescript/impl/util/Lang.ts +8 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +35 -27
- 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 +113 -121
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +1 -1
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +8 -7
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +19 -0
- 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/NamespacesRequestTest.spec.ts +195 -0
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +2 -0
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +20 -13
- package/target/api/_api.js +1 -1
- package/target/api/_api.js.map +1 -1
- package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
- package/target/impl/AjaxImpl.js +70 -29
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +43 -36
- 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 +1 -1
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +2 -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 +58 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +7 -9
- package/target/impl/util/Lang.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 +28 -18
- 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 +94 -109
- 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 +7 -8
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +18 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.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/NamespacesRequestTest.spec.js +199 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +17 -13
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test-classes/.gz +0 -0
- package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
- package/target/test-classes/fileuploadtest.html +24 -0
- package/target/test-classes/jsf-development.js +3559 -0
- package/target/test-classes/jsf-development.js.br +0 -0
- package/target/test-classes/jsf-development.js.gz +0 -0
- package/target/test-classes/jsf-development.js.map +1 -0
- package/target/test-classes/jsf.js +3 -0
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {Config, DomQueryCollector, DQ, DQ$, Lang, LazyStream, 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,31 +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
|
-
|
|
53
|
+
PARTIAL_ID,
|
|
54
|
+
RESPONSE_XML,
|
|
55
|
+
SEL_CLIENT_WINDOW_ELEM,
|
|
43
56
|
SEL_VIEWSTATE_ELEM,
|
|
44
57
|
SOURCE,
|
|
45
58
|
SUCCESS,
|
|
46
|
-
TAG_AFTER,
|
|
47
|
-
TAG_ATTR,
|
|
48
|
-
TAG_BEFORE,
|
|
49
|
-
TAG_BODY,
|
|
50
|
-
TAG_FORM,
|
|
51
|
-
TAG_HEAD,
|
|
52
59
|
UPDATE_ELEMS,
|
|
53
60
|
UPDATE_FORMS,
|
|
54
|
-
|
|
61
|
+
XML_TAG_AFTER,
|
|
62
|
+
XML_TAG_ATTR,
|
|
63
|
+
XML_TAG_BEFORE
|
|
55
64
|
} from "../core/Const";
|
|
56
|
-
import trim = Lang.trim;
|
|
57
65
|
import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
66
|
+
import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
|
|
67
|
+
import trim = Lang.trim;
|
|
58
68
|
|
|
59
69
|
|
|
60
70
|
/**
|
|
@@ -81,28 +91,31 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
81
91
|
* the data incoming must represent the html representation of the head itself one way or the other
|
|
82
92
|
*/
|
|
83
93
|
replaceHead(shadowDocument: XMLQuery | DQ) {
|
|
84
|
-
|
|
94
|
+
const shadowHead = shadowDocument.querySelectorAll(HTML_TAG_HEAD);
|
|
85
95
|
if (!shadowHead.isPresent()) {
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
|
-
|
|
98
|
+
const head = ExtDomQuery.querySelectorAll(HTML_TAG_HEAD);
|
|
89
99
|
// full replace we delete everything
|
|
90
100
|
head.childNodes.delete();
|
|
91
101
|
this.addToHead(shadowHead);
|
|
102
|
+
//we copy the attributes as well (just in case myfaces introduces the id in head)
|
|
103
|
+
head.copyAttrs(shadowHead);
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
addToHead(shadowHead: XMLQuery | DQ) {
|
|
95
107
|
const mappedHeadData = new ExtDomQuery(shadowHead);
|
|
96
|
-
const postProcessTags = [
|
|
108
|
+
const postProcessTags = [HTML_TAG_STYLE, HTML_TAG_LINK, HTML_TAG_SCRIPT];
|
|
97
109
|
const nonExecutables = mappedHeadData.filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) == -1);
|
|
98
110
|
nonExecutables.runHeadInserts(true);
|
|
99
111
|
|
|
100
112
|
//incoming either the outer head tag or its children
|
|
101
113
|
const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
|
|
102
|
-
// this is stored for post processing
|
|
103
|
-
// after the rest of the "
|
|
114
|
+
// this is stored for "post" processing
|
|
115
|
+
// after the rest of the "physical build up", head before body
|
|
104
116
|
const evalElements = nodesToAdd.stream
|
|
105
117
|
.filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) != -1).collect(new DomQueryCollector());
|
|
118
|
+
|
|
106
119
|
this.addToHeadDeferred(evalElements);
|
|
107
120
|
}
|
|
108
121
|
|
|
@@ -120,20 +133,20 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
120
133
|
*/
|
|
121
134
|
replaceBody(shadowDocument: XMLQuery | DQ) {
|
|
122
135
|
|
|
123
|
-
|
|
136
|
+
const shadowBody = shadowDocument.querySelectorAll(HTML_TAG_BODY);
|
|
124
137
|
if (!shadowBody.isPresent()) {
|
|
125
138
|
return;
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
|
|
141
|
+
const shadowInnerHTML: string = <string>shadowBody.innerHTML;
|
|
129
142
|
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
const resultingBody = <DQ>ExtDomQuery.querySelectorAll(HTML_TAG_BODY);
|
|
144
|
+
const updateForms = resultingBody.querySelectorAll(HTML_TAG_FORM);
|
|
132
145
|
|
|
133
146
|
// main difference, we cannot replace the body itself, but only its content
|
|
134
147
|
// we need a separate step for post-processing the incoming
|
|
135
148
|
// attributes, like classes, styles etc...
|
|
136
|
-
resultingBody.copyAttrs(shadowBody);
|
|
149
|
+
(resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
|
|
137
150
|
this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
|
|
138
151
|
this.storeForPostProcessing(updateForms, resultingBody);
|
|
139
152
|
}
|
|
@@ -161,18 +174,18 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
161
174
|
* <error>
|
|
162
175
|
*/
|
|
163
176
|
|
|
164
|
-
|
|
177
|
+
const mergedErrorData = new ExtConfig({});
|
|
165
178
|
mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
|
|
166
179
|
mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
|
|
167
180
|
mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
|
|
168
181
|
|
|
169
|
-
|
|
182
|
+
const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
|
|
170
183
|
|
|
171
184
|
//we now store the response xml also in the error data for further details
|
|
172
185
|
mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
|
|
173
186
|
|
|
174
187
|
// error post-processing and enrichment (standard messages from keys)
|
|
175
|
-
|
|
188
|
+
const errorData = ErrorData.fromServerError(mergedErrorData);
|
|
176
189
|
|
|
177
190
|
// we now trigger an internally stored onError function which might be an attached to the context
|
|
178
191
|
// either we do not have an internal on error, or an on error has been based via params from the outside.
|
|
@@ -190,7 +203,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
190
203
|
redirect(node: XMLQuery) {
|
|
191
204
|
Assertions.assertUrlExists(node);
|
|
192
205
|
|
|
193
|
-
|
|
206
|
+
const redirectUrl = trim(node.attr(ATTR_URL).value);
|
|
194
207
|
if (redirectUrl != EMPTY_STR) {
|
|
195
208
|
window.location.href = redirectUrl;
|
|
196
209
|
}
|
|
@@ -202,8 +215,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
202
215
|
* @param cdataBlock the cdata block with the new html code
|
|
203
216
|
*/
|
|
204
217
|
update(node: XMLQuery, cdataBlock: string) {
|
|
205
|
-
|
|
206
|
-
|
|
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));
|
|
207
220
|
if (sourceForm) {
|
|
208
221
|
this.storeForPostProcessing(sourceForm, result);
|
|
209
222
|
}
|
|
@@ -223,9 +236,9 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
223
236
|
* @param node
|
|
224
237
|
*/
|
|
225
238
|
attributes(node: XMLQuery) {
|
|
226
|
-
|
|
239
|
+
const elem = DQ.byId(node.id.value, true);
|
|
227
240
|
|
|
228
|
-
node.byTagName(
|
|
241
|
+
node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
|
|
229
242
|
elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
|
|
230
243
|
});
|
|
231
244
|
}
|
|
@@ -246,17 +259,17 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
246
259
|
insert(node: XMLQuery) {
|
|
247
260
|
//let insertId = node.id; //not used atm
|
|
248
261
|
|
|
249
|
-
|
|
250
|
-
|
|
262
|
+
const before = node.attr(XML_TAG_BEFORE);
|
|
263
|
+
const after = node.attr(XML_TAG_AFTER);
|
|
251
264
|
|
|
252
|
-
|
|
265
|
+
const insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
|
|
253
266
|
|
|
254
267
|
if (before.isPresent()) {
|
|
255
268
|
DQ.byId(before.value, true).insertBefore(insertNodes);
|
|
256
269
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
257
270
|
}
|
|
258
271
|
if (after.isPresent()) {
|
|
259
|
-
|
|
272
|
+
const domQuery = DQ.byId(after.value, true);
|
|
260
273
|
domQuery.insertAfter(insertNodes);
|
|
261
274
|
|
|
262
275
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -269,12 +282,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
269
282
|
* @param node the node hosting the insert data
|
|
270
283
|
*/
|
|
271
284
|
insertWithSubTags(node: XMLQuery) {
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
const before = node.querySelectorAll(XML_TAG_BEFORE);
|
|
286
|
+
const after = node.querySelectorAll(XML_TAG_AFTER);
|
|
274
287
|
|
|
275
288
|
before.each(item => {
|
|
276
|
-
|
|
277
|
-
|
|
289
|
+
const insertId = item.attr(ATTR_ID);
|
|
290
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
278
291
|
if (insertId.isPresent()) {
|
|
279
292
|
DQ.byId(insertId.value, true).insertBefore(insertNodes);
|
|
280
293
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -282,8 +295,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
282
295
|
});
|
|
283
296
|
|
|
284
297
|
after.each(item => {
|
|
285
|
-
|
|
286
|
-
|
|
298
|
+
const insertId = item.attr(ATTR_ID);
|
|
299
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
287
300
|
if (insertId.isPresent()) {
|
|
288
301
|
DQ.byId(insertId.value, true).insertAfter(insertNodes);
|
|
289
302
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -298,7 +311,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
298
311
|
*/
|
|
299
312
|
processViewState(node: XMLQuery): boolean {
|
|
300
313
|
if (ResponseProcessor.isViewStateNode(node)) {
|
|
301
|
-
|
|
314
|
+
const state = node.cDATAAsString;
|
|
302
315
|
this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
303
316
|
return true;
|
|
304
317
|
}
|
|
@@ -307,7 +320,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
307
320
|
|
|
308
321
|
processClientWindow(node: XMLQuery): boolean {
|
|
309
322
|
if (ResponseProcessor.isClientWindowNode(node)) {
|
|
310
|
-
|
|
323
|
+
const state = node.cDATAAsString;
|
|
311
324
|
this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
312
325
|
return true;
|
|
313
326
|
}
|
|
@@ -336,15 +349,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
336
349
|
*/
|
|
337
350
|
fixViewStates() {
|
|
338
351
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
|
|
339
|
-
.each((
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
affectedForms = this.getContainerForms(namingContainerId)
|
|
345
|
-
.filter(affectedForm => this.executeOrRenderFilter(affectedForm));
|
|
352
|
+
.each(([, value]) => {
|
|
353
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
354
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
355
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
346
356
|
|
|
347
|
-
this.appendViewStateToForms(affectedForms, value.value);
|
|
357
|
+
this.appendViewStateToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
348
358
|
});
|
|
349
359
|
}
|
|
350
360
|
|
|
@@ -356,15 +366,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
356
366
|
*/
|
|
357
367
|
fixClientWindow() {
|
|
358
368
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
|
|
359
|
-
.each((
|
|
360
|
-
const value: StateHolder = item[1];
|
|
369
|
+
.each(([, value]) => {
|
|
361
370
|
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
affectedForms = this.getContainerForms(namingContainerId)
|
|
365
|
-
.filter(affectedForm => this.executeOrRenderFilter(affectedForm));
|
|
371
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
372
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
366
373
|
|
|
367
|
-
this.appendClientWindowToForms(affectedForms, value.value);
|
|
374
|
+
this.appendClientWindowToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
368
375
|
});
|
|
369
376
|
}
|
|
370
377
|
|
|
@@ -372,10 +379,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
372
379
|
* all processing done we can close the request and send the appropriate events
|
|
373
380
|
*/
|
|
374
381
|
done() {
|
|
375
|
-
|
|
382
|
+
const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
|
|
376
383
|
|
|
377
384
|
//because some frameworks might decorate them over the context in the response
|
|
378
|
-
|
|
385
|
+
const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
|
|
379
386
|
Implementation.sendEvent(eventData, eventHandler);
|
|
380
387
|
}
|
|
381
388
|
|
|
@@ -384,9 +391,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
384
391
|
*
|
|
385
392
|
* @param forms the forms to append the viewState to
|
|
386
393
|
* @param viewState the final viewState
|
|
394
|
+
* @param namingContainerId
|
|
387
395
|
*/
|
|
388
|
-
private appendViewStateToForms(forms: DQ, viewState: string) {
|
|
389
|
-
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);
|
|
390
398
|
}
|
|
391
399
|
|
|
392
400
|
|
|
@@ -395,9 +403,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
395
403
|
*
|
|
396
404
|
* @param forms the forms to append the viewState to
|
|
397
405
|
* @param clientWindow the final viewState
|
|
406
|
+
* @param namingContainerId
|
|
398
407
|
*/
|
|
399
|
-
private appendClientWindowToForms(forms: DQ, clientWindow: string) {
|
|
400
|
-
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);
|
|
401
410
|
}
|
|
402
411
|
|
|
403
412
|
/**
|
|
@@ -407,45 +416,28 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
407
416
|
* @param selector the selector for the state
|
|
408
417
|
* @param state the state itself which needs to be assigned
|
|
409
418
|
*
|
|
419
|
+
* @param namingContainerId
|
|
410
420
|
* @private
|
|
411
421
|
*/
|
|
412
|
-
private assignState(forms: DQ, selector: string, state: string) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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;
|
|
422
438
|
});
|
|
423
439
|
}
|
|
424
440
|
|
|
425
|
-
/**
|
|
426
|
-
* Helper to Create a new JSF ViewState Element
|
|
427
|
-
*
|
|
428
|
-
* @param parent, the parent node to attach the viewState element to
|
|
429
|
-
* (usually a form node)
|
|
430
|
-
*/
|
|
431
|
-
private static newViewStateElement(parent: DQ): DQ {
|
|
432
|
-
let newElement = DQ.fromMarkup($nsp(HTML_VIEWSTATE));
|
|
433
|
-
newElement.appendTo(parent);
|
|
434
|
-
return newElement;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Helper to Create a new JSF ViewState Element
|
|
439
|
-
*
|
|
440
|
-
* @param parent, the parent node to attach the viewState element to
|
|
441
|
-
* (usually a form node)
|
|
442
|
-
*/
|
|
443
|
-
private static newClientWindowElement(parent: DQ): DQ {
|
|
444
|
-
let newElement = DQ.fromMarkup($nsp(HTML_CLIENT_WINDOW));
|
|
445
|
-
newElement.appendTo(parent);
|
|
446
|
-
return newElement;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
441
|
/**
|
|
450
442
|
* Stores certain aspects of the dom for later post-processing
|
|
451
443
|
*
|
|
@@ -482,10 +474,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
482
474
|
* @returns if it is a viewState node
|
|
483
475
|
*/
|
|
484
476
|
private static isViewStateNode(node: XMLQuery): boolean {
|
|
485
|
-
|
|
477
|
+
const SEP = $faces().separatorchar;
|
|
486
478
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_VIEWSTATE) ||
|
|
487
|
-
node?.id?.value?.indexOf([
|
|
488
|
-
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);
|
|
489
481
|
}
|
|
490
482
|
|
|
491
483
|
/**
|
|
@@ -495,10 +487,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
495
487
|
* @returns true of it ii
|
|
496
488
|
*/
|
|
497
489
|
private static isClientWindowNode(node: XMLQuery): boolean {
|
|
498
|
-
|
|
490
|
+
const SEP = $faces().separatorchar;
|
|
499
491
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_CLIENT_WINDOW) ||
|
|
500
|
-
node?.id?.value?.indexOf([
|
|
501
|
-
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);
|
|
502
494
|
}
|
|
503
495
|
|
|
504
496
|
private triggerOnError(errorData: ErrorData) {
|
|
@@ -510,25 +502,22 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
510
502
|
* @param affectedForm
|
|
511
503
|
* @private
|
|
512
504
|
*/
|
|
513
|
-
private
|
|
514
|
-
|
|
515
|
-
|
|
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)
|
|
516
508
|
.orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
|
|
517
|
-
.orElse(
|
|
518
|
-
|
|
509
|
+
.orElse(IDENT_NONE).value.split(/\s+/gi);
|
|
510
|
+
const executeAndRenders = executes.concat(...renders);
|
|
519
511
|
return LazyStream.of(...executeAndRenders).filter(nameOrId => {
|
|
520
|
-
if (nameOrId
|
|
521
|
-
return true;
|
|
522
|
-
}
|
|
523
|
-
if (nameOrId == "@none") {
|
|
512
|
+
if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
|
|
524
513
|
return true;
|
|
525
514
|
}
|
|
526
515
|
|
|
527
|
-
const
|
|
516
|
+
const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
|
|
528
517
|
//either the form directly is in execute or render or one of its children or one of its parents
|
|
529
|
-
return affectedForm.matchesSelector(
|
|
530
|
-
affectedForm.querySelectorAll(
|
|
531
|
-
affectedForm.firstParent(
|
|
518
|
+
return affectedForm.matchesSelector(NAME_OR_ID) ||
|
|
519
|
+
affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
|
|
520
|
+
affectedForm.firstParent(NAME_OR_ID).isPresent();
|
|
532
521
|
}).first().isPresent();
|
|
533
522
|
}
|
|
534
523
|
|
|
@@ -540,14 +529,17 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
540
529
|
private getContainerForms(namingContainerId: Config) {
|
|
541
530
|
if (namingContainerId.isPresent()) {
|
|
542
531
|
//naming container mode, all forms under naming container id must be processed
|
|
543
|
-
return DQ.
|
|
544
|
-
.orElse(DQ$(`form[id='${namingContainerId.value}'], form[name='${namingContainerId.value}']`))
|
|
532
|
+
return DQ$(this.getNameOrIdSelector(namingContainerId.value))
|
|
545
533
|
// missing condition if the naming container is not present we have to
|
|
546
534
|
// use the body as fallback
|
|
547
|
-
.
|
|
548
|
-
.byTagName(
|
|
535
|
+
.orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
|
|
536
|
+
.byTagName(HTML_TAG_FORM, true);
|
|
549
537
|
} else {
|
|
550
|
-
return DQ.byTagName(
|
|
538
|
+
return DQ.byTagName(HTML_TAG_FORM);
|
|
551
539
|
}
|
|
552
540
|
}
|
|
541
|
+
|
|
542
|
+
private getNameOrIdSelector(nameOrId) {
|
|
543
|
+
return `[id='${nameOrId}'], [name='${nameOrId}']`;
|
|
544
|
+
}
|
|
553
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,11 +23,12 @@ 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,
|
|
@@ -111,12 +112,12 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
111
112
|
let xhrObject = this.xhrObject;
|
|
112
113
|
|
|
113
114
|
let executesArr = () => {
|
|
114
|
-
return this.requestContext.getIf(
|
|
115
|
+
return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get("none").value.split(/\s+/gi);
|
|
115
116
|
};
|
|
116
117
|
try {
|
|
117
118
|
|
|
118
119
|
let formElement = this.sourceForm.getAsElem(0).value;
|
|
119
|
-
let viewState = (
|
|
120
|
+
let viewState = $faces().getViewState(formElement);
|
|
120
121
|
// encoded we need to decode
|
|
121
122
|
// We generated a base representation of the current form
|
|
122
123
|
// in case someone has overloaded the viewState with additional decorators we merge
|
|
@@ -132,14 +133,14 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
132
133
|
|
|
133
134
|
// next step the pass through parameters are merged in for post params
|
|
134
135
|
let requestContext = this.requestContext;
|
|
135
|
-
let
|
|
136
|
+
let requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR);
|
|
136
137
|
|
|
137
138
|
// this is an extension where we allow pass through parameters to be sent down additionally
|
|
138
139
|
// this can be used and is used in the impl to enrich the post request parameters with additional
|
|
139
140
|
// information
|
|
140
|
-
formData.shallowMerge(
|
|
141
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
141
142
|
|
|
142
|
-
this.responseContext =
|
|
143
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
143
144
|
|
|
144
145
|
// we have to shift the internal passthroughs around to build up our response context
|
|
145
146
|
let responseContext = this.responseContext;
|
|
@@ -290,7 +291,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
290
291
|
return;
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
(
|
|
294
|
+
$faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
private handleMalFormedXML(resolve: Function) {
|
|
@@ -90,6 +90,22 @@ export module StandardInits {
|
|
|
90
90
|
</html>`;
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
const HTML_FORM_NAMESPACED = `<!DOCTYPE html>
|
|
94
|
+
<html lang="en">
|
|
95
|
+
<head>
|
|
96
|
+
<meta charset="UTF-8">
|
|
97
|
+
<title>Title</title>
|
|
98
|
+
</head>
|
|
99
|
+
<body>
|
|
100
|
+
<form id="jd_0:blarg">
|
|
101
|
+
<input type="text" id="jd_0:input_1" name="jd_0:input_1" value="input_1_val"></input>
|
|
102
|
+
<input type="hidden" id="jd_0:jakarta.faces.ViewState" name="jakarta.faces.ViewState" value="blubbblubblubb"></input>
|
|
103
|
+
<input type="button" id="jd_0:input_2" name="input_2" value="input_1_val"></input>
|
|
104
|
+
</form>
|
|
105
|
+
</body>
|
|
106
|
+
</html>`;
|
|
107
|
+
|
|
108
|
+
|
|
93
109
|
|
|
94
110
|
/**
|
|
95
111
|
* a page simulating basically a simple faces form
|
|
@@ -277,6 +293,9 @@ export module StandardInits {
|
|
|
277
293
|
export function defaultMyFaces(withJsf = true): Promise<() => void> {
|
|
278
294
|
return init(HTML_FORM_DEFAULT, withJsf);
|
|
279
295
|
}
|
|
296
|
+
export function defaultMyFacesNamespaces(withJsf = true): Promise<() => void> {
|
|
297
|
+
return init(HTML_FORM_NAMESPACED, withJsf);
|
|
298
|
+
}
|
|
280
299
|
export function defaultMyFaces23(withJsf = true): Promise<() => void> {
|
|
281
300
|
return init(HTML_FORM_DEFAULT.replace(/jakarta/gi, "javax"), withJsf, false);
|
|
282
301
|
}
|
|
@@ -20,7 +20,7 @@ import {expect} from 'chai';
|
|
|
20
20
|
import * as sinon from 'sinon';
|
|
21
21
|
|
|
22
22
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
23
|
-
import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
|
|
23
|
+
import {CTX_PARAM_REQ_PASS_THR, P_EXECUTE, P_RENDER} from "../../impl/core/Const";
|
|
24
24
|
import defaultMyFaces = StandardInits.defaultMyFaces;
|
|
25
25
|
|
|
26
26
|
|
|
@@ -60,9 +60,9 @@ describe('faces.ajax.request test suite', () => {
|
|
|
60
60
|
expect(addRequestToQueue.callCount).to.eq(1);
|
|
61
61
|
const context = (<Config>addRequestToQueue.args[0][2]);
|
|
62
62
|
|
|
63
|
-
expect(context.getIf(
|
|
63
|
+
expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_RENDER).value).eq("@all");
|
|
64
64
|
//Execute issuing form due to @form and always the issuing element
|
|
65
|
-
expect(context.getIf(
|
|
65
|
+
expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value).eq("blarg input_2");
|
|
66
66
|
} finally {
|
|
67
67
|
//once done we restore the proper state
|
|
68
68
|
addRequestToQueue.restore();
|
|
@@ -20,7 +20,7 @@ import {expect} from 'chai';
|
|
|
20
20
|
import * as sinon from 'sinon';
|
|
21
21
|
|
|
22
22
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
23
|
-
import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
|
|
23
|
+
import {CTX_PARAM_REQ_PASS_THR, P_EXECUTE, P_RENDER} from "../../impl/core/Const";
|
|
24
24
|
import defaultMyFaces23 = StandardInits.defaultMyFaces23;
|
|
25
25
|
|
|
26
26
|
|
|
@@ -60,9 +60,9 @@ describe('javax.ajax.request test suite', () => {
|
|
|
60
60
|
expect(addRequestToQueue.callCount).to.eq(1);
|
|
61
61
|
const context = (<Config>addRequestToQueue.args[0][2]);
|
|
62
62
|
|
|
63
|
-
expect(context.getIf(
|
|
63
|
+
expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_RENDER).value).eq("@all");
|
|
64
64
|
//Execute issuing form due to @form and always the issuing element
|
|
65
|
-
expect(context.getIf(
|
|
65
|
+
expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value).eq("blarg input_2");
|
|
66
66
|
} finally {
|
|
67
67
|
//once done we restore the proper state
|
|
68
68
|
addRequestToQueue.restore();
|