jsf.js_next_gen 4.0.0-beta-23 → 4.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +13 -21
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/faces.ajax.addOnError.html +2 -0
- package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
- package/dist/docs/functions/faces.push.close.html +4 -2
- package/dist/docs/functions/faces.push.init.html +19 -7
- package/dist/docs/functions/faces.push.open.html +4 -2
- package/dist/docs/functions/myfaces.ab.html +9 -4
- package/dist/docs/functions/myfaces.onDomReady.html +72 -0
- package/dist/docs/index.html +16 -18
- package/dist/docs/modules/myfaces.html +3 -1
- package/dist/docs/variables/myfaces.oam.html +2 -1
- package/dist/window/faces-development.js +2846 -2085
- 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 +17 -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 +2856 -2084
- 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 +17 -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 +19 -18
- package/plans for 4.0.1.txt +8 -0
- 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 +68 -25
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +204 -100
- package/src/main/typescript/impl/PushImpl.ts +63 -38
- package/src/main/typescript/impl/core/Const.ts +56 -40
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncRunnable.ts +85 -10
- package/src/main/typescript/impl/util/ExtDomQuery.ts +65 -54
- package/src/main/typescript/impl/util/FileUtils.ts +108 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +93 -0
- package/src/main/typescript/impl/util/Lang.ts +91 -35
- package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
- package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +211 -138
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +92 -166
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +111 -120
- package/src/main/typescript/myfaces/OamSubmit.ts +30 -14
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +163 -27
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +921 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +111 -3
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
- package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
- package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
- package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
- package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
- 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 +158 -17
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +320 -15
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +45 -4
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +374 -35
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
- package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
- package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/test/resources/jsf-development.js +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +63 -21
- package/target/api/_api.js.map +1 -1
- package/target/api/jsf.js +11 -0
- package/target/api/jsf.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 +177 -81
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +66 -35
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +54 -39
- 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/AsyncRunnable.js +60 -0
- package/target/impl/util/AsyncRunnable.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +66 -48
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +97 -0
- package/target/impl/util/FileUtils.js.map +1 -0
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +83 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/{types/index.js → impl/util/IAsyncRunnable.js} +11 -2
- package/target/impl/util/IAsyncRunnable.js.map +1 -0
- package/target/impl/util/Lang.js +81 -31
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/util/URLCodec.js +77 -0
- package/target/impl/util/URLCodec.js.map +1 -0
- package/target/impl/util/XhrQueueController.js +107 -0
- package/target/impl/util/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +2 -2
- 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 +70 -23
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +44 -29
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +187 -119
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +82 -156
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrQueHandler.js +11 -0
- package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
- package/target/impl/xhrCore/XhrQueueController.js +62 -0
- package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/XhrRequest.js +94 -106
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +25 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +124 -23
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +103 -3
- 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/myfaces/OnLoadSpec.js +57 -0
- package/target/test/myfaces/OnLoadSpec.js.map +1 -0
- package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +26 -19
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -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 +142 -10
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +288 -11
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +40 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +315 -24
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
- package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
- package/target/test/xhrCore/XhrFormDataTest.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
- package/tmp.xml +36 -0
- package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
- package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
- package/target/types/index.js.map +0 -1
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {AsyncRunnable} from "../util/AsyncRunnable";
|
|
18
|
-
import {Config, DQ
|
|
17
|
+
import {AsyncRunnable, IAsyncRunnable} from "../util/AsyncRunnable";
|
|
18
|
+
import {Config, DQ} from "mona-dish";
|
|
19
19
|
import {Implementation} from "../AjaxImpl";
|
|
20
20
|
|
|
21
21
|
import {XhrFormData} from "./XhrFormData";
|
|
@@ -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,
|
|
@@ -36,145 +37,151 @@ import {
|
|
|
36
37
|
ON_EVENT, P_EXECUTE,
|
|
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,
|
|
43
|
-
VAL_AJAX
|
|
44
|
+
VAL_AJAX, IDENT_NONE, CTX_PARAM_SRC_FRM_ID, CTX_PARAM_SRC_CTL_ID, CTX_PARAM_PPS
|
|
44
45
|
} from "../core/Const";
|
|
45
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
resolveFinalUrl,
|
|
48
|
+
resolveHandlerFunc,
|
|
49
|
+
resoveNamingContainerMapper
|
|
50
|
+
} from "./RequestDataResolver";
|
|
46
51
|
import failSaveExecute = ExtLang.failSaveExecute;
|
|
52
|
+
import {ExtConfig} from "../util/ExtDomQuery";
|
|
47
53
|
|
|
48
54
|
/**
|
|
49
55
|
* Faces XHR Request Wrapper
|
|
50
|
-
* as
|
|
56
|
+
* as AsyncRunnable for our Asynchronous queue
|
|
57
|
+
* This means from the outside the
|
|
58
|
+
* xhr request is similar to a Promise in a way
|
|
59
|
+
* that you can add then and catch and finally callbacks.
|
|
60
|
+
*
|
|
51
61
|
*
|
|
52
62
|
* The idea is that we basically just enqueue
|
|
53
63
|
* a single ajax request into our queue
|
|
54
64
|
* and let the queue do the processing.
|
|
55
65
|
*
|
|
66
|
+
*
|
|
56
67
|
*/
|
|
57
68
|
|
|
58
|
-
export class XhrRequest
|
|
69
|
+
export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
|
|
59
70
|
|
|
60
71
|
private responseContext: Config;
|
|
61
72
|
|
|
62
73
|
private stopProgress = false;
|
|
63
74
|
|
|
64
|
-
/**
|
|
65
|
-
* helper support so that we do not have to drag in Promise shims
|
|
66
|
-
*/
|
|
67
|
-
private catchFuncs: Array<Function> = [];
|
|
68
|
-
private thenFunc: Array<Function> = [];
|
|
69
75
|
|
|
76
|
+
private xhrObject = new XMLHttpRequest();
|
|
70
77
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @param source the issuing element
|
|
74
|
-
* @param sourceForm the form which is related to the issuing element
|
|
75
|
-
* @param requestContext the request context with allö pass through values
|
|
76
|
-
*
|
|
77
|
-
* Optional Parameters
|
|
78
|
+
* Required Parameters
|
|
78
79
|
*
|
|
80
|
+
* @param requestContext the request context with all pass through values
|
|
79
81
|
* @param internalContext internal context with internal info which is passed through, not used by the user
|
|
80
|
-
*
|
|
82
|
+
* Optional Parameters
|
|
81
83
|
* @param timeout optional xhr timeout
|
|
82
84
|
* @param ajaxType optional request type, default "POST"
|
|
83
85
|
* @param contentType optional content type, default "application/x-www-form-urlencoded"
|
|
84
|
-
* @param xhrObject optional xhr object which must fullfill the XMLHTTPRequest api, default XMLHttpRequest
|
|
85
86
|
*/
|
|
86
87
|
constructor(
|
|
87
|
-
private
|
|
88
|
-
private sourceForm: DQ,
|
|
89
|
-
private requestContext: Config,
|
|
88
|
+
private requestContext: ExtConfig,
|
|
90
89
|
private internalContext: Config,
|
|
91
|
-
private partialIdsArray = [],
|
|
92
90
|
private timeout = NO_TIMEOUT,
|
|
93
91
|
private ajaxType = REQ_TYPE_POST,
|
|
94
|
-
private contentType = URL_ENCODED
|
|
95
|
-
private xhrObject = new XMLHttpRequest()
|
|
92
|
+
private contentType = URL_ENCODED
|
|
96
93
|
) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.registerXhrCallbacks((data: any) =>
|
|
102
|
-
this.resolve(data)
|
|
103
|
-
}, (data: any) => {
|
|
104
|
-
this.reject(data)
|
|
105
|
-
});
|
|
94
|
+
super();
|
|
95
|
+
// we omit promises here because we have to deal with cancel functionality,
|
|
96
|
+
// and promises to not provide that (yet) instead we have our async queue
|
|
97
|
+
// which uses an api internally, which is very close to promises
|
|
98
|
+
this.registerXhrCallbacks((data: any) => this.resolve(data), (data: any) => this.reject(data));
|
|
106
99
|
}
|
|
107
100
|
|
|
108
|
-
start():
|
|
101
|
+
start(): IAsyncRunnable<XMLHttpRequest> {
|
|
109
102
|
|
|
110
103
|
let ignoreErr = failSaveExecute;
|
|
111
104
|
let xhrObject = this.xhrObject;
|
|
105
|
+
let sourceForm = DQ.byId(this.internalContext.getIf(CTX_PARAM_SRC_FRM_ID).value)
|
|
112
106
|
|
|
113
107
|
let executesArr = () => {
|
|
114
|
-
return this.requestContext.getIf(
|
|
108
|
+
return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get(IDENT_NONE).value.split(/\s+/gi);
|
|
115
109
|
};
|
|
116
|
-
try {
|
|
117
110
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//in
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
try {
|
|
112
|
+
// encoded we need to decode
|
|
113
|
+
// We generated a base representation of the current form
|
|
114
|
+
// in case someone has overloaded the viewState with additional decorators we merge
|
|
115
|
+
// that in, there is no way around it, the spec allows it and getViewState
|
|
116
|
+
// must be called, so whatever getViewState delivers has higher priority then
|
|
117
|
+
// whatever the formData object delivers
|
|
118
|
+
// the partialIdsArray arr is almost deprecated legacy code where we allowed to send a separate list of partial
|
|
119
|
+
// ids for reduced load and server processing, this will be removed soon, we can handle the same via execute
|
|
120
|
+
const executes = executesArr();
|
|
121
|
+
const partialIdsArray = this.internalContext.getIf(CTX_PARAM_PPS).value === true ? executes : [];
|
|
122
|
+
const formData: XhrFormData = new XhrFormData(
|
|
123
|
+
sourceForm,
|
|
124
|
+
resoveNamingContainerMapper(this.internalContext),
|
|
125
|
+
executes, partialIdsArray
|
|
126
|
+
);
|
|
130
127
|
|
|
131
128
|
this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
|
|
132
129
|
|
|
133
|
-
//next step the pass through parameters are merged in for post params
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
// next step the pass through parameters are merged in for post params
|
|
131
|
+
this.requestContext.$nspEnabled = false;
|
|
132
|
+
const requestContext = this.requestContext;
|
|
133
|
+
const requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
|
|
136
134
|
|
|
135
|
+
// we are turning off here the jsf, faces remapping because we are now dealing with
|
|
136
|
+
// pass-through parameters
|
|
137
|
+
requestPassThroughParams.$nspEnabled = false;
|
|
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
|
-
|
|
141
|
+
try {
|
|
142
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
143
|
+
} finally {
|
|
144
|
+
// unfortunately as long as we support
|
|
145
|
+
// both namespaces we have to keep manual control
|
|
146
|
+
// on the key renaming before doing ops like deep copy
|
|
147
|
+
this.requestContext.$nspEnabled = true;
|
|
148
|
+
requestPassThroughParams.$nspEnabled = true;
|
|
149
|
+
}
|
|
141
150
|
|
|
142
|
-
this.responseContext =
|
|
151
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
143
152
|
|
|
144
|
-
//we have to shift the internal passthroughs around to build up our response context
|
|
145
|
-
|
|
153
|
+
// we have to shift the internal passthroughs around to build up our response context
|
|
154
|
+
const responseContext = this.responseContext;
|
|
146
155
|
|
|
147
156
|
responseContext.assign(CTX_PARAM_MF_INTERNAL).value = this.internalContext.value;
|
|
148
157
|
|
|
149
|
-
//per spec the
|
|
158
|
+
// per spec the onEvent and onError handlers must be passed through to the response
|
|
150
159
|
responseContext.assign(ON_EVENT).value = requestContext.getIf(ON_EVENT).value;
|
|
151
160
|
responseContext.assign(ON_ERROR).value = requestContext.getIf(ON_ERROR).value;
|
|
152
161
|
|
|
153
|
-
xhrObject.open(this.ajaxType, resolveFinalUrl(
|
|
162
|
+
xhrObject.open(this.ajaxType, resolveFinalUrl(sourceForm, formData, this.ajaxType), true);
|
|
154
163
|
|
|
155
|
-
//adding timeout
|
|
164
|
+
// adding timeout
|
|
156
165
|
this.timeout ? xhrObject.timeout = this.timeout : null;
|
|
157
166
|
|
|
158
|
-
//a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
|
|
159
|
-
//normal browsers should resolve this
|
|
160
|
-
//tests can quietly fail on this one
|
|
167
|
+
// a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
|
|
168
|
+
// normal browsers should resolve this
|
|
169
|
+
// tests can quietly fail on this one
|
|
161
170
|
if(this.contentType != "undefined") {
|
|
162
171
|
ignoreErr(() => xhrObject.setRequestHeader(CONTENT_TYPE, `${this.contentType}; charset=utf-8`));
|
|
163
172
|
}
|
|
164
173
|
|
|
165
174
|
ignoreErr(() => xhrObject.setRequestHeader(HEAD_FACES_REQ, VAL_AJAX));
|
|
166
175
|
|
|
167
|
-
//probably not needed anymore, will test this
|
|
168
|
-
//some webkit based mobile browsers do not follow the w3c spec of
|
|
176
|
+
// probably not needed anymore, will test this
|
|
177
|
+
// some webkit based mobile browsers do not follow the w3c spec of
|
|
169
178
|
// setting, they accept headers automatically
|
|
170
179
|
ignoreErr(() => xhrObject.setRequestHeader(REQ_ACCEPT, STD_ACCEPT));
|
|
171
180
|
|
|
172
181
|
this.sendEvent(BEGIN);
|
|
173
|
-
|
|
174
182
|
this.sendRequest(formData);
|
|
175
|
-
|
|
176
183
|
} catch (e) {
|
|
177
|
-
//_onError
|
|
184
|
+
// _onError
|
|
178
185
|
this.handleError(e);
|
|
179
186
|
}
|
|
180
187
|
return this;
|
|
@@ -182,41 +189,15 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
182
189
|
|
|
183
190
|
cancel() {
|
|
184
191
|
try {
|
|
192
|
+
// this causes onError to be called where the error
|
|
193
|
+
// handling takes over
|
|
185
194
|
this.xhrObject.abort();
|
|
186
195
|
} catch (e) {
|
|
187
196
|
this.handleError(e);
|
|
188
197
|
}
|
|
189
198
|
}
|
|
190
199
|
|
|
191
|
-
resolve(data: any) {
|
|
192
|
-
Stream.of(...this.thenFunc).reduce((inputVal: any, thenFunc: any) => {
|
|
193
|
-
return thenFunc(inputVal);
|
|
194
|
-
}, data);
|
|
195
|
-
}
|
|
196
200
|
|
|
197
|
-
reject(data: any) {
|
|
198
|
-
Stream.of(...this.catchFuncs).reduce((inputVal: any, catchFunc: any) => {
|
|
199
|
-
return catchFunc(inputVal);
|
|
200
|
-
}, data);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
catch(func: (data: any) => any): AsyncRunnable<XMLHttpRequest> {
|
|
204
|
-
this.catchFuncs.push(func);
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
finally(func: () => void): AsyncRunnable<XMLHttpRequest> {
|
|
209
|
-
//no ie11 support we probably are going to revert to shims for that one
|
|
210
|
-
this.catchFuncs.push(func);
|
|
211
|
-
this.thenFunc.push(func);
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
then(func: (data: any) => any): AsyncRunnable<XMLHttpRequest> {
|
|
216
|
-
//this.$promise.then(func);
|
|
217
|
-
this.thenFunc.push(func);
|
|
218
|
-
return this;
|
|
219
|
-
}
|
|
220
201
|
|
|
221
202
|
/**
|
|
222
203
|
* attaches the internal event and processing
|
|
@@ -226,7 +207,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
226
207
|
* @param reject
|
|
227
208
|
*/
|
|
228
209
|
private registerXhrCallbacks(resolve: Consumer<any>, reject: Consumer<any>) {
|
|
229
|
-
|
|
210
|
+
const xhrObject = this.xhrObject;
|
|
230
211
|
|
|
231
212
|
xhrObject.onabort = () => {
|
|
232
213
|
this.onAbort(reject);
|
|
@@ -241,14 +222,18 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
241
222
|
this.onDone(this.xhrObject, resolve);
|
|
242
223
|
};
|
|
243
224
|
xhrObject.onerror = (errorData: any) => {
|
|
244
|
-
|
|
225
|
+
|
|
226
|
+
// some browsers trigger an error when cancelling a request internally, or when
|
|
227
|
+
// cancel is called from outside
|
|
245
228
|
// in this case we simply ignore the request and clear up the queue, because
|
|
246
229
|
// it is not safe anymore to proceed with the current queue
|
|
247
|
-
|
|
248
230
|
// This bypasses a Safari issue where it keeps requests hanging after page unload
|
|
249
231
|
// and then triggers a cancel error on then instead of just stopping
|
|
250
232
|
// and clearing the code
|
|
251
233
|
if(this.isCancelledResponse(this.xhrObject)) {
|
|
234
|
+
/*
|
|
235
|
+
* this triggers the catch chain and after that finally
|
|
236
|
+
*/
|
|
252
237
|
reject();
|
|
253
238
|
this.stopProgress = true;
|
|
254
239
|
return;
|
|
@@ -258,7 +243,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
258
243
|
}
|
|
259
244
|
|
|
260
245
|
private isCancelledResponse(currentTarget: XMLHttpRequest): boolean {
|
|
261
|
-
return currentTarget?.status === 0 && //cancelled by browser
|
|
246
|
+
return currentTarget?.status === 0 && // cancelled by browser
|
|
262
247
|
currentTarget?.readyState === 4 &&
|
|
263
248
|
currentTarget?.responseText === '' &&
|
|
264
249
|
currentTarget?.responseXML === null;
|
|
@@ -284,25 +269,24 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
284
269
|
|
|
285
270
|
this.sendEvent(COMPLETE);
|
|
286
271
|
|
|
287
|
-
//
|
|
272
|
+
// malformed responses always result in empty response xml
|
|
273
|
+
// per spec a valid response cannot be empty
|
|
288
274
|
if (!this?.xhrObject?.responseXML) {
|
|
289
275
|
this.handleMalFormedXML(resolve);
|
|
290
276
|
return;
|
|
291
277
|
}
|
|
292
278
|
|
|
293
|
-
(
|
|
279
|
+
$faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
|
|
294
280
|
}
|
|
295
281
|
|
|
296
282
|
private handleMalFormedXML(resolve: Function) {
|
|
297
283
|
this.stopProgress = true;
|
|
298
|
-
|
|
284
|
+
const errorData = {
|
|
299
285
|
type: ERROR,
|
|
300
286
|
status: MALFORMEDXML,
|
|
301
287
|
responseCode: 200,
|
|
302
288
|
responseText: this.xhrObject?.responseText,
|
|
303
|
-
source:
|
|
304
|
-
id: this.source.id.value
|
|
305
|
-
}
|
|
289
|
+
source: this.internalContext.getIf(CTX_PARAM_SRC_CTL_ID).value
|
|
306
290
|
};
|
|
307
291
|
try {
|
|
308
292
|
this.handleError(errorData, true);
|
|
@@ -311,7 +295,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
311
295
|
// reject would clean up the queue
|
|
312
296
|
resolve(errorData);
|
|
313
297
|
}
|
|
314
|
-
//non blocking non clearing
|
|
298
|
+
// non blocking non clearing
|
|
315
299
|
}
|
|
316
300
|
|
|
317
301
|
private onDone(data: any, resolve: Consumer<any>) {
|
|
@@ -319,21 +303,27 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
319
303
|
if (this.stopProgress) {
|
|
320
304
|
return;
|
|
321
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* now call the then chain
|
|
308
|
+
*/
|
|
322
309
|
resolve(data);
|
|
323
310
|
}
|
|
324
311
|
|
|
325
312
|
private onError(errorData: any, reject: Consumer<any>) {
|
|
326
313
|
this.handleError(errorData);
|
|
314
|
+
/*
|
|
315
|
+
* this triggers the catch chain and after that finally
|
|
316
|
+
*/
|
|
327
317
|
reject();
|
|
328
318
|
}
|
|
329
319
|
|
|
330
320
|
private sendRequest(formData: XhrFormData) {
|
|
331
|
-
|
|
321
|
+
const isPost = this.ajaxType != REQ_TYPE_GET;
|
|
332
322
|
if (formData.isMultipartRequest) {
|
|
333
|
-
//in case of a multipart request we send in a formData object as body
|
|
323
|
+
// in case of a multipart request we send in a formData object as body
|
|
334
324
|
this.xhrObject.send((isPost) ? formData.toFormData() : null);
|
|
335
325
|
} else {
|
|
336
|
-
//in case of a normal request we send it normally
|
|
326
|
+
// in case of a normal request we send it normally
|
|
337
327
|
this.xhrObject.send((isPost) ? formData.toString() : null);
|
|
338
328
|
}
|
|
339
329
|
}
|
|
@@ -342,26 +332,27 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
342
332
|
* other helpers
|
|
343
333
|
*/
|
|
344
334
|
private sendEvent(evtType: string) {
|
|
345
|
-
|
|
335
|
+
const eventData = EventData.createFromRequest(this.xhrObject, this.requestContext, evtType);
|
|
346
336
|
try {
|
|
347
|
-
//
|
|
348
|
-
//this in onError but also we cannot swallow it
|
|
349
|
-
//
|
|
350
|
-
//because some frameworks might decorate them over the context in the response
|
|
337
|
+
// User code error, we might cover
|
|
338
|
+
// this in onError, but also we cannot swallow it.
|
|
339
|
+
// We need to resolve the local handlers lazily,
|
|
340
|
+
// because some frameworks might decorate them over the context in the response
|
|
351
341
|
let eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_EVENT);
|
|
352
342
|
|
|
353
343
|
Implementation.sendEvent(eventData, eventHandler);
|
|
354
344
|
} catch (e) {
|
|
345
|
+
e.source = e?.source ?? this.requestContext.getIf(SOURCE).value;
|
|
355
346
|
this.handleError(e);
|
|
347
|
+
|
|
356
348
|
throw e;
|
|
357
349
|
}
|
|
358
350
|
}
|
|
359
351
|
|
|
360
352
|
private handleError(exception, responseFormatError: boolean = false) {
|
|
361
|
-
|
|
353
|
+
const errorData = (responseFormatError) ? ErrorData.fromHttpConnection(exception.source, exception.type, exception.status, exception.responseText, exception.responseCode, exception.status) : ErrorData.fromClient(exception);
|
|
354
|
+
const eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_ERROR);
|
|
362
355
|
|
|
363
|
-
let eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_ERROR);
|
|
364
356
|
Implementation.sendError(errorData, eventHandler);
|
|
365
357
|
}
|
|
366
|
-
|
|
367
358
|
}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {DQ
|
|
17
|
+
import {DQ} from "mona-dish";
|
|
18
|
+
import {ExtLang} from "../impl/util/Lang";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* legacy code to enable various aspects
|
|
@@ -28,6 +29,7 @@ import {DQ, Stream} from "mona-dish";
|
|
|
28
29
|
* we might move the code over in the future, but for now a straight 1:1 port suffices
|
|
29
30
|
*/
|
|
30
31
|
export module oam {
|
|
32
|
+
import ofAssoc = ExtLang.ofAssoc;
|
|
31
33
|
/**
|
|
32
34
|
* sets a hidden input field
|
|
33
35
|
* @param formName the formName
|
|
@@ -62,18 +64,23 @@ export module oam {
|
|
|
62
64
|
DQ.byId(element).delete();
|
|
63
65
|
};
|
|
64
66
|
|
|
65
|
-
// noinspection JSUnusedGlobalSymbols
|
|
67
|
+
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
66
68
|
/**
|
|
67
69
|
* does special form submit remapping
|
|
68
70
|
* re-maps the issuing command link into something,
|
|
69
|
-
*
|
|
71
|
+
* the "decode" of the command link on the server can understand
|
|
70
72
|
*
|
|
71
73
|
* @param formName
|
|
72
74
|
* @param linkId
|
|
73
75
|
* @param target
|
|
74
76
|
* @param params
|
|
75
77
|
*/
|
|
76
|
-
export const submitForm = function (formName: string, linkId: string, target: string, params:
|
|
78
|
+
export const submitForm = function (formName: string, linkId: string | null = null, target: string |null = null, params: AssocArr<any> | Tuples<string, any> | null = {} ): boolean {
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
//handle a possible incoming null, not sure if this is used that way anywhere, but we allow it
|
|
82
|
+
params = (!params) ? {} : params;
|
|
83
|
+
|
|
77
84
|
let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
|
|
78
85
|
window?.[clearFn]?.(formName);
|
|
79
86
|
|
|
@@ -81,18 +88,21 @@ export module oam {
|
|
|
81
88
|
if (window?.myfaces?.core?.config?.autoScroll && (window as any)?.getScrolling) {
|
|
82
89
|
myfaces.oam.setHiddenInput(formName, 'autoScroll', (window as any)?.getScrolling());
|
|
83
90
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
91
|
+
let paramsStream: Array<[string, any]> = Array.isArray(params) ? [...params] : ofAssoc(params);
|
|
92
|
+
paramsStream.forEach(([key, data]) => myfaces.oam.setHiddenInput(formName, key, data));
|
|
87
93
|
|
|
88
94
|
//we call the namespaced function, to allow decoration, via a direct call we would
|
|
89
|
-
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
|
|
95
|
+
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId ?? '');
|
|
96
|
+
|
|
90
97
|
|
|
91
|
-
DQ.byId(document.forms[formName]).each(form => {
|
|
98
|
+
DQ.byId(document.forms?.[formName] ?? document.getElementById(formName)).each(form => {
|
|
92
99
|
const ATTR_TARGET = "target";
|
|
93
100
|
const formElement = form.getAsElem(0).value as HTMLFormElement;
|
|
94
|
-
const oldTarget = form.
|
|
95
|
-
|
|
101
|
+
const oldTarget = (form.getAsElem(0).value as HTMLFormElement).getAttribute("target");
|
|
102
|
+
|
|
103
|
+
if(target != "null" && target) {
|
|
104
|
+
(form.getAsElem(0).value as HTMLFormElement).setAttribute("target", target);
|
|
105
|
+
}
|
|
96
106
|
|
|
97
107
|
const result = formElement?.onsubmit?.(null);
|
|
98
108
|
|
|
@@ -103,9 +113,15 @@ export module oam {
|
|
|
103
113
|
} catch (e) {
|
|
104
114
|
window?.console.error(e);
|
|
105
115
|
} finally {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
if(oldTarget == null || oldTarget == "null") {
|
|
117
|
+
(form.getAsElem(0).value as HTMLFormElement).removeAttribute("target");
|
|
118
|
+
} else {
|
|
119
|
+
(form.getAsElem(0).value as HTMLFormElement).setAttribute("target", oldTarget);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// noinspection JSUnusedLocalSymbols
|
|
123
|
+
paramsStream.forEach(([key, data]) => {
|
|
124
|
+
myfaces.oam.clearHiddenInput(formName, key);
|
|
109
125
|
});
|
|
110
126
|
myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
|
|
111
127
|
}
|