jsf.js_next_gen 4.0.0-beta-23 → 4.0.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 +7 -22
- 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 +6 -4
- package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
- package/dist/docs/functions/faces.ajax.request.html +7 -7
- package/dist/docs/functions/faces.ajax.response.html +0 -1
- 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/faces.util.chain.html +3 -3
- package/dist/docs/functions/myfaces.ab.html +9 -4
- package/dist/docs/functions/myfaces.onOnDomReady.html +72 -0
- package/dist/docs/index.html +7 -18
- package/dist/docs/modules/myfaces.html +3 -1
- package/dist/docs/variables/myfaces.oam.html +2 -1
- package/dist/window/faces-development.js +2147 -1779
- 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 +2156 -1777
- 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/pom.xml +1 -1
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +24 -7
- package/src/main/typescript/api/_api.ts +79 -37
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +168 -78
- package/src/main/typescript/impl/PushImpl.ts +63 -38
- package/src/main/typescript/impl/core/Const.ts +52 -39
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/util/AsyncRunnable.ts +4 -4
- package/src/main/typescript/impl/util/ExtDomQuery.ts +58 -45
- package/src/main/typescript/impl/util/FileUtils.ts +104 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
- package/src/main/typescript/impl/util/Lang.ts +30 -31
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +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 +202 -131
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +79 -166
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -68
- package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +19 -22
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +108 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
- 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 +242 -11
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +373 -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 +72 -31
- 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 +144 -59
- 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 +51 -38
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +58 -40
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +96 -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 +79 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +29 -30
- 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 +82 -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 +1 -1
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +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 +182 -116
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +68 -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 +68 -59
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +23 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +16 -16
- 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/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 +100 -1
- 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/xhrCore/EventTests.spec.js +1 -1
- 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 +217 -9
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +308 -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/target/types/index.js +0 -18
- package/target/types/index.js.map +0 -1
|
@@ -20,19 +20,16 @@ import {XhrRequest} from "./xhrCore/XhrRequest";
|
|
|
20
20
|
import {AsynchronousQueue} from "./util/AsyncQueue";
|
|
21
21
|
import {AssocArrayCollector, Config, DQ, Lang, LazyStream, Optional, Stream} from "mona-dish";
|
|
22
22
|
import {Assertions} from "./util/Assertions";
|
|
23
|
-
import {
|
|
24
|
-
import {ExtDomquery} from "./util/ExtDomQuery";
|
|
23
|
+
import {ExtConfig, ExtDomQuery} from "./util/ExtDomQuery";
|
|
25
24
|
import {ErrorData} from "./xhrCore/ErrorData";
|
|
26
25
|
import {EventData} from "./xhrCore/EventData";
|
|
27
26
|
import {ExtLang} from "./util/Lang";
|
|
28
27
|
|
|
29
28
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
CTX_PARAM_PASS_THR,
|
|
29
|
+
CTX_OPTIONS_EXECUTE,
|
|
30
|
+
CTX_PARAM_REQ_PASS_THR,
|
|
33
31
|
CTX_PARAM_SRC_CTL_ID,
|
|
34
32
|
CTX_PARAM_SRC_FRM_ID,
|
|
35
|
-
CTX_PARAM_TR_TYPE,
|
|
36
33
|
IDENT_ALL,
|
|
37
34
|
IDENT_FORM,
|
|
38
35
|
IDENT_NONE,
|
|
@@ -49,19 +46,23 @@ import {
|
|
|
49
46
|
P_RESET_VALUES,
|
|
50
47
|
P_WINDOW_ID,
|
|
51
48
|
CTX_PARAM_RENDER,
|
|
52
|
-
REQ_TYPE_POST,
|
|
53
49
|
SOURCE,
|
|
54
|
-
|
|
50
|
+
HTML_TAG_FORM,
|
|
51
|
+
CTX_OPTIONS_PARAMS,
|
|
52
|
+
VIEW_ID,
|
|
53
|
+
$faces,
|
|
54
|
+
EMPTY_STR,
|
|
55
|
+
CTX_PARAM_MF_INTERNAL,
|
|
56
|
+
NAMED_VIEWROOT,
|
|
57
|
+
NAMING_CONTAINER_ID
|
|
55
58
|
} from "./core/Const";
|
|
56
59
|
import {
|
|
57
60
|
resolveDefaults,
|
|
58
61
|
resolveDelay,
|
|
59
62
|
resolveForm,
|
|
60
|
-
resolveTimeout
|
|
63
|
+
resolveTimeout, resolveViewId, resolveViewRootId, resoveNamingContainerMapper
|
|
61
64
|
} from "./xhrCore/RequestDataResolver";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
declare var faces: any;
|
|
65
|
+
import {encodeFormData} from "./util/FileUtils";
|
|
65
66
|
|
|
66
67
|
/*
|
|
67
68
|
* allowed project stages
|
|
@@ -74,8 +75,8 @@ enum ProjectStages {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
/*
|
|
77
|
-
*
|
|
78
|
-
* will not be transmitted from the options into the
|
|
78
|
+
* Block-filter for the pass-through filtering; the attributes given here
|
|
79
|
+
* will not be transmitted from the options into the pass-through
|
|
79
80
|
*/
|
|
80
81
|
enum BlockFilter {
|
|
81
82
|
onerror = "onerror",
|
|
@@ -85,7 +86,9 @@ enum BlockFilter {
|
|
|
85
86
|
myfaces = "myfaces",
|
|
86
87
|
delay = "delay",
|
|
87
88
|
timeout = "timeout",
|
|
88
|
-
|
|
89
|
+
resetValues = "resetValues",
|
|
90
|
+
windowId = "windowId",
|
|
91
|
+
params = "params"
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
/**
|
|
@@ -109,11 +112,15 @@ export module Implementation {
|
|
|
109
112
|
a) Monad like structures for querying because this keeps the code denser and adds abstractions
|
|
110
113
|
that always was the strong point of jquery and it still is better in this regard than what ecmascript provides
|
|
111
114
|
|
|
112
|
-
b) Streams and
|
|
115
|
+
b) Streams and lazy streams like java has, a pull stream construct, ecmascript does not have anything like it.
|
|
116
|
+
(it has array filters and maps, but ES2015 does not support flatMap)
|
|
113
117
|
Another option would have been rxjs but that would have introduced a code dependency and probably more code. We might
|
|
114
|
-
move to RXJS if the need arises however. But for now I would rather stick with my small self grown library which works
|
|
118
|
+
move to RXJS if the need arises, however. But for now I would rather stick with my small self grown library which works
|
|
115
119
|
quite well and where I can patch quickly (I have used it in several industrial projects, so it works well
|
|
116
120
|
and is heavily fortified by unit tests (140 testcases as time of writing this))
|
|
121
|
+
The long term plan is to eliminate the Stream usage as soon as we can move up to ES2019 (adding the missing
|
|
122
|
+
functions as shims, is a no go, because we are a library, and absolutey do not Shim anything which can leak
|
|
123
|
+
into the global namespace!)
|
|
117
124
|
|
|
118
125
|
c) A neutral json like configuration which allows assignments of arbitrary values with reduce code which then can be
|
|
119
126
|
transformed into different data representations
|
|
@@ -167,21 +174,9 @@ export module Implementation {
|
|
|
167
174
|
export function getSeparatorChar(): string {
|
|
168
175
|
return resolveGlobalConfig()?.separator ??
|
|
169
176
|
this?.separator ??
|
|
170
|
-
(separator =
|
|
177
|
+
(separator = ExtDomQuery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
|
|
171
178
|
}
|
|
172
179
|
|
|
173
|
-
/**
|
|
174
|
-
* fetches the separator char from the given script tags
|
|
175
|
-
*
|
|
176
|
-
* @return {string} the separator char for the given script tags
|
|
177
|
-
*/
|
|
178
|
-
export function getContextPath(): string {
|
|
179
|
-
return resolveGlobalConfig()?.separator ??
|
|
180
|
-
this?.separator ??
|
|
181
|
-
(separator = ExtDomquery.searchJsfJsFor(/separator=([^&;]*)/).orElse(":").value);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
180
|
/**
|
|
186
181
|
* this is for testing purposes only, since AjaxImpl is a module
|
|
187
182
|
* we need to reset for every unit test its internal states
|
|
@@ -197,7 +192,7 @@ export module Implementation {
|
|
|
197
192
|
/**
|
|
198
193
|
* @return the project stage also emitted by the server:
|
|
199
194
|
* it cannot be cached and must be delivered over the server
|
|
200
|
-
* The value for it comes from the
|
|
195
|
+
* The value for it comes from the request parameter of the faces.js script called "stage".
|
|
201
196
|
*/
|
|
202
197
|
export function getProjectStage(): string | null {
|
|
203
198
|
return resolveGlobalConfig()?.projectStage ??
|
|
@@ -212,8 +207,8 @@ export module Implementation {
|
|
|
212
207
|
export function resolveProjectStateFromURL(): string | null {
|
|
213
208
|
|
|
214
209
|
/* run through all script tags and try to find the one that includes faces.js */
|
|
215
|
-
const foundStage =
|
|
216
|
-
return (foundStage in ProjectStages) ? foundStage :
|
|
210
|
+
const foundStage = ExtDomQuery.searchJsfJsFor(/stage=([^&;]*)/).value as string;
|
|
211
|
+
return (foundStage in ProjectStages) ? foundStage : ProjectStages.Production; // MYFACES-4572: default is production
|
|
217
212
|
}
|
|
218
213
|
|
|
219
214
|
/**
|
|
@@ -223,7 +218,7 @@ export module Implementation {
|
|
|
223
218
|
* @param event
|
|
224
219
|
* @param funcs
|
|
225
220
|
*/
|
|
226
|
-
export function chain(source:
|
|
221
|
+
export function chain(source: HTMLElement | string, event: Event | null, ...funcs: EvalFuncs): boolean {
|
|
227
222
|
// we can use our lazy stream each functionality to run our chain here..
|
|
228
223
|
// by passing a boolean as return value into the onElem call
|
|
229
224
|
// we can stop early at the first false, just like the spec requests
|
|
@@ -257,15 +252,14 @@ export module Implementation {
|
|
|
257
252
|
export function request(el: ElemDef, event?: Event, opts ?: Options) {
|
|
258
253
|
|
|
259
254
|
const {
|
|
260
|
-
resolvedEvent,
|
|
261
255
|
options,
|
|
262
256
|
elem,
|
|
263
257
|
elementId,
|
|
264
|
-
requestCtx,
|
|
265
|
-
internalCtx,
|
|
266
258
|
windowId,
|
|
267
259
|
isResetValues
|
|
268
260
|
} = resolveDefaults(event, opts, el);
|
|
261
|
+
const requestCtx = new ExtConfig({});
|
|
262
|
+
const internalCtx = new ExtConfig({});
|
|
269
263
|
|
|
270
264
|
Assertions.assertRequestIntegrity(options, elem);
|
|
271
265
|
|
|
@@ -276,15 +270,28 @@ export module Implementation {
|
|
|
276
270
|
* so that people can use dummy forms and work
|
|
277
271
|
* with detached objects
|
|
278
272
|
*/
|
|
279
|
-
const form: DQ = resolveForm(
|
|
273
|
+
const form: DQ = resolveForm(elem, event);
|
|
274
|
+
const viewId: string = resolveViewId(form);
|
|
280
275
|
const formId = form.id.value;
|
|
281
276
|
const delay: number = resolveDelay(options);
|
|
282
277
|
const timeout: number = resolveTimeout(options);
|
|
283
278
|
|
|
284
279
|
requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;
|
|
285
280
|
|
|
286
|
-
|
|
287
|
-
requestCtx.
|
|
281
|
+
// old non spec behavior will be removed after it is clear whether the removal breaks any code
|
|
282
|
+
requestCtx.assign(CTX_PARAM_REQ_PASS_THR).value = extractLegacyParams(options.value);
|
|
283
|
+
|
|
284
|
+
// spec conform behavior, all passthrough params must be under "passthrough
|
|
285
|
+
const params = remapArrayToAssocArr(options.getIf(CTX_OPTIONS_PARAMS).orElse({}).value);
|
|
286
|
+
//we turn off the remapping for the param merge, because we do not want to have
|
|
287
|
+
//any namespacing to be remapped
|
|
288
|
+
|
|
289
|
+
let ctxPassthrough = requestCtx.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
|
|
290
|
+
ctxPassthrough.$nspEnabled = false;
|
|
291
|
+
ctxPassthrough.shallowMerge(new Config(params), true);
|
|
292
|
+
//now we turn it on again
|
|
293
|
+
ctxPassthrough.$nspEnabled = true;
|
|
294
|
+
requestCtx.assignIf(!!event, CTX_PARAM_REQ_PASS_THR, P_EVT).value = event?.type;
|
|
288
295
|
|
|
289
296
|
/**
|
|
290
297
|
* ajax pass through context with the source
|
|
@@ -292,6 +299,8 @@ export module Implementation {
|
|
|
292
299
|
*/
|
|
293
300
|
requestCtx.assign(SOURCE).value = elementId;
|
|
294
301
|
|
|
302
|
+
requestCtx.assign(VIEW_ID).value = viewId;
|
|
303
|
+
|
|
295
304
|
/**
|
|
296
305
|
* on resolvedEvent and onError...
|
|
297
306
|
* those values will be traversed later on
|
|
@@ -308,12 +317,12 @@ export module Implementation {
|
|
|
308
317
|
/**
|
|
309
318
|
* binding contract the jakarta.faces.source must be set
|
|
310
319
|
*/
|
|
311
|
-
requestCtx.assign(
|
|
320
|
+
requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
|
|
312
321
|
|
|
313
322
|
/**
|
|
314
323
|
* jakarta.faces.partial.ajax must be set to true
|
|
315
324
|
*/
|
|
316
|
-
requestCtx.assign(
|
|
325
|
+
requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_AJAX).value = true;
|
|
317
326
|
|
|
318
327
|
/**
|
|
319
328
|
* if resetValues is set to true
|
|
@@ -322,7 +331,7 @@ export module Implementation {
|
|
|
322
331
|
* the value has to be explicitly true, according to
|
|
323
332
|
* the specs jsdoc
|
|
324
333
|
*/
|
|
325
|
-
requestCtx.assignIf(isResetValues,
|
|
334
|
+
requestCtx.assignIf(isResetValues, CTX_PARAM_REQ_PASS_THR, P_RESET_VALUES).value = true;
|
|
326
335
|
|
|
327
336
|
// additional meta information to speed things up, note internal non jsf
|
|
328
337
|
// pass through options are stored under _mfInternal in the context
|
|
@@ -333,13 +342,13 @@ export module Implementation {
|
|
|
333
342
|
// mojarra under blackbox conditions.
|
|
334
343
|
// I assume it does the same as our formId_submit=1 so leaving it out
|
|
335
344
|
// won't hurt but for the sake of compatibility we are going to add it
|
|
336
|
-
requestCtx.assign(
|
|
345
|
+
requestCtx.assign(CTX_PARAM_REQ_PASS_THR, formId).value = formId;
|
|
337
346
|
internalCtx.assign(CTX_PARAM_SRC_CTL_ID).value = elementId;
|
|
338
|
-
internalCtx.assign(CTX_PARAM_TR_TYPE).value = REQ_TYPE_POST;
|
|
339
347
|
|
|
340
348
|
assignClientWindowId(form, requestCtx);
|
|
341
349
|
assignExecute(options, requestCtx, form, elementId);
|
|
342
350
|
assignRender(options, requestCtx, form, elementId);
|
|
351
|
+
assignNamingContainerData(internalCtx, form);
|
|
343
352
|
|
|
344
353
|
//now we enqueue the request as asynchronous runnable into our request
|
|
345
354
|
//queue and let the queue take over the rest
|
|
@@ -455,17 +464,17 @@ export module Implementation {
|
|
|
455
464
|
const ALTERED = "___mf_id_altered__";
|
|
456
465
|
const INIT = "___init____";
|
|
457
466
|
|
|
458
|
-
|
|
467
|
+
/*
|
|
459
468
|
* the search root for the dom element search
|
|
460
469
|
*/
|
|
461
470
|
let searchRoot = new DQ(node || document.body).querySelectorAll(`form input [name='${P_CLIENT_WINDOW}']`);
|
|
462
471
|
|
|
463
|
-
|
|
472
|
+
/*
|
|
464
473
|
* lazy helper to fetch the window id from the window url
|
|
465
474
|
*/
|
|
466
|
-
let fetchWindowIdFromUrl = () =>
|
|
475
|
+
let fetchWindowIdFromUrl = () => ExtDomQuery.searchJsfJsFor(/jfwid=([^&;]*)/).orElse(null).value;
|
|
467
476
|
|
|
468
|
-
|
|
477
|
+
/*
|
|
469
478
|
* functional double check based on stream reduction
|
|
470
479
|
* the values should be identical or on INIT value which is a premise to
|
|
471
480
|
* skip the first check
|
|
@@ -482,27 +491,26 @@ export module Implementation {
|
|
|
482
491
|
return value2;
|
|
483
492
|
};
|
|
484
493
|
|
|
485
|
-
|
|
494
|
+
/*
|
|
486
495
|
* helper for cleaner code, maps the value from an item
|
|
487
496
|
*
|
|
488
497
|
* @param item
|
|
489
498
|
*/
|
|
490
499
|
let getValue = (item: DQ) => item.attr("value").value;
|
|
491
|
-
|
|
500
|
+
/*
|
|
492
501
|
* fetch the window id from the forms
|
|
493
502
|
* window ids must be present in all forms
|
|
494
|
-
* or non
|
|
503
|
+
* or non-existent. If they exist all of them must be the same
|
|
495
504
|
*/
|
|
496
505
|
|
|
497
|
-
let formWindowId: Optional<string> = searchRoot.stream.map
|
|
506
|
+
let formWindowId: Optional<string> = searchRoot.stream.map(getValue).reduce(differenceCheck, INIT);
|
|
498
507
|
|
|
499
508
|
|
|
500
509
|
//if the resulting window id is set on altered then we have an unresolvable problem
|
|
501
510
|
assert(ALTERED != formWindowId.value, "Multiple different windowIds found in document");
|
|
502
511
|
|
|
503
|
-
|
|
512
|
+
/*
|
|
504
513
|
* return the window id or null
|
|
505
|
-
* prio, forms under node/document and if not given then from the url
|
|
506
514
|
*/
|
|
507
515
|
return formWindowId.value != INIT ? formWindowId.value : fetchWindowIdFromUrl();
|
|
508
516
|
}
|
|
@@ -517,17 +525,23 @@ export module Implementation {
|
|
|
517
525
|
*/
|
|
518
526
|
export function getViewState(form: Element | string): string {
|
|
519
527
|
/**
|
|
520
|
-
*
|
|
528
|
+
* type-check assert!, we opt for strong typing here
|
|
521
529
|
* because it makes it easier to detect bugs
|
|
522
530
|
*/
|
|
523
531
|
|
|
524
532
|
let element: DQ = DQ.byId(form, true);
|
|
525
|
-
if (!element.isTag(
|
|
533
|
+
if (!element.isTag(HTML_TAG_FORM)) {
|
|
526
534
|
throw new Error(getMessage("ERR_VIEWSTATE"));
|
|
527
535
|
}
|
|
528
536
|
|
|
529
|
-
|
|
530
|
-
|
|
537
|
+
// determine the naming container scenario
|
|
538
|
+
const dummyContext = new Config({});
|
|
539
|
+
assignNamingContainerData(dummyContext, DQ.byId(form))
|
|
540
|
+
// fetch all non file input form elements
|
|
541
|
+
let formElements = element.deepElements.encodeFormElement()
|
|
542
|
+
|
|
543
|
+
// encode them! (file inputs are handled differently and are not part of the viewstate)
|
|
544
|
+
return encodeFormData(formElements, resoveNamingContainerMapper(dummyContext));
|
|
531
545
|
}
|
|
532
546
|
|
|
533
547
|
/**
|
|
@@ -537,11 +551,11 @@ export module Implementation {
|
|
|
537
551
|
*/
|
|
538
552
|
export let queueHandler = {
|
|
539
553
|
/**
|
|
540
|
-
* public to make it
|
|
554
|
+
* public to make it accessible for tests
|
|
541
555
|
*
|
|
542
556
|
* adds a new request to our queue for further processing
|
|
543
557
|
*/
|
|
544
|
-
addRequestToQueue: function (elem: DQ, form: DQ, reqCtx:
|
|
558
|
+
addRequestToQueue: function (elem: DQ, form: DQ, reqCtx: ExtConfig, respPassThr: Config, delay = 0, timeout = 0) {
|
|
545
559
|
requestQueue = requestQueue ?? new AsynchronousQueue<XhrRequest>();
|
|
546
560
|
requestQueue.enqueue(new XhrRequest(elem, form, reqCtx, respPassThr, [], timeout), delay);
|
|
547
561
|
}
|
|
@@ -563,7 +577,7 @@ export module Implementation {
|
|
|
563
577
|
*/
|
|
564
578
|
function assignRender(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
|
|
565
579
|
if (requestOptions.getIf(CTX_PARAM_RENDER).isPresent()) {
|
|
566
|
-
remapDefaultConstants(targetContext.getIf(
|
|
580
|
+
remapDefaultConstants(targetContext.getIf(CTX_PARAM_REQ_PASS_THR).get({}), P_RENDER, <string>requestOptions.getIf(CTX_PARAM_RENDER).value, issuingForm, <any>sourceElementId, targetContext.getIf(VIEW_ID).value);
|
|
567
581
|
}
|
|
568
582
|
}
|
|
569
583
|
|
|
@@ -581,15 +595,15 @@ export module Implementation {
|
|
|
581
595
|
*/
|
|
582
596
|
function assignExecute(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
|
|
583
597
|
|
|
584
|
-
if (requestOptions.getIf(
|
|
598
|
+
if (requestOptions.getIf(CTX_OPTIONS_EXECUTE).isPresent()) {
|
|
585
599
|
/*the options must be a blank delimited list of strings*/
|
|
586
600
|
/*compliance with Mojarra which automatically adds @this to an execute
|
|
587
601
|
* the spec rev 2.0a however states, if none is issued nothing at all should be sent down
|
|
588
602
|
*/
|
|
589
|
-
requestOptions.assign(
|
|
590
|
-
remapDefaultConstants(targetContext.getIf(
|
|
603
|
+
requestOptions.assign(CTX_OPTIONS_EXECUTE).value = [requestOptions.getIf(CTX_OPTIONS_EXECUTE).value, IDENT_THIS].join(" ");
|
|
604
|
+
remapDefaultConstants(targetContext.getIf(CTX_PARAM_REQ_PASS_THR).get({}), P_EXECUTE, <string>requestOptions.getIf(CTX_OPTIONS_EXECUTE).value, issuingForm, <any>sourceElementId, targetContext.getIf(VIEW_ID).value);
|
|
591
605
|
} else {
|
|
592
|
-
targetContext.assign(
|
|
606
|
+
targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value = sourceElementId;
|
|
593
607
|
}
|
|
594
608
|
}
|
|
595
609
|
|
|
@@ -601,16 +615,33 @@ export module Implementation {
|
|
|
601
615
|
*/
|
|
602
616
|
function assignClientWindowId(form: DQ, targetContext: Config) {
|
|
603
617
|
|
|
604
|
-
let clientWindow = (
|
|
618
|
+
let clientWindow = $faces().getClientWindow(form.getAsElem(0).value);
|
|
605
619
|
if (clientWindow) {
|
|
606
|
-
targetContext.assign(
|
|
620
|
+
targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* determines the current naming container
|
|
626
|
+
* and assigns it internally
|
|
627
|
+
*
|
|
628
|
+
* @param internalContext
|
|
629
|
+
* @param formElement
|
|
630
|
+
* @private
|
|
631
|
+
*/
|
|
632
|
+
function assignNamingContainerData(internalContext: Config, formElement: DQ) {
|
|
633
|
+
const viewRootId = resolveViewRootId(formElement);
|
|
634
|
+
|
|
635
|
+
if(!!viewRootId) {
|
|
636
|
+
internalContext.assign(NAMED_VIEWROOT).value = true;
|
|
637
|
+
internalContext.assign(NAMING_CONTAINER_ID).value = viewRootId;
|
|
607
638
|
}
|
|
608
639
|
}
|
|
609
640
|
|
|
610
641
|
/**
|
|
611
642
|
* transforms the user values to the expected one
|
|
612
643
|
* with the proper none all form and this handling
|
|
613
|
-
* (note we also could use a simple string replace but then
|
|
644
|
+
* (note we also could use a simple string replace, but then
|
|
614
645
|
* we would have had double entries under some circumstances)
|
|
615
646
|
*
|
|
616
647
|
* there are several standardized constants which need a special treatment
|
|
@@ -621,14 +652,60 @@ export module Implementation {
|
|
|
621
652
|
* @param userValues the passed user values (aka input string which needs to be transformed)
|
|
622
653
|
* @param issuingForm the form where the issuing element originates
|
|
623
654
|
* @param issuingElementId the issuing element
|
|
655
|
+
* @param rootNamingContainerId the naming container id ("" default if none is given)
|
|
624
656
|
*/
|
|
625
|
-
function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string): Config {
|
|
657
|
+
function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string, rootNamingContainerId: string = ""): Config {
|
|
626
658
|
//a cleaner implementation of the transform list method
|
|
627
|
-
|
|
659
|
+
const SEP = $faces().separatorchar;
|
|
628
660
|
let iterValues: string[] = (userValues) ? trim(userValues).split(/\s+/gi) : [];
|
|
629
661
|
let ret = [];
|
|
630
662
|
let processed: {[key: string]: boolean} = {};
|
|
631
663
|
|
|
664
|
+
/**
|
|
665
|
+
* remaps the client ids for the portlet case so that the server
|
|
666
|
+
* can deal with them either prefixed ir not
|
|
667
|
+
* also resolves the absolute id case (it was assumed the server does this, but
|
|
668
|
+
* apparently the RI does not, so we have to follow the RI behavior here)
|
|
669
|
+
* @param componentIdToTransform the componentId which needs post processing
|
|
670
|
+
*/
|
|
671
|
+
const remapNamingContainer = componentIdToTransform => {
|
|
672
|
+
// pattern :<anything> must be prepended by viewRoot if there is one,
|
|
673
|
+
// otherwise we are in a not namespaced then only the id has to match
|
|
674
|
+
const rootNamingContainerPrefix = (rootNamingContainerId.length) ? rootNamingContainerId+SEP : EMPTY_STR;
|
|
675
|
+
let formClientId = issuingForm.id.value;
|
|
676
|
+
// nearest parent naming container relative to the form
|
|
677
|
+
const nearestNamingContainer = formClientId.substring(0, formClientId.lastIndexOf(SEP));
|
|
678
|
+
const nearestNamingContainerPrefix = (nearestNamingContainer.length) ? nearestNamingContainer + SEP : EMPTY_STR;
|
|
679
|
+
// Absolute search expressions, always start with SEP or the name of the root naming container
|
|
680
|
+
const hasLeadingSep = componentIdToTransform.indexOf(SEP) === 0;
|
|
681
|
+
const isAbsolutSearchExpr = hasLeadingSep || (rootNamingContainerId.length
|
|
682
|
+
&& componentIdToTransform.indexOf(rootNamingContainerPrefix) == 0);
|
|
683
|
+
let finalIdentifier = "";
|
|
684
|
+
if (isAbsolutSearchExpr) {
|
|
685
|
+
//we cut off the leading sep if there is one
|
|
686
|
+
componentIdToTransform = hasLeadingSep ? componentIdToTransform.substring(1) : componentIdToTransform;
|
|
687
|
+
componentIdToTransform = componentIdToTransform.indexOf(rootNamingContainerPrefix) == 0 ? componentIdToTransform.substring(rootNamingContainerPrefix.length) : componentIdToTransform;
|
|
688
|
+
//now we prepend either the prefix or "" from the cut-off string to get the final result
|
|
689
|
+
finalIdentifier = [rootNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR);
|
|
690
|
+
} else { //relative search according to the javadoc
|
|
691
|
+
//we cut off the root naming container id from the form
|
|
692
|
+
if (formClientId.indexOf(rootNamingContainerPrefix) == 0) {
|
|
693
|
+
formClientId = formClientId.substring(rootNamingContainerPrefix.length);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
//If prependId = true, the outer form id must be present in the id if same form
|
|
697
|
+
let hasPrependId = componentIdToTransform.indexOf(formClientId) == 0;
|
|
698
|
+
finalIdentifier = hasPrependId ?
|
|
699
|
+
[rootNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR) :
|
|
700
|
+
[nearestNamingContainerPrefix, componentIdToTransform].join(EMPTY_STR);
|
|
701
|
+
}
|
|
702
|
+
// We need to double check because we have scenarios where we have a naming container
|
|
703
|
+
// and no prepend (aka tobago testcase "must handle ':' in IDs properly", scenario 3,
|
|
704
|
+
// in this case we return the component id, and be happy
|
|
705
|
+
// we can roll a dom check here
|
|
706
|
+
return (!!document.getElementById(finalIdentifier)) ? finalIdentifier : componentIdToTransform;
|
|
707
|
+
};
|
|
708
|
+
|
|
632
709
|
// in this case we do not use lazy stream because it wont bring any code reduction
|
|
633
710
|
// or speedup
|
|
634
711
|
for (let cnt = 0; cnt < iterValues.length; cnt++) {
|
|
@@ -646,33 +723,39 @@ export module Implementation {
|
|
|
646
723
|
return targetConfig;
|
|
647
724
|
//@form pushes the issuing form id into our list
|
|
648
725
|
case IDENT_FORM:
|
|
649
|
-
ret.push(issuingForm.id.value);
|
|
726
|
+
ret.push(remapNamingContainer(issuingForm.id.value));
|
|
650
727
|
processed[issuingForm.id.value] = true;
|
|
651
728
|
break;
|
|
652
729
|
//@this is replaced with the current issuing element id
|
|
653
730
|
case IDENT_THIS:
|
|
654
731
|
if (!(issuingElementId in processed)) {
|
|
655
|
-
ret.push(issuingElementId);
|
|
732
|
+
ret.push(remapNamingContainer(issuingElementId));
|
|
656
733
|
processed[issuingElementId] = true;
|
|
657
734
|
}
|
|
658
735
|
break;
|
|
659
736
|
default:
|
|
660
|
-
ret.push(iterValues[cnt]);
|
|
737
|
+
ret.push(remapNamingContainer(iterValues[cnt]));
|
|
661
738
|
processed[iterValues[cnt]] = true;
|
|
662
739
|
}
|
|
663
740
|
}
|
|
664
|
-
|
|
741
|
+
|
|
665
742
|
targetConfig.assign(targetKey).value = ret.join(" ");
|
|
666
743
|
return targetConfig;
|
|
667
744
|
}
|
|
668
745
|
|
|
669
746
|
/**
|
|
670
|
-
*
|
|
671
|
-
* the values required for
|
|
747
|
+
* Filter the options given with a blacklist, so that only
|
|
748
|
+
* the values required for params-through are processed in the ajax request
|
|
749
|
+
*
|
|
750
|
+
* Note this is a bug carried over from the old implementation
|
|
751
|
+
* the spec conform behavior is to use params for passthrough values
|
|
752
|
+
* this will be removed soon, after it is cleared up whether removing
|
|
753
|
+
* it breaks any legacy code
|
|
672
754
|
*
|
|
673
755
|
* @param {Context} mappedOpts the options to be filtered
|
|
756
|
+
* @deprecated
|
|
674
757
|
*/
|
|
675
|
-
function
|
|
758
|
+
function extractLegacyParams(mappedOpts: Options): Context {
|
|
676
759
|
//we now can use the full code reduction given by our stream api
|
|
677
760
|
//to filter
|
|
678
761
|
return Stream.ofAssoc(mappedOpts)
|
|
@@ -680,6 +763,13 @@ export module Implementation {
|
|
|
680
763
|
.collect(new AssocArrayCollector());
|
|
681
764
|
}
|
|
682
765
|
|
|
766
|
+
function remapArrayToAssocArr(arrayedParams: [[string, any]] | {[key: string]: any}): {[key: string]: any} {
|
|
767
|
+
if(Array.isArray(arrayedParams)) {
|
|
768
|
+
return Stream.of(... arrayedParams).collect(new AssocArrayCollector());
|
|
769
|
+
}
|
|
770
|
+
return arrayedParams;
|
|
771
|
+
}
|
|
772
|
+
|
|
683
773
|
function resolveGlobalConfig(): any {
|
|
684
774
|
return window?.[MYFACES]?.config ?? {};
|
|
685
775
|
}
|