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
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
import {Config, Lang, XMLQuery} from "mona-dish";
|
|
17
17
|
|
|
18
18
|
import {DQ} from "mona-dish";
|
|
19
|
-
import {ExtLang} from "./Lang";
|
|
20
|
-
import getMessage = ExtLang.getMessage;
|
|
21
|
-
import makeException = ExtLang.makeException;
|
|
22
19
|
import {
|
|
23
20
|
ATTR_URL,
|
|
24
21
|
EMPTY_RESPONSE,
|
|
@@ -26,8 +23,10 @@ import {
|
|
|
26
23
|
ON_ERROR,
|
|
27
24
|
ON_EVENT,
|
|
28
25
|
PHASE_PROCESS_RESPONSE,
|
|
29
|
-
|
|
26
|
+
XML_TAG_PARTIAL_RESP
|
|
30
27
|
} from "../core/Const";
|
|
28
|
+
import {ExtLang} from "./Lang";
|
|
29
|
+
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* a set of internal code assertions
|
|
@@ -36,6 +35,8 @@ import {
|
|
|
36
35
|
*/
|
|
37
36
|
export module Assertions {
|
|
38
37
|
|
|
38
|
+
|
|
39
|
+
|
|
39
40
|
export function assertRequestIntegrity(options: Config, elem: DQ): void | never {
|
|
40
41
|
/*assert if the onerror is set and once if it is set it must be of type function*/
|
|
41
42
|
assertFunction(options.getIf(ON_ERROR).value);
|
|
@@ -43,12 +44,12 @@ export module Assertions {
|
|
|
43
44
|
assertFunction(options.getIf(ON_EVENT).value);
|
|
44
45
|
//improve the error messages if an empty elem is passed
|
|
45
46
|
//Assertions.assertElementExists(elem);
|
|
46
|
-
assert(elem.isPresent(), getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet", )
|
|
47
|
+
assert(elem.isPresent(), ExtLang.getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided or exist", "source element id"), "faces.ajax.request", "ArgNotSet", )
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export function assertUrlExists(node: XMLQuery): void | never {
|
|
50
51
|
if (node.attr(ATTR_URL).isAbsent()) {
|
|
51
|
-
throw Assertions.raiseError(new Error(), getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
|
|
52
|
+
throw Assertions.raiseError(new Error(), ExtLang.getMessage("ERR_RED_URL", null, "processRedirect"), "processRedirect");
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -59,7 +60,7 @@ export module Assertions {
|
|
|
59
60
|
export function assertValidXMLResponse(responseXML: XMLQuery) : void | never {
|
|
60
61
|
assert(!responseXML.isAbsent(), EMPTY_RESPONSE, PHASE_PROCESS_RESPONSE);
|
|
61
62
|
assert(!responseXML.isXMLParserError(), responseXML.parserErrorText(EMPTY_STR), PHASE_PROCESS_RESPONSE);
|
|
62
|
-
assert(responseXML.querySelectorAll(
|
|
63
|
+
assert(responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -79,7 +80,7 @@ export module Assertions {
|
|
|
79
80
|
let finalMessage = message ?? EMPTY_STR;
|
|
80
81
|
|
|
81
82
|
//TODO clean up the messy makeException, this is a perfect case for encapsulation and sane defaults
|
|
82
|
-
return makeException(error, finalTitle, finalName, "Response", caller || (((<any>arguments).caller) ? (<any>arguments).caller.toString() : "_raiseError"), finalMessage);
|
|
83
|
+
return ExtLang.makeException(error, finalTitle, finalName, "Response", caller || (((<any>arguments).caller) ? (<any>arguments).caller.toString() : "_raiseError"), finalMessage);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/*
|
|
@@ -103,6 +104,13 @@ export module Assertions {
|
|
|
103
104
|
export function assertFunction(value: any, msg = EMPTY_STR, caller=EMPTY_STR, title="Assertion Error"): asserts value is Function {
|
|
104
105
|
assertType(value, "function", msg, caller, title);
|
|
105
106
|
}
|
|
107
|
+
|
|
108
|
+
export function assertDelay(value: any) {
|
|
109
|
+
if(!(value >= 0)) { // >= 0 abbreviation which covers all cases of non positive values,
|
|
110
|
+
// including NaN and non numeric strings, no type equality is deliberate here,
|
|
111
|
+
throw new Error("Invalid delay value: " + value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
|
|
@@ -201,8 +201,8 @@ export class ExtDomQuery extends DQ {
|
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
203
|
let reference = element.attr("href")
|
|
204
|
-
.
|
|
205
|
-
.
|
|
204
|
+
.orElseLazy(() => element.attr("src").value)
|
|
205
|
+
.orElseLazy(() => element.attr("rel").value);
|
|
206
206
|
|
|
207
207
|
if (!reference.isPresent()) {
|
|
208
208
|
return true;
|
|
@@ -235,7 +235,7 @@ export class ExtDomQuery extends DQ {
|
|
|
235
235
|
* @param deep whether the search should go into embedded shadow dom elements
|
|
236
236
|
* @return a DomQuery containing the found elements
|
|
237
237
|
*/
|
|
238
|
-
static byId(selector: string | DomQuery | Element, deep = false):
|
|
238
|
+
static byId(selector: string | DomQuery | Element, deep = false): ExtDomQuery {
|
|
239
239
|
const ret = DomQuery.byId(selector, deep);
|
|
240
240
|
return new ExtDomQuery(ret);
|
|
241
241
|
}
|
|
@@ -244,6 +244,9 @@ export class ExtDomQuery extends DQ {
|
|
|
244
244
|
return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
filter(func: (item: DomQuery) => boolean): ExtDomQuery {
|
|
248
|
+
return new ExtDomQuery(super.filter(func));
|
|
249
|
+
}
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
export const ExtDQ = ExtDomQuery;
|
|
@@ -254,6 +257,8 @@ export const ExtDQ = ExtDomQuery;
|
|
|
254
257
|
*/
|
|
255
258
|
export class ExtConfig extends Config {
|
|
256
259
|
|
|
260
|
+
$nspEnabled = true;
|
|
261
|
+
|
|
257
262
|
constructor(root: any) {
|
|
258
263
|
super(root);
|
|
259
264
|
}
|
|
@@ -323,7 +328,10 @@ export class ExtConfig extends Config {
|
|
|
323
328
|
* @param accessPath the access paths to be remapped
|
|
324
329
|
* @private returns an array of access paths with version remapped namespaces
|
|
325
330
|
*/
|
|
326
|
-
private remap(accessPath:
|
|
331
|
+
private remap(accessPath: string[]): string[] {
|
|
332
|
+
if(!this.$nspEnabled) {
|
|
333
|
+
return accessPath;
|
|
334
|
+
}
|
|
327
335
|
return Stream.of(...accessPath).map(key => $nsp(key)).collect(new ArrayCollector());
|
|
328
336
|
}
|
|
329
337
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*! Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
* this work for additional information regarding copyright ownership.
|
|
4
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
5
|
+
* (the "License"); you may not use this file except in compliance with
|
|
6
|
+
* the License. You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {DomQuery, DQ, DQ$} from "mona-dish";
|
|
19
|
+
import {$faces, $nsp, HTML_CLIENT_WINDOW, HTML_VIEWSTATE, P_CLIENT_WINDOW, P_VIEWSTATE} from "../core/Const";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builder for hidden inputs.
|
|
23
|
+
* ATM only ViewState and Client window
|
|
24
|
+
* are supported (per spec)
|
|
25
|
+
*
|
|
26
|
+
* Improves readability in the response processor!
|
|
27
|
+
*/
|
|
28
|
+
export class HiddenInputBuilder {
|
|
29
|
+
private namingContainerId?: string;
|
|
30
|
+
private parent?: DomQuery;
|
|
31
|
+
private readonly name: string;
|
|
32
|
+
private readonly template: string;
|
|
33
|
+
|
|
34
|
+
constructor(private selector: string) {
|
|
35
|
+
const isViewState = selector.indexOf($nsp(P_VIEWSTATE)) != -1;
|
|
36
|
+
this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW
|
|
37
|
+
this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
withNamingContainerId(namingContainer: string): HiddenInputBuilder {
|
|
41
|
+
this.namingContainerId = namingContainer;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
withParent(parent: DomQuery): HiddenInputBuilder {
|
|
46
|
+
this.parent = parent;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
build(): DomQuery {
|
|
52
|
+
const SEP = $faces().separatorchar;
|
|
53
|
+
|
|
54
|
+
let existingStates = DQ$(`[name*='${$nsp(this.name)}']`);
|
|
55
|
+
let cnt = existingStates.stream.map(state => {
|
|
56
|
+
let ident: string = state.id.orElse("-1").value;
|
|
57
|
+
ident = ident.substring(ident.lastIndexOf(SEP)+1);
|
|
58
|
+
return parseInt(ident);
|
|
59
|
+
})
|
|
60
|
+
.filter(item => !isNaN(item))
|
|
61
|
+
.reduce((item1, item2) => Math.max(item1, item2), -1).value;
|
|
62
|
+
//the maximum new ident is the current max + 1
|
|
63
|
+
cnt++;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const newElement = DQ.fromMarkup($nsp(this.template));
|
|
67
|
+
newElement.id.value = ((this.namingContainerId?.length) ?
|
|
68
|
+
[this.namingContainerId, $nsp(this.name), cnt]:
|
|
69
|
+
[$nsp(this.name), cnt]).join(SEP);
|
|
70
|
+
|
|
71
|
+
//name must be prefixed with the naming container id as well according to the jsdocs
|
|
72
|
+
newElement.name.value = (this.namingContainerId?.length) ?
|
|
73
|
+
[this.namingContainerId, $nsp(this.name)].join(SEP): $nsp(this.name);
|
|
74
|
+
|
|
75
|
+
this?.parent?.append(newElement);
|
|
76
|
+
return newElement;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -13,13 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
|
-
* todo replace singleton with module definition
|
|
17
|
-
*
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
import {Lang as LangBase, Config, Optional, DomQuery, DQ, Stream} from "mona-dish";
|
|
21
19
|
import {Messages} from "../i18n/Messages";
|
|
22
|
-
import {EMPTY_STR,
|
|
20
|
+
import {EMPTY_STR, HTML_TAG_FORM} from "../core/Const";
|
|
23
21
|
import {getEventTarget} from "../xhrCore/RequestDataResolver";
|
|
24
22
|
|
|
25
23
|
|
|
@@ -160,25 +158,25 @@ export module ExtLang {
|
|
|
160
158
|
export function getForm(elem: Element, event ?: Event): DQ | never {
|
|
161
159
|
|
|
162
160
|
let queryElem = new DQ(elem);
|
|
163
|
-
let eventTarget = new DQ(getEventTarget(event));
|
|
161
|
+
let eventTarget = (event) ? new DQ(getEventTarget(event)) : DomQuery.absent;
|
|
164
162
|
|
|
165
|
-
if (queryElem.isTag(
|
|
163
|
+
if (queryElem.isTag(HTML_TAG_FORM)) {
|
|
166
164
|
return queryElem;
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
//html 5 for handling
|
|
170
|
-
if (queryElem.attr(
|
|
171
|
-
let formId = queryElem.attr(
|
|
168
|
+
if (queryElem.attr(HTML_TAG_FORM).isPresent()) {
|
|
169
|
+
let formId = queryElem.attr(HTML_TAG_FORM).value;
|
|
172
170
|
let foundForm = DQ.byId(formId, true);
|
|
173
171
|
if (foundForm.isPresent()) {
|
|
174
172
|
return foundForm;
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
let form = queryElem.
|
|
179
|
-
.orElseLazy(() => queryElem.byTagName(
|
|
180
|
-
.orElseLazy(() => eventTarget.
|
|
181
|
-
.orElseLazy(() => eventTarget.byTagName(
|
|
176
|
+
let form = queryElem.firstParent(HTML_TAG_FORM)
|
|
177
|
+
.orElseLazy(() => queryElem.byTagName(HTML_TAG_FORM, true))
|
|
178
|
+
.orElseLazy(() => eventTarget.firstParent(HTML_TAG_FORM))
|
|
179
|
+
.orElseLazy(() => eventTarget.byTagName(HTML_TAG_FORM))
|
|
182
180
|
.first();
|
|
183
181
|
|
|
184
182
|
assertFormExists(form);
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import {
|
|
17
|
-
EMPTY_STR,
|
|
17
|
+
EMPTY_STR, ERROR,
|
|
18
18
|
ERROR_MESSAGE,
|
|
19
19
|
ERROR_NAME,
|
|
20
20
|
RESPONSE_TEXT,
|
|
21
|
-
RESPONSE_XML,
|
|
21
|
+
RESPONSE_XML, SERVER_ERROR,
|
|
22
22
|
SOURCE,
|
|
23
23
|
STATUS,
|
|
24
24
|
UNKNOWN
|
|
@@ -49,7 +49,8 @@ export enum ErrorType {
|
|
|
49
49
|
export class ErrorData extends EventData implements IErrorData {
|
|
50
50
|
|
|
51
51
|
type: string = "error";
|
|
52
|
-
source:
|
|
52
|
+
source: HTMLElement;
|
|
53
|
+
sourceId: string;
|
|
53
54
|
errorName: string;
|
|
54
55
|
errorMessage: string;
|
|
55
56
|
|
|
@@ -63,12 +64,14 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
63
64
|
serverErrorMessage: string;
|
|
64
65
|
message: string;
|
|
65
66
|
|
|
66
|
-
constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "
|
|
67
|
+
constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "", type = ErrorType.CLIENT_ERROR) {
|
|
67
68
|
super();
|
|
68
|
-
this.source = source;
|
|
69
|
-
this.
|
|
69
|
+
this.source = document.getElementById(source);
|
|
70
|
+
this.sourceId = source;
|
|
71
|
+
this.type = ERROR;
|
|
70
72
|
this.errorName = errorName;
|
|
71
|
-
|
|
73
|
+
//tck requires that the type is prefixed to the message itself (jsdoc also) in case of a server error
|
|
74
|
+
this.message = this.errorMessage = (type == SERVER_ERROR) ? type + ": " + errorMessage : errorMessage;
|
|
72
75
|
this.responseCode = responseCode;
|
|
73
76
|
this.responseText = responseText;
|
|
74
77
|
this.status = status;
|
|
@@ -81,10 +84,10 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
static fromClient(e: Error): ErrorData {
|
|
84
|
-
return new ErrorData("client", e?.name ??
|
|
87
|
+
return new ErrorData((e as any)?.source ?? "client", e?.name ?? EMPTY_STR, e?.message ?? EMPTY_STR, e?.stack ?? EMPTY_STR);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string =
|
|
90
|
+
static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string = EMPTY_STR): ErrorData {
|
|
88
91
|
return new ErrorData(source, name, message, responseText, responseCode, `${responseCode}`, status, ErrorType.HTTP_ERROR);
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -98,11 +101,13 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
98
101
|
let status = getMsg(context, STATUS);
|
|
99
102
|
let responseText = getMsg(context, RESPONSE_TEXT);
|
|
100
103
|
let responseXML = getMsg(context, RESPONSE_XML);
|
|
104
|
+
|
|
105
|
+
|
|
101
106
|
return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode + EMPTY_STR, status, errorType);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
private static getMsg(context, param) {
|
|
105
|
-
return getMessage(context.getIf(param).orElse(
|
|
110
|
+
return getMessage(context.getIf(param).orElse(EMPTY_STR).value);
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
static fromServerError(context: Config): ErrorData {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import {Config, DQ} from "mona-dish";
|
|
17
|
-
import {BEGIN,
|
|
17
|
+
import {BEGIN, CTX_PARAM_REQ_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
|
|
18
18
|
|
|
19
19
|
export class EventData implements IEventData{
|
|
20
20
|
type: string;
|
|
@@ -33,7 +33,7 @@ export class EventData implements IEventData{
|
|
|
33
33
|
|
|
34
34
|
let sourceId: string = context.getIf(SOURCE)
|
|
35
35
|
.orElseLazy(() => context.getIf(P_PARTIAL_SOURCE).value)
|
|
36
|
-
.orElseLazy(() => context.getIf(
|
|
36
|
+
.orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value)
|
|
37
37
|
.value;
|
|
38
38
|
if (sourceId) {
|
|
39
39
|
eventData.source = DQ.byId(sourceId, true).first().value.value;
|
|
@@ -32,7 +32,6 @@ export interface IResponseProcessor {
|
|
|
32
32
|
*/
|
|
33
33
|
replaceHead(shadowHead: XMLQuery | DQ): void;
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
/**
|
|
37
36
|
* adds new elements to the head
|
|
38
37
|
*
|
|
@@ -40,6 +39,14 @@ export interface IResponseProcessor {
|
|
|
40
39
|
*/
|
|
41
40
|
addToHead(newElements: XMLQuery | DQ): void;
|
|
42
41
|
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* adds new elements to the head in a deferred manner
|
|
45
|
+
*
|
|
46
|
+
* @param newElements the elements which need addition
|
|
47
|
+
*/
|
|
48
|
+
addToHeadDeferred(newElements: XMLQuery | DQ): void;
|
|
49
|
+
|
|
43
50
|
/**
|
|
44
51
|
* replace the body
|
|
45
52
|
*
|
|
@@ -16,18 +16,23 @@
|
|
|
16
16
|
|
|
17
17
|
import {Config, DomQuery, DQ} from "mona-dish";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
$faces,
|
|
20
|
+
$nsp,
|
|
21
|
+
CTX_OPTIONS_DELAY,
|
|
22
|
+
CTX_OPTIONS_TIMEOUT,
|
|
23
|
+
DELAY_NONE,
|
|
21
24
|
EMPTY_FUNC,
|
|
22
25
|
EMPTY_STR,
|
|
23
26
|
ENCODED_URL,
|
|
24
|
-
|
|
27
|
+
P_VIEWSTATE,
|
|
25
28
|
REQ_TYPE_GET,
|
|
26
29
|
REQ_TYPE_POST
|
|
27
30
|
} from "../core/Const";
|
|
28
31
|
import {XhrFormData} from "./XhrFormData";
|
|
29
32
|
import {ExtLang} from "../util/Lang";
|
|
30
33
|
import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
34
|
+
import {Assertions} from "../util/Assertions";
|
|
35
|
+
|
|
31
36
|
|
|
32
37
|
/**
|
|
33
38
|
* Resolver functions for various aspects of the request data
|
|
@@ -67,20 +72,26 @@ export function resolveFinalUrl(sourceForm: DomQuery, formData: XhrFormData, aja
|
|
|
67
72
|
* it is either the id or the parent form of the element or an embedded form
|
|
68
73
|
* of the element
|
|
69
74
|
*
|
|
70
|
-
* @param requestCtx
|
|
71
75
|
* @param elem
|
|
72
76
|
* @param event
|
|
73
77
|
*/
|
|
74
|
-
export function resolveForm(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
export function resolveForm(elem: DQ, event: Event): DQ {
|
|
79
|
+
return ExtLang.getForm(elem.getAsElem(0).value, event);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function resolveViewId(form: DQ): string {
|
|
83
|
+
const viewState = form.querySelectorAll(`input[type='hidden'][name*='${$nsp(P_VIEWSTATE)}']`).id.orElse("").value;
|
|
84
|
+
const divider = $faces().separatorchar;
|
|
85
|
+
const viewId = viewState.split(divider, 2)[0];
|
|
86
|
+
const viewStateViewId = viewId.indexOf($nsp(P_VIEWSTATE)) === -1 ? viewId : "";
|
|
87
|
+
// myfaces specific, we in non portlet environments prepend the viewId
|
|
88
|
+
// even without being in a naming container, the other components ignore that
|
|
89
|
+
return form.id.value.indexOf(viewStateViewId) === 0 ? viewStateViewId : "";
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
export function resolveTimeout(options: Config): number {
|
|
82
93
|
let getCfg = ExtLang.getLocalOrGlobalConfig;
|
|
83
|
-
return options.getIf(
|
|
94
|
+
return options.getIf(CTX_OPTIONS_TIMEOUT).value ?? getCfg(options.value, CTX_OPTIONS_TIMEOUT, 0);
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
/**
|
|
@@ -89,9 +100,15 @@ export function resolveTimeout(options: Config): number {
|
|
|
89
100
|
* @param options ... the options object, in most cases it will host the delay value
|
|
90
101
|
*/
|
|
91
102
|
export function resolveDelay(options: Config): number {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
// null, 'none', or undefined will automatically be mapped to 0 aka no delay
|
|
104
|
+
// the config delay will be dropped not needed anymore, it does not really
|
|
105
|
+
// make sense anymore now that it is part of a local spec
|
|
106
|
+
let ret = options.getIf(CTX_OPTIONS_DELAY).orElse(0).value;
|
|
107
|
+
// if delay === none, no delay must be used, aka delay 0
|
|
108
|
+
ret = (DELAY_NONE === ret) ? 0 : ret;
|
|
109
|
+
// negative, or invalid values will automatically get a js exception
|
|
110
|
+
Assertions.assertDelay(ret);
|
|
111
|
+
return ret;
|
|
95
112
|
}
|
|
96
113
|
|
|
97
114
|
/**
|
|
@@ -138,14 +155,15 @@ export function getEventTarget(evt: Event): Element {
|
|
|
138
155
|
* @param opts
|
|
139
156
|
* @param el
|
|
140
157
|
*/
|
|
141
|
-
export function resolveDefaults(event: Event, opts:
|
|
158
|
+
export function resolveDefaults(event: Event, opts: Options | [[string, any]] , el: Element | string = null): any {
|
|
142
159
|
//deep copy the options, so that further transformations to not backfire into the callers
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
const elem = DQ.byId(el || <Element>event.target, true);
|
|
161
|
+
const options = new ExtConfig(opts).deepCopy as ExtConfig;
|
|
162
|
+
return {
|
|
163
|
+
options: options,
|
|
164
|
+
elem: elem,
|
|
165
|
+
elementId: elem.id.value,
|
|
166
|
+
windowId: resolveWindowId(options),
|
|
167
|
+
isResetValues: true === options.value?.resetValues
|
|
168
|
+
};
|
|
151
169
|
}
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
CTX_PARAM_SRC_FRM_ID,
|
|
26
26
|
SEL_RESPONSE_XML,
|
|
27
27
|
SOURCE,
|
|
28
|
-
|
|
28
|
+
HTML_TAG_FORM,
|
|
29
29
|
UPDATE_ELEMS,
|
|
30
30
|
UPDATE_FORMS,
|
|
31
31
|
DEFERRED_HEAD_INSERTS
|
|
@@ -106,9 +106,9 @@ export function resolveSourceForm(internalContext: Config, elem: DQ): DQ {
|
|
|
106
106
|
let sourceFormId = internalContext.getIf(CTX_PARAM_SRC_FRM_ID);
|
|
107
107
|
let sourceForm = new DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);
|
|
108
108
|
|
|
109
|
-
sourceForm = sourceForm.orElseLazy(() => elem.
|
|
110
|
-
.orElseLazy(() => elem.querySelectorAll(
|
|
111
|
-
.orElseLazy(() => DQ.querySelectorAll(
|
|
109
|
+
sourceForm = sourceForm.orElseLazy(() => elem.firstParent(HTML_TAG_FORM))
|
|
110
|
+
.orElseLazy(() => elem.querySelectorAll(HTML_TAG_FORM))
|
|
111
|
+
.orElseLazy(() => DQ.querySelectorAll(HTML_TAG_FORM));
|
|
112
112
|
|
|
113
113
|
return sourceForm;
|
|
114
114
|
}
|
|
@@ -20,23 +20,23 @@ import {ResponseProcessor} from "./ResponseProcessor";
|
|
|
20
20
|
import {IResponseProcessor} from "./IResponseProcessor";
|
|
21
21
|
import {
|
|
22
22
|
$nsp,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
XML_TAG_ATTRIBUTES,
|
|
24
|
+
XML_TAG_CHANGES,
|
|
25
|
+
XML_TAG_DELETE,
|
|
26
|
+
XML_TAG_ERROR,
|
|
27
|
+
XML_TAG_EVAL,
|
|
28
|
+
XML_TAG_EXTENSION,
|
|
29
|
+
XML_TAG_INSERT,
|
|
30
|
+
XML_TAG_REDIRECT,
|
|
31
|
+
XML_TAG_UPDATE, P_RESOURCE,
|
|
32
32
|
P_VIEWBODY,
|
|
33
33
|
P_VIEWHEAD,
|
|
34
34
|
P_VIEWROOT,
|
|
35
35
|
PARTIAL_ID,
|
|
36
|
-
|
|
36
|
+
XML_TAG_PARTIAL_RESP,
|
|
37
37
|
RESPONSE_XML,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
XML_TAG_AFTER,
|
|
39
|
+
XML_TAG_BEFORE
|
|
40
40
|
} from "../core/Const";
|
|
41
41
|
import {resolveContexts, resolveResponseXML} from "./ResonseDataResolver";
|
|
42
42
|
import {ExtConfig} from "../util/ExtDomQuery";
|
|
@@ -67,7 +67,7 @@ export module Response {
|
|
|
67
67
|
internalContext.assign(RESPONSE_XML).value = responseXML;
|
|
68
68
|
|
|
69
69
|
// we now process the partial tags, or in none given raise an error
|
|
70
|
-
responseXML.querySelectorAll(
|
|
70
|
+
responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP)
|
|
71
71
|
.each(item => processPartialTag(<XMLQuery>item, responseProcessor, internalContext));
|
|
72
72
|
|
|
73
73
|
// We now process the viewStates, client windows and the elements to be evaluated are delayed.
|
|
@@ -89,18 +89,18 @@ export module Response {
|
|
|
89
89
|
function processPartialTag(node: XMLQuery, responseProcessor: IResponseProcessor, internalContext) {
|
|
90
90
|
|
|
91
91
|
internalContext.assign(PARTIAL_ID).value = node.id;
|
|
92
|
-
const SEL_SUB_TAGS = [
|
|
92
|
+
const SEL_SUB_TAGS = [XML_TAG_ERROR, XML_TAG_REDIRECT, XML_TAG_CHANGES].join(",");
|
|
93
93
|
|
|
94
94
|
// now we can process the main operations
|
|
95
95
|
node.querySelectorAll(SEL_SUB_TAGS).each((node: XMLQuery) => {
|
|
96
96
|
switch (node.tagName.value) {
|
|
97
|
-
case
|
|
97
|
+
case XML_TAG_ERROR:
|
|
98
98
|
responseProcessor.error(node);
|
|
99
99
|
break;
|
|
100
|
-
case
|
|
100
|
+
case XML_TAG_REDIRECT:
|
|
101
101
|
responseProcessor.redirect(node);
|
|
102
102
|
break;
|
|
103
|
-
case
|
|
103
|
+
case XML_TAG_CHANGES:
|
|
104
104
|
processChangesTag(node, responseProcessor);
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
@@ -110,7 +110,7 @@ export module Response {
|
|
|
110
110
|
|
|
111
111
|
let processInsert = function (responseProcessor: IResponseProcessor, node: XMLQuery) {
|
|
112
112
|
// path1 insert after as child tags
|
|
113
|
-
if(node.querySelectorAll([
|
|
113
|
+
if(node.querySelectorAll([XML_TAG_BEFORE, XML_TAG_AFTER].join(",")).length) {
|
|
114
114
|
responseProcessor.insertWithSubTags(node);
|
|
115
115
|
} else { // insert before after with id
|
|
116
116
|
responseProcessor.insert(node);
|
|
@@ -125,31 +125,31 @@ export module Response {
|
|
|
125
125
|
* @param responseProcessor
|
|
126
126
|
*/
|
|
127
127
|
function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {
|
|
128
|
-
const ALLOWED_TAGS = [
|
|
128
|
+
const ALLOWED_TAGS = [XML_TAG_UPDATE, XML_TAG_EVAL, XML_TAG_INSERT, XML_TAG_DELETE, XML_TAG_ATTRIBUTES, XML_TAG_EXTENSION].join(", ");
|
|
129
129
|
node.querySelectorAll(ALLOWED_TAGS).each(
|
|
130
130
|
(node: XMLQuery) => {
|
|
131
131
|
switch (node.tagName.value) {
|
|
132
|
-
case
|
|
132
|
+
case XML_TAG_UPDATE:
|
|
133
133
|
processUpdateTag(node, responseProcessor);
|
|
134
134
|
break;
|
|
135
135
|
|
|
136
|
-
case
|
|
136
|
+
case XML_TAG_EVAL:
|
|
137
137
|
responseProcessor.eval(node);
|
|
138
138
|
break;
|
|
139
139
|
|
|
140
|
-
case
|
|
140
|
+
case XML_TAG_INSERT:
|
|
141
141
|
processInsert(responseProcessor, node);
|
|
142
142
|
break;
|
|
143
143
|
|
|
144
|
-
case
|
|
144
|
+
case XML_TAG_DELETE:
|
|
145
145
|
responseProcessor.delete(node);
|
|
146
146
|
break;
|
|
147
147
|
|
|
148
|
-
case
|
|
148
|
+
case XML_TAG_ATTRIBUTES:
|
|
149
149
|
responseProcessor.attributes(node);
|
|
150
150
|
break;
|
|
151
151
|
|
|
152
|
-
case
|
|
152
|
+
case XML_TAG_EXTENSION:
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
155
|
}
|