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
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.XhrRequest = void 0;
|
|
19
|
+
const AsyncRunnable_1 = require("../util/AsyncRunnable");
|
|
19
20
|
const mona_dish_1 = require("mona-dish");
|
|
20
21
|
const AjaxImpl_1 = require("../AjaxImpl");
|
|
21
22
|
const XhrFormData_1 = require("./XhrFormData");
|
|
@@ -27,147 +28,123 @@ const RequestDataResolver_1 = require("./RequestDataResolver");
|
|
|
27
28
|
var failSaveExecute = Lang_1.ExtLang.failSaveExecute;
|
|
28
29
|
/**
|
|
29
30
|
* Faces XHR Request Wrapper
|
|
30
|
-
* as
|
|
31
|
+
* as AsyncRunnable for our Asynchronous queue
|
|
32
|
+
* This means from the outside the
|
|
33
|
+
* xhr request is similar to a Promise in a way
|
|
34
|
+
* that you can add then and catch and finally callbacks.
|
|
35
|
+
*
|
|
31
36
|
*
|
|
32
37
|
* The idea is that we basically just enqueue
|
|
33
38
|
* a single ajax request into our queue
|
|
34
39
|
* and let the queue do the processing.
|
|
35
40
|
*
|
|
41
|
+
*
|
|
36
42
|
*/
|
|
37
|
-
class XhrRequest {
|
|
43
|
+
class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param source the issuing element
|
|
42
|
-
* @param sourceForm the form which is related to the issuing element
|
|
43
|
-
* @param requestContext the request context with allö pass through values
|
|
44
|
-
*
|
|
45
|
-
* Optional Parameters
|
|
45
|
+
* Required Parameters
|
|
46
46
|
*
|
|
47
|
+
* @param requestContext the request context with all pass through values
|
|
47
48
|
* @param internalContext internal context with internal info which is passed through, not used by the user
|
|
48
|
-
*
|
|
49
|
+
* Optional Parameters
|
|
49
50
|
* @param timeout optional xhr timeout
|
|
50
51
|
* @param ajaxType optional request type, default "POST"
|
|
51
52
|
* @param contentType optional content type, default "application/x-www-form-urlencoded"
|
|
52
|
-
* @param xhrObject optional xhr object which must fullfill the XMLHTTPRequest api, default XMLHttpRequest
|
|
53
53
|
*/
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
56
|
-
this.sourceForm = sourceForm;
|
|
54
|
+
constructor(requestContext, internalContext, timeout = Const_1.NO_TIMEOUT, ajaxType = Const_1.REQ_TYPE_POST, contentType = Const_1.URL_ENCODED) {
|
|
55
|
+
super();
|
|
57
56
|
this.requestContext = requestContext;
|
|
58
57
|
this.internalContext = internalContext;
|
|
59
|
-
this.partialIdsArray = partialIdsArray;
|
|
60
58
|
this.timeout = timeout;
|
|
61
59
|
this.ajaxType = ajaxType;
|
|
62
60
|
this.contentType = contentType;
|
|
63
|
-
this.xhrObject = xhrObject;
|
|
64
61
|
this.stopProgress = false;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
/*
|
|
71
|
-
* we omit promises here
|
|
72
|
-
* some browsers do not support it and we do not need shim code
|
|
73
|
-
*/
|
|
74
|
-
this.registerXhrCallbacks((data) => {
|
|
75
|
-
this.resolve(data);
|
|
76
|
-
}, (data) => {
|
|
77
|
-
this.reject(data);
|
|
78
|
-
});
|
|
62
|
+
this.xhrObject = new XMLHttpRequest();
|
|
63
|
+
// we omit promises here because we have to deal with cancel functionality,
|
|
64
|
+
// and promises to not provide that (yet) instead we have our async queue
|
|
65
|
+
// which uses an api internally, which is very close to promises
|
|
66
|
+
this.registerXhrCallbacks((data) => this.resolve(data), (data) => this.reject(data));
|
|
79
67
|
}
|
|
80
68
|
start() {
|
|
81
|
-
var _a;
|
|
82
69
|
let ignoreErr = failSaveExecute;
|
|
83
70
|
let xhrObject = this.xhrObject;
|
|
71
|
+
let sourceForm = mona_dish_1.DQ.byId(this.internalContext.getIf(Const_1.CTX_PARAM_SRC_FRM_ID).value);
|
|
84
72
|
let executesArr = () => {
|
|
85
|
-
return this.requestContext.getIf(Const_1.
|
|
73
|
+
return this.requestContext.getIf(Const_1.CTX_PARAM_REQ_PASS_THR, Const_1.P_EXECUTE).get(Const_1.IDENT_NONE).value.split(/\s+/gi);
|
|
86
74
|
};
|
|
87
75
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let formData = new XhrFormData_1.XhrFormData(this.sourceForm, viewState, executesArr(), this.partialIdsArray);
|
|
76
|
+
// encoded we need to decode
|
|
77
|
+
// We generated a base representation of the current form
|
|
78
|
+
// in case someone has overloaded the viewState with additional decorators we merge
|
|
79
|
+
// that in, there is no way around it, the spec allows it and getViewState
|
|
80
|
+
// must be called, so whatever getViewState delivers has higher priority then
|
|
81
|
+
// whatever the formData object delivers
|
|
82
|
+
// the partialIdsArray arr is almost deprecated legacy code where we allowed to send a separate list of partial
|
|
83
|
+
// ids for reduced load and server processing, this will be removed soon, we can handle the same via execute
|
|
84
|
+
const executes = executesArr();
|
|
85
|
+
const partialIdsArray = this.internalContext.getIf(Const_1.CTX_PARAM_PPS).value === true ? executes : [];
|
|
86
|
+
const formData = new XhrFormData_1.XhrFormData(sourceForm, (0, RequestDataResolver_1.resoveNamingContainerMapper)(this.internalContext), executes, partialIdsArray);
|
|
100
87
|
this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
|
|
101
|
-
//next step the pass through parameters are merged in for post params
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
// next step the pass through parameters are merged in for post params
|
|
89
|
+
this.requestContext.$nspEnabled = false;
|
|
90
|
+
const requestContext = this.requestContext;
|
|
91
|
+
const requestPassThroughParams = requestContext.getIf(Const_1.CTX_PARAM_REQ_PASS_THR);
|
|
92
|
+
// we are turning off here the jsf, faces remapping because we are now dealing with
|
|
93
|
+
// pass-through parameters
|
|
94
|
+
requestPassThroughParams.$nspEnabled = false;
|
|
104
95
|
// this is an extension where we allow pass through parameters to be sent down additionally
|
|
105
96
|
// this can be used and is used in the impl to enrich the post request parameters with additional
|
|
106
97
|
// information
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
try {
|
|
99
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
// unfortunately as long as we support
|
|
103
|
+
// both namespaces we have to keep manual control
|
|
104
|
+
// on the key renaming before doing ops like deep copy
|
|
105
|
+
this.requestContext.$nspEnabled = true;
|
|
106
|
+
requestPassThroughParams.$nspEnabled = true;
|
|
107
|
+
}
|
|
108
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
109
|
+
// we have to shift the internal passthroughs around to build up our response context
|
|
110
|
+
const responseContext = this.responseContext;
|
|
111
111
|
responseContext.assign(Const_1.CTX_PARAM_MF_INTERNAL).value = this.internalContext.value;
|
|
112
|
-
//per spec the
|
|
112
|
+
// per spec the onEvent and onError handlers must be passed through to the response
|
|
113
113
|
responseContext.assign(Const_1.ON_EVENT).value = requestContext.getIf(Const_1.ON_EVENT).value;
|
|
114
114
|
responseContext.assign(Const_1.ON_ERROR).value = requestContext.getIf(Const_1.ON_ERROR).value;
|
|
115
|
-
xhrObject.open(this.ajaxType, (0, RequestDataResolver_1.resolveFinalUrl)(
|
|
116
|
-
//adding timeout
|
|
115
|
+
xhrObject.open(this.ajaxType, (0, RequestDataResolver_1.resolveFinalUrl)(sourceForm, formData, this.ajaxType), true);
|
|
116
|
+
// adding timeout
|
|
117
117
|
this.timeout ? xhrObject.timeout = this.timeout : null;
|
|
118
|
-
//a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
|
|
119
|
-
//normal browsers should resolve this
|
|
120
|
-
//tests can quietly fail on this one
|
|
118
|
+
// a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
|
|
119
|
+
// normal browsers should resolve this
|
|
120
|
+
// tests can quietly fail on this one
|
|
121
121
|
if (this.contentType != "undefined") {
|
|
122
122
|
ignoreErr(() => xhrObject.setRequestHeader(Const_1.CONTENT_TYPE, `${this.contentType}; charset=utf-8`));
|
|
123
123
|
}
|
|
124
124
|
ignoreErr(() => xhrObject.setRequestHeader(Const_1.HEAD_FACES_REQ, Const_1.VAL_AJAX));
|
|
125
|
-
//probably not needed anymore, will test this
|
|
126
|
-
//some webkit based mobile browsers do not follow the w3c spec of
|
|
125
|
+
// probably not needed anymore, will test this
|
|
126
|
+
// some webkit based mobile browsers do not follow the w3c spec of
|
|
127
127
|
// setting, they accept headers automatically
|
|
128
128
|
ignoreErr(() => xhrObject.setRequestHeader(Const_1.REQ_ACCEPT, Const_1.STD_ACCEPT));
|
|
129
129
|
this.sendEvent(Const_1.BEGIN);
|
|
130
130
|
this.sendRequest(formData);
|
|
131
131
|
}
|
|
132
132
|
catch (e) {
|
|
133
|
-
//_onError
|
|
133
|
+
// _onError
|
|
134
134
|
this.handleError(e);
|
|
135
135
|
}
|
|
136
136
|
return this;
|
|
137
137
|
}
|
|
138
138
|
cancel() {
|
|
139
139
|
try {
|
|
140
|
+
// this causes onError to be called where the error
|
|
141
|
+
// handling takes over
|
|
140
142
|
this.xhrObject.abort();
|
|
141
143
|
}
|
|
142
144
|
catch (e) {
|
|
143
145
|
this.handleError(e);
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
|
-
resolve(data) {
|
|
147
|
-
mona_dish_1.Stream.of(...this.thenFunc).reduce((inputVal, thenFunc) => {
|
|
148
|
-
return thenFunc(inputVal);
|
|
149
|
-
}, data);
|
|
150
|
-
}
|
|
151
|
-
reject(data) {
|
|
152
|
-
mona_dish_1.Stream.of(...this.catchFuncs).reduce((inputVal, catchFunc) => {
|
|
153
|
-
return catchFunc(inputVal);
|
|
154
|
-
}, data);
|
|
155
|
-
}
|
|
156
|
-
catch(func) {
|
|
157
|
-
this.catchFuncs.push(func);
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
finally(func) {
|
|
161
|
-
//no ie11 support we probably are going to revert to shims for that one
|
|
162
|
-
this.catchFuncs.push(func);
|
|
163
|
-
this.thenFunc.push(func);
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
then(func) {
|
|
167
|
-
//this.$promise.then(func);
|
|
168
|
-
this.thenFunc.push(func);
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
148
|
/**
|
|
172
149
|
* attaches the internal event and processing
|
|
173
150
|
* callback within the promise to our xhr object
|
|
@@ -176,7 +153,7 @@ class XhrRequest {
|
|
|
176
153
|
* @param reject
|
|
177
154
|
*/
|
|
178
155
|
registerXhrCallbacks(resolve, reject) {
|
|
179
|
-
|
|
156
|
+
const xhrObject = this.xhrObject;
|
|
180
157
|
xhrObject.onabort = () => {
|
|
181
158
|
this.onAbort(reject);
|
|
182
159
|
};
|
|
@@ -190,13 +167,17 @@ class XhrRequest {
|
|
|
190
167
|
this.onDone(this.xhrObject, resolve);
|
|
191
168
|
};
|
|
192
169
|
xhrObject.onerror = (errorData) => {
|
|
193
|
-
// some browsers trigger an error when cancelling a request internally
|
|
170
|
+
// some browsers trigger an error when cancelling a request internally, or when
|
|
171
|
+
// cancel is called from outside
|
|
194
172
|
// in this case we simply ignore the request and clear up the queue, because
|
|
195
173
|
// it is not safe anymore to proceed with the current queue
|
|
196
174
|
// This bypasses a Safari issue where it keeps requests hanging after page unload
|
|
197
175
|
// and then triggers a cancel error on then instead of just stopping
|
|
198
176
|
// and clearing the code
|
|
199
177
|
if (this.isCancelledResponse(this.xhrObject)) {
|
|
178
|
+
/*
|
|
179
|
+
* this triggers the catch chain and after that finally
|
|
180
|
+
*/
|
|
200
181
|
reject();
|
|
201
182
|
this.stopProgress = true;
|
|
202
183
|
return;
|
|
@@ -205,7 +186,7 @@ class XhrRequest {
|
|
|
205
186
|
};
|
|
206
187
|
}
|
|
207
188
|
isCancelledResponse(currentTarget) {
|
|
208
|
-
return (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.status) === 0 && //cancelled by browser
|
|
189
|
+
return (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.status) === 0 && // cancelled by browser
|
|
209
190
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.readyState) === 4 &&
|
|
210
191
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseText) === '' &&
|
|
211
192
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseXML) === null;
|
|
@@ -224,26 +205,25 @@ class XhrRequest {
|
|
|
224
205
|
reject();
|
|
225
206
|
}
|
|
226
207
|
onSuccess(resolve) {
|
|
227
|
-
var _a, _b
|
|
208
|
+
var _a, _b;
|
|
228
209
|
this.sendEvent(Const_1.COMPLETE);
|
|
229
|
-
//
|
|
210
|
+
// malformed responses always result in empty response xml
|
|
211
|
+
// per spec a valid response cannot be empty
|
|
230
212
|
if (!((_a = this === null || this === void 0 ? void 0 : this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseXML)) {
|
|
231
213
|
this.handleMalFormedXML(resolve);
|
|
232
214
|
return;
|
|
233
215
|
}
|
|
234
|
-
(
|
|
216
|
+
(0, Const_1.$faces)().ajax.response(this.xhrObject, (_b = this.responseContext.value) !== null && _b !== void 0 ? _b : {});
|
|
235
217
|
}
|
|
236
218
|
handleMalFormedXML(resolve) {
|
|
237
219
|
var _a;
|
|
238
220
|
this.stopProgress = true;
|
|
239
|
-
|
|
221
|
+
const errorData = {
|
|
240
222
|
type: Const_1.ERROR,
|
|
241
223
|
status: Const_1.MALFORMEDXML,
|
|
242
224
|
responseCode: 200,
|
|
243
225
|
responseText: (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseText,
|
|
244
|
-
source:
|
|
245
|
-
id: this.source.id.value
|
|
246
|
-
}
|
|
226
|
+
source: this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value
|
|
247
227
|
};
|
|
248
228
|
try {
|
|
249
229
|
this.handleError(errorData, true);
|
|
@@ -253,27 +233,33 @@ class XhrRequest {
|
|
|
253
233
|
// reject would clean up the queue
|
|
254
234
|
resolve(errorData);
|
|
255
235
|
}
|
|
256
|
-
//non blocking non clearing
|
|
236
|
+
// non blocking non clearing
|
|
257
237
|
}
|
|
258
238
|
onDone(data, resolve) {
|
|
259
239
|
// if stop progress a special handling including resolve is already performed
|
|
260
240
|
if (this.stopProgress) {
|
|
261
241
|
return;
|
|
262
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* now call the then chain
|
|
245
|
+
*/
|
|
263
246
|
resolve(data);
|
|
264
247
|
}
|
|
265
248
|
onError(errorData, reject) {
|
|
266
249
|
this.handleError(errorData);
|
|
250
|
+
/*
|
|
251
|
+
* this triggers the catch chain and after that finally
|
|
252
|
+
*/
|
|
267
253
|
reject();
|
|
268
254
|
}
|
|
269
255
|
sendRequest(formData) {
|
|
270
|
-
|
|
256
|
+
const isPost = this.ajaxType != Const_1.REQ_TYPE_GET;
|
|
271
257
|
if (formData.isMultipartRequest) {
|
|
272
|
-
//in case of a multipart request we send in a formData object as body
|
|
258
|
+
// in case of a multipart request we send in a formData object as body
|
|
273
259
|
this.xhrObject.send((isPost) ? formData.toFormData() : null);
|
|
274
260
|
}
|
|
275
261
|
else {
|
|
276
|
-
//in case of a normal request we send it normally
|
|
262
|
+
// in case of a normal request we send it normally
|
|
277
263
|
this.xhrObject.send((isPost) ? formData.toString() : null);
|
|
278
264
|
}
|
|
279
265
|
}
|
|
@@ -281,23 +267,25 @@ class XhrRequest {
|
|
|
281
267
|
* other helpers
|
|
282
268
|
*/
|
|
283
269
|
sendEvent(evtType) {
|
|
284
|
-
|
|
270
|
+
var _a;
|
|
271
|
+
const eventData = EventData_1.EventData.createFromRequest(this.xhrObject, this.requestContext, evtType);
|
|
285
272
|
try {
|
|
286
|
-
//
|
|
287
|
-
//this in onError but also we cannot swallow it
|
|
288
|
-
//
|
|
289
|
-
//because some frameworks might decorate them over the context in the response
|
|
273
|
+
// User code error, we might cover
|
|
274
|
+
// this in onError, but also we cannot swallow it.
|
|
275
|
+
// We need to resolve the local handlers lazily,
|
|
276
|
+
// because some frameworks might decorate them over the context in the response
|
|
290
277
|
let eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_EVENT);
|
|
291
278
|
AjaxImpl_1.Implementation.sendEvent(eventData, eventHandler);
|
|
292
279
|
}
|
|
293
280
|
catch (e) {
|
|
281
|
+
e.source = (_a = e === null || e === void 0 ? void 0 : e.source) !== null && _a !== void 0 ? _a : this.requestContext.getIf(Const_1.SOURCE).value;
|
|
294
282
|
this.handleError(e);
|
|
295
283
|
throw e;
|
|
296
284
|
}
|
|
297
285
|
}
|
|
298
286
|
handleError(exception, responseFormatError = false) {
|
|
299
|
-
|
|
300
|
-
|
|
287
|
+
const errorData = (responseFormatError) ? ErrorData_1.ErrorData.fromHttpConnection(exception.source, exception.type, exception.status, exception.responseText, exception.responseCode, exception.status) : ErrorData_1.ErrorData.fromClient(exception);
|
|
288
|
+
const eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_ERROR);
|
|
301
289
|
AjaxImpl_1.Implementation.sendError(errorData, eventHandler);
|
|
302
290
|
}
|
|
303
291
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XhrRequest.js","sourceRoot":"","sources":["../../../src/main/typescript/impl/xhrCore/XhrRequest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"XhrRequest.js","sourceRoot":"","sources":["../../../src/main/typescript/impl/xhrCore/XhrRequest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yDAAoE;AACpE,yCAAqC;AACrC,0CAA2C;AAE3C,+CAA0C;AAC1C,2CAAsC;AACtC,2CAAsC;AACtC,uCAAqC;AACrC,yCAoBuB;AACvB,+DAI+B;AAC/B,IAAO,eAAe,GAAG,cAAO,CAAC,eAAe,CAAC;AAGjD;;;;;;;;;;;;;GAaG;AAEH,MAAa,UAAW,SAAQ,6BAA6B;IAQzD;;;;;;;;;OASG;IACH,YACY,cAAyB,EACzB,eAAuB,EACvB,UAAU,kBAAU,EACpB,WAAW,qBAAa,EACxB,cAAc,mBAAW;QAEjC,KAAK,EAAE,CAAC;QANA,mBAAc,GAAd,cAAc,CAAW;QACzB,oBAAe,GAAf,eAAe,CAAQ;QACvB,YAAO,GAAP,OAAO,CAAa;QACpB,aAAQ,GAAR,QAAQ,CAAgB;QACxB,gBAAW,GAAX,WAAW,CAAc;QAnB7B,iBAAY,GAAG,KAAK,CAAC;QAGrB,cAAS,GAAG,IAAI,cAAc,EAAE,CAAC;QAmBrC,2EAA2E;QAC3E,yEAAyE;QACzE,gEAAgE;QAChE,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACnG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AC,CAAC,CAAC,qBAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC/N,MAAM,YAAY,GAAG,IAAA,wCAAkB,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,gBAAQ,CAAC,CAAC;QAE7F,yBAAc,CAAC,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;CACJ;AAjSD,gCAiSC"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.oam = void 0;
|
|
19
19
|
const mona_dish_1 = require("mona-dish");
|
|
20
|
+
const Lang_1 = require("../impl/util/Lang");
|
|
20
21
|
/**
|
|
21
22
|
* legacy code to enable various aspects
|
|
22
23
|
* of myfaces, used to be rendered inline
|
|
@@ -30,6 +31,7 @@ const mona_dish_1 = require("mona-dish");
|
|
|
30
31
|
*/
|
|
31
32
|
var oam;
|
|
32
33
|
(function (oam) {
|
|
34
|
+
var ofAssoc = Lang_1.ExtLang.ofAssoc;
|
|
33
35
|
/**
|
|
34
36
|
* sets a hidden input field
|
|
35
37
|
* @param formName the formName
|
|
@@ -64,36 +66,39 @@ var oam;
|
|
|
64
66
|
}
|
|
65
67
|
mona_dish_1.DQ.byId(element).delete();
|
|
66
68
|
};
|
|
67
|
-
// noinspection JSUnusedGlobalSymbols
|
|
69
|
+
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
68
70
|
/**
|
|
69
71
|
* does special form submit remapping
|
|
70
72
|
* re-maps the issuing command link into something,
|
|
71
|
-
*
|
|
73
|
+
* the "decode" of the command link on the server can understand
|
|
72
74
|
*
|
|
73
75
|
* @param formName
|
|
74
76
|
* @param linkId
|
|
75
77
|
* @param target
|
|
76
78
|
* @param params
|
|
77
79
|
*/
|
|
78
|
-
oam.submitForm = function (formName, linkId, target, params) {
|
|
79
|
-
var _a, _b, _c, _d;
|
|
80
|
+
oam.submitForm = function (formName, linkId = null, target = null, params = {}) {
|
|
81
|
+
var _a, _b, _c, _d, _e, _f;
|
|
82
|
+
//handle a possible incoming null, not sure if this is used that way anywhere, but we allow it
|
|
83
|
+
params = (!params) ? {} : params;
|
|
80
84
|
let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
|
|
81
85
|
(_a = window === null || window === void 0 ? void 0 : window[clearFn]) === null || _a === void 0 ? void 0 : _a.call(window, formName);
|
|
82
86
|
//autoscroll code
|
|
83
87
|
if (((_d = (_c = (_b = window === null || window === void 0 ? void 0 : window.myfaces) === null || _b === void 0 ? void 0 : _b.core) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.autoScroll) && (window === null || window === void 0 ? void 0 : window.getScrolling)) {
|
|
84
88
|
myfaces.oam.setHiddenInput(formName, 'autoScroll', window === null || window === void 0 ? void 0 : window.getScrolling());
|
|
85
89
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
90
|
+
let paramsStream = Array.isArray(params) ? [...params] : ofAssoc(params);
|
|
91
|
+
paramsStream.forEach(([key, data]) => myfaces.oam.setHiddenInput(formName, key, data));
|
|
89
92
|
//we call the namespaced function, to allow decoration, via a direct call we would
|
|
90
|
-
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
|
|
91
|
-
mona_dish_1.DQ.byId(document.forms[formName]).each(form => {
|
|
93
|
+
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId !== null && linkId !== void 0 ? linkId : '');
|
|
94
|
+
mona_dish_1.DQ.byId((_f = (_e = document.forms) === null || _e === void 0 ? void 0 : _e[formName]) !== null && _f !== void 0 ? _f : document.getElementById(formName)).each(form => {
|
|
92
95
|
var _a;
|
|
93
96
|
const ATTR_TARGET = "target";
|
|
94
97
|
const formElement = form.getAsElem(0).value;
|
|
95
|
-
const oldTarget = form.
|
|
96
|
-
|
|
98
|
+
const oldTarget = form.getAsElem(0).value.getAttribute("target");
|
|
99
|
+
if (target != "null" && target) {
|
|
100
|
+
form.getAsElem(0).value.setAttribute("target", target);
|
|
101
|
+
}
|
|
97
102
|
const result = (_a = formElement === null || formElement === void 0 ? void 0 : formElement.onsubmit) === null || _a === void 0 ? void 0 : _a.call(formElement, null);
|
|
98
103
|
try {
|
|
99
104
|
if ((!!result) || 'undefined' == typeof result) {
|
|
@@ -104,9 +109,15 @@ var oam;
|
|
|
104
109
|
window === null || window === void 0 ? void 0 : window.console.error(e);
|
|
105
110
|
}
|
|
106
111
|
finally {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
if (oldTarget == null || oldTarget == "null") {
|
|
113
|
+
form.getAsElem(0).value.removeAttribute("target");
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
form.getAsElem(0).value.setAttribute("target", oldTarget);
|
|
117
|
+
}
|
|
118
|
+
// noinspection JSUnusedLocalSymbols
|
|
119
|
+
paramsStream.forEach(([key, data]) => {
|
|
120
|
+
myfaces.oam.clearHiddenInput(formName, key);
|
|
110
121
|
});
|
|
111
122
|
myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
|
|
112
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OamSubmit.js","sourceRoot":"","sources":["../../src/main/typescript/myfaces/OamSubmit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"OamSubmit.js","sourceRoot":"","sources":["../../src/main/typescript/myfaces/OamSubmit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yCAA6B;AAC7B,4CAA0C;AAE1C;;;;;;;;;;GAUG;AACH,IAAc,GAAG,CAqGhB;AArGD,WAAc,GAAG;IACb,IAAO,OAAO,GAAG,cAAO,CAAC,OAAO,CAAC;IACjC;;;;;OAKG;IACU,kBAAc,GAAG,UAAU,QAAgB,EAAE,IAAY,EAAE,KAAa;QACjF,cAAE,C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