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
|
@@ -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
|
-
import {Lang as LangBase, Config, Optional, DomQuery, DQ
|
|
18
|
+
import {Lang as LangBase, Config, Optional, DomQuery, DQ} 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
|
|
|
@@ -38,11 +36,11 @@ export module ExtLang {
|
|
|
38
36
|
|
|
39
37
|
//should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those
|
|
40
38
|
/**
|
|
41
|
-
* helper function to
|
|
39
|
+
* helper function to safely resolve anything
|
|
42
40
|
* this is not an elvis operator, it resolves
|
|
43
41
|
* a value without exception in a tree and if
|
|
44
42
|
* it is not resolvable then an optional of
|
|
45
|
-
* a default value is restored or Optional
|
|
43
|
+
* a default value is restored or Optional\.empty
|
|
46
44
|
* if none is given
|
|
47
45
|
*
|
|
48
46
|
* usage
|
|
@@ -51,7 +49,7 @@ export module ExtLang {
|
|
|
51
49
|
* </code>
|
|
52
50
|
*
|
|
53
51
|
* @param resolverProducer a lambda which can produce the value
|
|
54
|
-
* @param defaultValue an optional default value if the producer
|
|
52
|
+
* @param defaultValue an optional default value if the producer fails to produce anything
|
|
55
53
|
* @returns an Optional of the produced value
|
|
56
54
|
*/
|
|
57
55
|
export function failSaveResolve<T>(resolverProducer: () => T, defaultValue: T = null): Optional<T> {
|
|
@@ -75,10 +73,10 @@ export module ExtLang {
|
|
|
75
73
|
* returns a given localized message upon a given key
|
|
76
74
|
* basic java log like templating functionality is included
|
|
77
75
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
76
|
+
* @param key the key for the message
|
|
77
|
+
* @param defaultMessage optional default message if none was found
|
|
80
78
|
*
|
|
81
|
-
* Additionally you can pass additional arguments, which are used
|
|
79
|
+
* Additionally, you can pass additional arguments, which are used
|
|
82
80
|
* in the same way java log templates use the params
|
|
83
81
|
*
|
|
84
82
|
* @param templateParams the param list to be filled in
|
|
@@ -87,10 +85,10 @@ export module ExtLang {
|
|
|
87
85
|
installedLocale = installedLocale ?? new Messages();
|
|
88
86
|
|
|
89
87
|
let msg = installedLocale[key] ?? defaultMessage ?? key;
|
|
90
|
-
|
|
91
|
-
Stream.of(...templateParams).each((param, cnt) => {
|
|
88
|
+
templateParams.forEach((param, cnt) => {
|
|
92
89
|
msg = msg.replace(new RegExp(["\\{", cnt, "\\}"].join(EMPTY_STR), "g"), param);
|
|
93
|
-
})
|
|
90
|
+
})
|
|
91
|
+
|
|
94
92
|
|
|
95
93
|
return msg;
|
|
96
94
|
}
|
|
@@ -106,15 +104,15 @@ export module ExtLang {
|
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
/**
|
|
109
|
-
* creates an
|
|
107
|
+
* creates an exception with additional internal parameters
|
|
110
108
|
* for extra information
|
|
111
109
|
*
|
|
112
110
|
* @param error
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
111
|
+
* @param title the exception title
|
|
112
|
+
* @param name the exception name
|
|
113
|
+
* @param callerCls the caller class
|
|
114
|
+
* @param callFunc the caller function
|
|
115
|
+
* @param message the message for the exception
|
|
118
116
|
*/
|
|
119
117
|
export function makeException(error: Error, title: string, name: string, callerCls: string, callFunc: string, message: string): Error {
|
|
120
118
|
|
|
@@ -124,14 +122,14 @@ export module ExtLang {
|
|
|
124
122
|
|
|
125
123
|
/**
|
|
126
124
|
* fetches a global config entry
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
125
|
+
* @param configName the name of the configuration entry
|
|
126
|
+
* @param defaultValue
|
|
129
127
|
*
|
|
130
128
|
* @return either the config entry or if none is given the default value
|
|
131
129
|
*/
|
|
132
130
|
export function getGlobalConfig(configName: string, defaultValue: any): any {
|
|
133
131
|
/**
|
|
134
|
-
* note we could use exists but this is
|
|
132
|
+
* note we could use exists but this is a heavy operation, since the config name usually
|
|
135
133
|
* given this function here is called very often
|
|
136
134
|
* is a single entry without . in between we can do the lighter shortcut
|
|
137
135
|
*/
|
|
@@ -139,7 +137,7 @@ export module ExtLang {
|
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
|
-
* fetches the form in
|
|
140
|
+
* fetches the form in a fuzzy manner depending
|
|
143
141
|
* on an element or event target.
|
|
144
142
|
*
|
|
145
143
|
* The idea is that according to the jsf spec
|
|
@@ -148,7 +146,7 @@ export module ExtLang {
|
|
|
148
146
|
* This is fine, but since then html5 came into the picture with the form attribute the element
|
|
149
147
|
* can be anywhere referencing its parent form.
|
|
150
148
|
*
|
|
151
|
-
* Also theoretically you can have the case of an issuing element enclosing a set of forms
|
|
149
|
+
* Also, theoretically you can have the case of an issuing element enclosing a set of forms
|
|
152
150
|
* (not really often used, but theoretically it could be input button allows to embed html for instance)
|
|
153
151
|
*
|
|
154
152
|
* So the idea is not to limit the issuing form determination to the spec case
|
|
@@ -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);
|
|
@@ -190,10 +188,11 @@ export module ExtLang {
|
|
|
190
188
|
* gets the local or global options with local ones having higher priority
|
|
191
189
|
* if no local or global one was found then the default value is given back
|
|
192
190
|
*
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
191
|
+
* @param configName the name of the configuration entry
|
|
192
|
+
* @param localOptions the local options root for the configuration myfaces as default marker is added
|
|
193
|
+
* implicitly
|
|
195
194
|
*
|
|
196
|
-
* @param
|
|
195
|
+
* @param defaultValue
|
|
197
196
|
*
|
|
198
197
|
* @return either the config entry or if none is given the default value
|
|
199
198
|
*/
|
|
@@ -203,6 +202,61 @@ export module ExtLang {
|
|
|
203
202
|
defaultValue;
|
|
204
203
|
}
|
|
205
204
|
|
|
205
|
+
/**
|
|
206
|
+
* expands an associative array into an array of key value tuples
|
|
207
|
+
* @param value
|
|
208
|
+
*/
|
|
209
|
+
export function ofAssoc(value: {[key: string]: any}) {
|
|
210
|
+
return Object.keys(value)
|
|
211
|
+
.map(key => [key, value[key]]);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function collectAssoc(target: any, item: any) {
|
|
215
|
+
target[item[0]] = item[1];
|
|
216
|
+
return target;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The active timeout for the "debounce".
|
|
221
|
+
* Since we only use it in the XhrController
|
|
222
|
+
* we can use a local module variable here
|
|
223
|
+
*/
|
|
224
|
+
let activeTimeouts = {};
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* a simple debounce function
|
|
231
|
+
* which waits until a timeout is reached and
|
|
232
|
+
* if something comes in in between debounces
|
|
233
|
+
*
|
|
234
|
+
* @param runnable a runnable which should go under debounce control
|
|
235
|
+
* @param timeout a timeout for the debounce window
|
|
236
|
+
*/
|
|
237
|
+
export function debounce(key, runnable, timeout) {
|
|
238
|
+
function clearActiveTimeout() {
|
|
239
|
+
clearTimeout(activeTimeouts[key]);
|
|
240
|
+
delete activeTimeouts[key];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!!(activeTimeouts?.[key])) {
|
|
244
|
+
clearActiveTimeout();
|
|
245
|
+
}
|
|
246
|
+
if (timeout > 0) {
|
|
247
|
+
activeTimeouts[key] = setTimeout(() => {
|
|
248
|
+
try {
|
|
249
|
+
runnable();
|
|
250
|
+
} finally {
|
|
251
|
+
clearActiveTimeout();
|
|
252
|
+
}
|
|
253
|
+
}, timeout);
|
|
254
|
+
} else {
|
|
255
|
+
runnable();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
206
260
|
/**
|
|
207
261
|
* assert that the form exists and throw an exception in the case it does not
|
|
208
262
|
*
|
|
@@ -213,4 +267,6 @@ export module ExtLang {
|
|
|
213
267
|
throw makeException(new Error(), null, null, "Impl", "getForm", getMessage("ERR_FORM"));
|
|
214
268
|
}
|
|
215
269
|
}
|
|
270
|
+
|
|
271
|
+
|
|
216
272
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {IAsyncRunnable} from "./AsyncRunnable";
|
|
2
|
+
import {ExtLang} from "./Lang";
|
|
3
|
+
import debounce = ExtLang.debounce;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A simple XHR queue controller
|
|
7
|
+
* following the async op -> next pattern
|
|
8
|
+
* Faces enforces for the XHR handling
|
|
9
|
+
*/
|
|
10
|
+
export class XhrQueueController<T extends IAsyncRunnable<any>> {
|
|
11
|
+
queue = [];
|
|
12
|
+
taskRunning = false;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* executes or enqueues an element
|
|
19
|
+
* @param runnable the runnable (request) to be enqueued
|
|
20
|
+
* @param timeOut timeout if > 0 which defers the execution
|
|
21
|
+
* until the debounce window for the timeout is closed.
|
|
22
|
+
*/
|
|
23
|
+
enqueue(runnable: T, timeOut: number = 0) {
|
|
24
|
+
debounce("xhrQueue", () => {
|
|
25
|
+
const requestHandler = this.enrichRunnable(runnable);
|
|
26
|
+
if (!this.taskRunning) {
|
|
27
|
+
this.signalTaskRunning();
|
|
28
|
+
requestHandler.start();
|
|
29
|
+
} else {
|
|
30
|
+
this.queue.push(requestHandler);
|
|
31
|
+
}
|
|
32
|
+
}, timeOut);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* trigger the next element in the queue
|
|
37
|
+
* to be started!
|
|
38
|
+
*/
|
|
39
|
+
next() {
|
|
40
|
+
this.updateTaskRunning();
|
|
41
|
+
const next = this.queue.shift();
|
|
42
|
+
next?.start();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* clears and resets the queue
|
|
47
|
+
*/
|
|
48
|
+
clear() {
|
|
49
|
+
this.queue.length = 0;
|
|
50
|
+
this.updateTaskRunning();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* true if queue is empty
|
|
55
|
+
*/
|
|
56
|
+
get isEmpty(): boolean {
|
|
57
|
+
return !this.queue.length;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Enriches the incoming async asyncRunnable
|
|
62
|
+
* with the error and next handling
|
|
63
|
+
* (aka: asyncRunnable is done -> next
|
|
64
|
+
* error -> clear queue
|
|
65
|
+
* @param asyncRunnable the async runnable which needs enrichment
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private enrichRunnable(asyncRunnable: T) {
|
|
69
|
+
/**
|
|
70
|
+
* we can use the Promise pattern asyncrunnable uses
|
|
71
|
+
* to trigger queue control callbacks of next element
|
|
72
|
+
* and clear the queue (theoretically this
|
|
73
|
+
* would work with any promise)
|
|
74
|
+
*/
|
|
75
|
+
try {
|
|
76
|
+
return asyncRunnable
|
|
77
|
+
.then(() => this.next())
|
|
78
|
+
.catch((e) => this.handleError(e));
|
|
79
|
+
} catch (e) {
|
|
80
|
+
this.handleError(e);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* alerts the queue that a task is running
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private signalTaskRunning() {
|
|
91
|
+
this.taskRunning = true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* updates the task running status according to the current queue
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private updateTaskRunning() {
|
|
99
|
+
this.taskRunning = !this.isEmpty;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* standard error handling
|
|
104
|
+
* we clear the queue and then bomb out
|
|
105
|
+
* @param e
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
private handleError(e) {
|
|
109
|
+
this.clear();
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -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_AJAX_SOURCE, SOURCE} from "../core/Const";
|
|
18
18
|
|
|
19
19
|
export class EventData implements IEventData{
|
|
20
20
|
type: string;
|
|
@@ -32,8 +32,8 @@ export class EventData implements IEventData{
|
|
|
32
32
|
eventData.status = name;
|
|
33
33
|
|
|
34
34
|
let sourceId: string = context.getIf(SOURCE)
|
|
35
|
-
.orElseLazy(() => context.getIf(
|
|
36
|
-
.orElseLazy(() => context.getIf(
|
|
35
|
+
.orElseLazy(() => context.getIf(P_AJAX_SOURCE).value)
|
|
36
|
+
.orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_AJAX_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
|
*
|
|
@@ -48,7 +55,7 @@ export interface IResponseProcessor {
|
|
|
48
55
|
replaceBody(shadowBody: XMLQuery | DQ): void;
|
|
49
56
|
|
|
50
57
|
/**
|
|
51
|
-
* Leaf Tag eval... process whatever is in the
|
|
58
|
+
* Leaf Tag eval... process whatever is in the evaluated cdata block
|
|
52
59
|
*
|
|
53
60
|
* @param node
|
|
54
61
|
*/
|
|
@@ -91,11 +98,11 @@ export interface IResponseProcessor {
|
|
|
91
98
|
attributes(node: XMLQuery): void;
|
|
92
99
|
|
|
93
100
|
/**
|
|
94
|
-
* replace the entire
|
|
101
|
+
* replace the entire viewRoot
|
|
95
102
|
* with shadowResponse
|
|
96
|
-
* @param
|
|
103
|
+
* @param shadowResponse
|
|
97
104
|
*/
|
|
98
|
-
replaceViewRoot(
|
|
105
|
+
replaceViewRoot(shadowResponse: XMLQuery | DQ): void;
|
|
99
106
|
|
|
100
107
|
/**
|
|
101
108
|
* jsf insert resolution
|
|
@@ -106,34 +113,34 @@ export interface IResponseProcessor {
|
|
|
106
113
|
insert(node: XMLQuery): void;
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
|
-
* insert with before, after
|
|
116
|
+
* insert with before, after sub-tags
|
|
110
117
|
* @param node
|
|
111
118
|
*/
|
|
112
|
-
|
|
119
|
+
insertWithSubTags(node: XMLQuery);
|
|
113
120
|
|
|
114
121
|
/**
|
|
115
122
|
* process the viewState update, update the affected
|
|
116
|
-
* forms with their respective new
|
|
123
|
+
* forms with their respective new viewState values
|
|
117
124
|
*
|
|
118
125
|
*/
|
|
119
126
|
processViewState(node: XMLQuery): boolean;
|
|
120
127
|
|
|
121
128
|
/**
|
|
122
129
|
* process the viewState update, update the affected
|
|
123
|
-
* forms with their respective new
|
|
130
|
+
* forms with their respective new viewState values
|
|
124
131
|
*
|
|
125
132
|
*/
|
|
126
133
|
processClientWindow(node: XMLQuery): boolean;
|
|
127
134
|
|
|
128
135
|
|
|
129
136
|
/**
|
|
130
|
-
*
|
|
137
|
+
* Eval - all processed elements so far
|
|
131
138
|
* and executes the embedded scripts
|
|
132
139
|
*/
|
|
133
140
|
globalEval(): void;
|
|
134
141
|
|
|
135
142
|
/**
|
|
136
|
-
* fix the
|
|
143
|
+
* fix the viewStates of all processed forms
|
|
137
144
|
*/
|
|
138
145
|
fixViewStates(): void;
|
|
139
146
|
|
|
@@ -142,4 +149,11 @@ export interface IResponseProcessor {
|
|
|
142
149
|
* send last event
|
|
143
150
|
*/
|
|
144
151
|
done(): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* update internal state to
|
|
155
|
+
* check whether we still are in a named view root
|
|
156
|
+
* (can change after a navigation)
|
|
157
|
+
*/
|
|
158
|
+
updateNamedViewRootState();
|
|
145
159
|
}
|