jsf.js_next_gen 4.0.0-RC.3 → 4.0.0-RC.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/style.css +23 -0
- package/dist/window/faces-development.js +2961 -3011
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.LICENSE.txt +0 -2
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +2966 -3016
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.LICENSE.txt +0 -2
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +16 -16
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +12 -7
- package/src/main/typescript/api/_api.ts +4 -3
- package/src/main/typescript/impl/AjaxImpl.ts +125 -41
- package/src/main/typescript/impl/core/Const.ts +52 -41
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
- package/src/main/typescript/impl/util/FileUtils.ts +66 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
- package/src/main/typescript/impl/util/Lang.ts +9 -11
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +15 -1
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +69 -24
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
- package/src/main/typescript/impl/xhrCore/Response.ts +55 -38
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +173 -98
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +91 -168
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +39 -23
- package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +73 -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 -3
- 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 +70 -3
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +372 -34
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
- 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 +2 -2
- package/src/test/resources/jsf-development.js +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +16 -29
- package/target/api/_api.js.map +1 -1
- package/target/api/faces.js +4 -4
- package/target/api/faces.js.map +1 -1
- package/target/api/jsf.js +9 -9
- 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 +155 -89
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +45 -48
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +52 -40
- 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/core/ImplTypes.js +9 -14
- package/target/impl/core/ImplTypes.js.map +1 -1
- package/target/impl/i18n/Messages.js +3 -4
- package/target/impl/i18n/Messages.js.map +1 -1
- package/target/impl/util/Assertions.js +20 -24
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js +28 -36
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +153 -221
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +64 -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 +23 -32
- 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/xhrCore/ErrorData.js +41 -64
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +10 -13
- 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 +71 -27
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +16 -16
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +43 -28
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +217 -162
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +92 -208
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +104 -104
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +33 -24
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/LangTest.spec.js +46 -32
- package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +238 -228
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +45 -31
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +24 -33
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +50 -48
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +310 -132
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +235 -22
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +32 -59
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +32 -59
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/impl/SeparatorCharsTest.spec.js +17 -17
- package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
- package/target/test/myfaces/OamSubmit.spec.js +25 -25
- package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
- package/target/test/queue/AsynchronousProbe.js +23 -29
- package/target/test/queue/AsynchronousProbe.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +39 -70
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +43 -74
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FakeWebsocket.js +14 -16
- package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +48 -78
- 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 +174 -73
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +173 -149
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +127 -142
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +415 -100
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +152 -91
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/ShadowDomTest.spec.js +30 -61
- package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
- package/target/test/xhrCore/WebsocketTest.js +60 -93
- package/target/test/xhrCore/WebsocketTest.js.map +1 -1
- package/target/test/xhrCore/XhrFormDataTest.spec.js +79 -30
- 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
|
@@ -13,12 +13,20 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {ArrayCollector, Config, DQ,
|
|
17
|
-
import {EMPTY_STR, IDENT_ALL, IDENT_FORM, P_VIEWSTATE} from "../core/Const";
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
16
|
+
import {ArrayCollector, Config, DQ, Stream} from "mona-dish";
|
|
17
|
+
import {$faces, $nsp, EMPTY_STR, IDENT_ALL, IDENT_FORM, IDENT_NONE, P_VIEWSTATE} from "../core/Const";
|
|
18
|
+
import {ExtConfig} from "../util/ExtDomQuery";
|
|
19
|
+
import {
|
|
20
|
+
decodeEncodedValues,
|
|
21
|
+
encodeFormData,
|
|
22
|
+
resolveFiles,
|
|
23
|
+
fixKeyWithoutVal
|
|
24
|
+
} from "../util/FileUtils";
|
|
20
25
|
|
|
21
26
|
|
|
27
|
+
type ParamsMapper<V, K> = (key: V, item: K) => [V, K];
|
|
28
|
+
const defaultParamsMapper: ParamsMapper<string, any> = (key, item) => [key, item];
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* A unified form data class
|
|
24
32
|
* which builds upon our configuration.
|
|
@@ -29,7 +37,11 @@ import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
|
29
37
|
*
|
|
30
38
|
* probably only one needed and one overlay!
|
|
31
39
|
* the entire file input storing probably is redundant now
|
|
32
|
-
* that dom query has been fixed
|
|
40
|
+
* that dom query has been fixed
|
|
41
|
+
*
|
|
42
|
+
* internal storage format
|
|
43
|
+
* every value is stored as an array
|
|
44
|
+
* even scalar ones!
|
|
33
45
|
*/
|
|
34
46
|
export class XhrFormData extends Config {
|
|
35
47
|
/**
|
|
@@ -45,31 +57,22 @@ export class XhrFormData extends Config {
|
|
|
45
57
|
* data collector from a given form
|
|
46
58
|
*
|
|
47
59
|
* @param dataSource either a form as DomQuery object or an encoded url string
|
|
48
|
-
* @param
|
|
60
|
+
* @param paramsMapper a remapper for the params keys and values
|
|
49
61
|
* @param executes the executes id list for the elements to being processed
|
|
50
62
|
* @param partialIds partial ids to collect, to reduce the data sent down
|
|
51
63
|
*/
|
|
52
|
-
constructor(private dataSource: DQ
|
|
64
|
+
constructor(private dataSource: DQ, private paramsMapper: ParamsMapper<string, any> = defaultParamsMapper, executes?: string[], private partialIds?: string[]) {
|
|
53
65
|
super({});
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.applyFormDataToConfig();
|
|
65
|
-
}
|
|
66
|
-
//now assign the external viewstate overrides
|
|
67
|
-
if ('undefined' != typeof viewState) {
|
|
68
|
-
this.assignEncodedString(viewState)
|
|
69
|
-
}
|
|
70
|
-
if (executes) {
|
|
71
|
-
this.postInit(...executes);
|
|
72
|
-
}
|
|
66
|
+
//encode and append the issuing item if not a partial ids array of ids is passed
|
|
67
|
+
/*
|
|
68
|
+
* Spec. 13.3.1
|
|
69
|
+
* Collect and encode input elements.
|
|
70
|
+
* Additionally the hidden element jakarta.faces.ViewState
|
|
71
|
+
* Enhancement partial page submit
|
|
72
|
+
*/
|
|
73
|
+
this.resolveRequestType(this.dataSource, executes);
|
|
74
|
+
this.encodeSubmittableFields(this.dataSource, this.partialIds);
|
|
75
|
+
this.applyViewState(this.dataSource);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
/**
|
|
@@ -77,30 +80,11 @@ export class XhrFormData extends Config {
|
|
|
77
80
|
* @param executes the executable dom nodes which need to be processed into the form data, which we can send
|
|
78
81
|
* in our ajax request
|
|
79
82
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
} else if (id == IDENT_FORM) {
|
|
86
|
-
return (<DQ>this.dataSource).matchesSelector(INPUT_FILE) ?
|
|
87
|
-
(<DQ>this.dataSource) :
|
|
88
|
-
(<DQ>this.dataSource).querySelectorAllDeep(INPUT_FILE);
|
|
89
|
-
} else {
|
|
90
|
-
let element = DQ.byId(id, true);
|
|
91
|
-
return element.matchesSelector(INPUT_FILE) ? element : this.getFileInputs(element);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
let inputExists = (item: DQ) => {
|
|
96
|
-
return item.isPresent();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.isMultipartRequest = LazyStream.of(...executes)
|
|
101
|
-
.map(fetchFileInputs)
|
|
102
|
-
.filter(inputExists)
|
|
103
|
-
.first().isPresent();
|
|
83
|
+
resolveRequestType(rootElement: DQ, executes?: Array<string>) {
|
|
84
|
+
if (!executes || executes.indexOf(IDENT_NONE) != -1) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.isMultipartRequest = rootElement.isMultipartCandidate(true);
|
|
104
88
|
}
|
|
105
89
|
|
|
106
90
|
/**
|
|
@@ -109,124 +93,62 @@ export class XhrFormData extends Config {
|
|
|
109
93
|
* @param form the form holding the view state value
|
|
110
94
|
*/
|
|
111
95
|
private applyViewState(form: DQ) {
|
|
112
|
-
|
|
113
|
-
|
|
96
|
+
if (this.getIf($nsp(P_VIEWSTATE)).isPresent()) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let viewStateElement = form.querySelectorAllDeep(`[name*='${$nsp(P_VIEWSTATE)}'`);
|
|
100
|
+
let viewState = viewStateElement.inputValue;
|
|
101
|
+
this.appendIf(viewState.isPresent(), this.remapKeyForNamingContainer(viewStateElement.name.value)).value = viewState.value;
|
|
114
102
|
}
|
|
115
103
|
|
|
116
|
-
/**
|
|
117
|
-
* assigns an url encoded string to this xhrFormData object
|
|
118
|
-
* as key value entry
|
|
119
|
-
* @param encoded
|
|
120
|
-
*/
|
|
121
|
-
assignEncodedString(encoded: string) {
|
|
122
|
-
// this code filters out empty strings as key value pairs
|
|
123
|
-
let keyValueEntries = decodeURIComponent(encoded).split(/&/gi)
|
|
124
|
-
.filter(item => !!(item || '')
|
|
125
|
-
.replace(/\s+/g, ''));
|
|
126
|
-
this.assignString(keyValueEntries);
|
|
127
|
-
}
|
|
128
104
|
|
|
129
105
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @param keyValueEntries
|
|
106
|
+
* @returns a Form data representation, this is needed for file submits
|
|
132
107
|
*/
|
|
133
|
-
|
|
134
|
-
let
|
|
108
|
+
toFormData(): FormData {
|
|
109
|
+
let ret: any = new FormData();
|
|
135
110
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
111
|
+
/*
|
|
112
|
+
* expands key: [item1, item2]
|
|
113
|
+
* to: [{key: item1}, {key, item2}]
|
|
114
|
+
*/
|
|
115
|
+
let expandArrayedData = ([key, item]) =>
|
|
116
|
+
Stream.of(...(item as Array<any>)).map(item => {
|
|
117
|
+
return {key, item};
|
|
118
|
+
});
|
|
139
119
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
120
|
+
/*
|
|
121
|
+
* remaps the incoming {key, value} tuples
|
|
122
|
+
* to naming container prefixed keys and values
|
|
123
|
+
*/
|
|
124
|
+
let remapForNamingContainer = ({key, item}) => {
|
|
125
|
+
key = this.remapKeyForNamingContainer(key);
|
|
126
|
+
return {key, item}
|
|
127
|
+
};
|
|
143
128
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
toMerge.append(keyVal[0] as string).value = keyVal?.splice(1)?.join("") ?? "";
|
|
151
|
-
});
|
|
152
|
-
//merge with overwrite but no append! (aka no double entries are allowed)
|
|
153
|
-
this.shallowMerge(toMerge);
|
|
154
|
-
}
|
|
129
|
+
/*
|
|
130
|
+
* collects everything into a FormData object
|
|
131
|
+
*/
|
|
132
|
+
let collectFormData = ({key, item}) => {
|
|
133
|
+
ret.append(key, item)
|
|
134
|
+
};
|
|
155
135
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
let ret: any = new FormData();
|
|
161
|
-
this.appendInputs(ret);
|
|
136
|
+
Stream.ofAssoc(this.value)
|
|
137
|
+
.flatMap(expandArrayedData)
|
|
138
|
+
.map(remapForNamingContainer)
|
|
139
|
+
.each(collectFormData)
|
|
162
140
|
return ret;
|
|
163
141
|
}
|
|
164
142
|
|
|
165
|
-
resolveSubmitIdentifier(elem: HTMLInputElement) {
|
|
166
|
-
let identifier = elem.name;
|
|
167
|
-
identifier = ((elem?.name ?? "").replace(/s+/gi, "") == "") ? elem.id : identifier;
|
|
168
|
-
return identifier;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
143
|
/**
|
|
172
144
|
* returns an encoded string representation of our xhr form data
|
|
173
145
|
*
|
|
174
146
|
* @param defaultStr optional default value if nothing is there to encode
|
|
175
147
|
*/
|
|
176
148
|
toString(defaultStr = EMPTY_STR): string {
|
|
177
|
-
|
|
178
|
-
return defaultStr;
|
|
179
|
-
}
|
|
180
|
-
let entries = LazyStream.of(...Object.keys(this.value))
|
|
181
|
-
.filter(key => this.value.hasOwnProperty(key))
|
|
182
|
-
.flatMap(key => Stream.of(...this.value[key]).map(val => [key, val])
|
|
183
|
-
//we cannot encode file elements that is handled by multipart requests anyway
|
|
184
|
-
.filter(([, value]) => !(value instanceof ExtDomQuery.global().File))
|
|
185
|
-
.collect(new ArrayCollector()))
|
|
186
|
-
|
|
187
|
-
.map(keyVal => {
|
|
188
|
-
return `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
|
|
189
|
-
})
|
|
190
|
-
.collect(new ArrayCollector());
|
|
191
|
-
|
|
192
|
-
return entries.join("&")
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* helper to fetch all file inputs from as given root element
|
|
197
|
-
* @param rootElement
|
|
198
|
-
* @private
|
|
199
|
-
*/
|
|
200
|
-
private getFileInputs(rootElement: DQ): DQ {
|
|
201
|
-
const rootFileInputs = rootElement
|
|
202
|
-
.filter(elem => elem.matchesSelector("input[type='file']"))
|
|
203
|
-
const childFileInputs = rootElement
|
|
204
|
-
.querySelectorAll("input[type='file']");
|
|
205
|
-
|
|
206
|
-
return rootFileInputs.concat(childFileInputs);
|
|
149
|
+
return encodeFormData(this, this.paramsMapper, defaultStr);
|
|
207
150
|
}
|
|
208
151
|
|
|
209
|
-
/**
|
|
210
|
-
* encode the given fields and apply the view state
|
|
211
|
-
* @private
|
|
212
|
-
*/
|
|
213
|
-
private applyFormDataToConfig() {
|
|
214
|
-
//encode and append the issuing item if not a partial ids array of ids is passed
|
|
215
|
-
/*
|
|
216
|
-
* Spec. 13.3.1
|
|
217
|
-
* Collect and encode input elements.
|
|
218
|
-
* Additionally the hidden element jakarta.faces.ViewState
|
|
219
|
-
* Enhancement partial page submit
|
|
220
|
-
*
|
|
221
|
-
*/
|
|
222
|
-
this.encodeSubmittableFields(this, <DQ>this.dataSource, this.partialIds);
|
|
223
|
-
|
|
224
|
-
if (this.getIf(P_VIEWSTATE).isPresent()) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
this.applyViewState(<DQ>this.dataSource);
|
|
229
|
-
}
|
|
230
152
|
|
|
231
153
|
/**
|
|
232
154
|
* determines fields to submit
|
|
@@ -234,28 +156,29 @@ export class XhrFormData extends Config {
|
|
|
234
156
|
* @param {Node} parentItem - form element item is nested in
|
|
235
157
|
* @param {Array} partialIds - ids fo PPS
|
|
236
158
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
159
|
+
public encodeSubmittableFields(parentItem: DQ, partialIds ?: string[]) {
|
|
160
|
+
//encoded String
|
|
161
|
+
const viewStateStr = $faces().getViewState(parentItem.getAsElem(0).value);
|
|
162
|
+
|
|
163
|
+
// we now need to decode it and then merge it into the target buf
|
|
164
|
+
// which hosts already our overrides (aka do not override what is already there(
|
|
165
|
+
// after that we need to deal with form elements on a separate level
|
|
166
|
+
const keyValueEntries: Stream<string[] | [string, File]> = decodeEncodedValues(viewStateStr);
|
|
167
|
+
const fileEntries = resolveFiles(parentItem);
|
|
168
|
+
const concatted = keyValueEntries.concat(fileEntries as any)
|
|
169
|
+
const formData = new ExtConfig({});
|
|
170
|
+
|
|
171
|
+
concatted
|
|
172
|
+
.map(fixKeyWithoutVal)
|
|
173
|
+
.map(keyVal => this.paramsMapper(keyVal[0] as string, keyVal[1]))
|
|
174
|
+
.each((entry) => {
|
|
175
|
+
formData.append(entry[0]).value = entry[1];
|
|
176
|
+
});
|
|
250
177
|
|
|
251
|
-
|
|
252
|
-
this.shallowMerge(toEncode.deepElements.encodeFormElement());
|
|
178
|
+
this.shallowMerge(formData, true, true);
|
|
253
179
|
}
|
|
254
180
|
|
|
255
|
-
private
|
|
256
|
-
|
|
257
|
-
.each(key => {
|
|
258
|
-
Stream.of(...this.value[key]).each(item => ret.append(key, item));
|
|
259
|
-
});
|
|
181
|
+
private remapKeyForNamingContainer(key: string): string {
|
|
182
|
+
return this.paramsMapper(key, "")[0];
|
|
260
183
|
}
|
|
261
184
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {AsyncRunnable} from "../util/AsyncRunnable";
|
|
18
|
-
import {Config, DQ, Stream} from "mona-dish";
|
|
18
|
+
import {Config, DQ, DQ$, Stream} from "mona-dish";
|
|
19
19
|
import {Implementation} from "../AjaxImpl";
|
|
20
20
|
|
|
21
21
|
import {XhrFormData} from "./XhrFormData";
|
|
@@ -23,27 +23,35 @@ import {ErrorData} from "./ErrorData";
|
|
|
23
23
|
import {EventData} from "./EventData";
|
|
24
24
|
import {ExtLang} from "../util/Lang";
|
|
25
25
|
import {
|
|
26
|
+
$faces, $nsp,
|
|
26
27
|
BEGIN,
|
|
27
28
|
COMPLETE,
|
|
28
29
|
CONTENT_TYPE,
|
|
29
30
|
CTX_PARAM_MF_INTERNAL,
|
|
30
|
-
|
|
31
|
+
CTX_PARAM_REQ_PASS_THR,
|
|
31
32
|
ERROR,
|
|
32
33
|
HEAD_FACES_REQ,
|
|
33
|
-
MALFORMEDXML,
|
|
34
|
+
MALFORMEDXML, NAMED_VIEWROOT,
|
|
34
35
|
NO_TIMEOUT,
|
|
35
36
|
ON_ERROR,
|
|
36
|
-
ON_EVENT, P_EXECUTE,
|
|
37
|
+
ON_EVENT, P_EXECUTE, P_PARTIAL_SOURCE, P_VIEWSTATE, NAMING_CONTAINER_ID,
|
|
37
38
|
REQ_ACCEPT,
|
|
38
39
|
REQ_TYPE_GET,
|
|
39
|
-
REQ_TYPE_POST,
|
|
40
|
+
REQ_TYPE_POST, SOURCE,
|
|
40
41
|
STATE_EVT_TIMEOUT,
|
|
41
42
|
STD_ACCEPT,
|
|
42
43
|
URL_ENCODED,
|
|
43
|
-
VAL_AJAX
|
|
44
|
+
VAL_AJAX, IDENT_NONE
|
|
44
45
|
} from "../core/Const";
|
|
45
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
resolveFinalUrl,
|
|
48
|
+
resolveHandlerFunc,
|
|
49
|
+
resolveViewRootId,
|
|
50
|
+
resoveNamingContainerMapper
|
|
51
|
+
} from "./RequestDataResolver";
|
|
46
52
|
import failSaveExecute = ExtLang.failSaveExecute;
|
|
53
|
+
import {ExtConfig} from "../util/ExtDomQuery";
|
|
54
|
+
import {ResponseProcessor} from "./ResponseProcessor";
|
|
47
55
|
|
|
48
56
|
/**
|
|
49
57
|
* Faces XHR Request Wrapper
|
|
@@ -53,6 +61,7 @@ import failSaveExecute = ExtLang.failSaveExecute;
|
|
|
53
61
|
* a single ajax request into our queue
|
|
54
62
|
* and let the queue do the processing.
|
|
55
63
|
*
|
|
64
|
+
*
|
|
56
65
|
*/
|
|
57
66
|
|
|
58
67
|
export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
@@ -86,7 +95,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
86
95
|
constructor(
|
|
87
96
|
private source: DQ,
|
|
88
97
|
private sourceForm: DQ,
|
|
89
|
-
private requestContext:
|
|
98
|
+
private requestContext: ExtConfig,
|
|
90
99
|
private internalContext: Config,
|
|
91
100
|
private partialIdsArray = [],
|
|
92
101
|
private timeout = NO_TIMEOUT,
|
|
@@ -111,12 +120,10 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
111
120
|
let xhrObject = this.xhrObject;
|
|
112
121
|
|
|
113
122
|
let executesArr = () => {
|
|
114
|
-
return this.requestContext.getIf(
|
|
123
|
+
return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get(IDENT_NONE).value.split(/\s+/gi);
|
|
115
124
|
};
|
|
116
|
-
try {
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
let viewState = (window?.faces ?? window?.jsf).getViewState(formElement);
|
|
126
|
+
try {
|
|
120
127
|
// encoded we need to decode
|
|
121
128
|
// We generated a base representation of the current form
|
|
122
129
|
// in case someone has overloaded the viewState with additional decorators we merge
|
|
@@ -125,21 +132,30 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
125
132
|
// whatever the formData object delivers
|
|
126
133
|
// the partialIdsArray arr is almost deprecated legacy code where we allowed to send a separate list of partial
|
|
127
134
|
// ids for reduced load and server processing, this will be removed soon, we can handle the same via execute
|
|
128
|
-
// anyway TODO
|
|
129
|
-
let formData: XhrFormData = new XhrFormData(this.sourceForm,
|
|
135
|
+
// anyway TODO reimplement the partial ids array, we still do not have it in jsf the way we need it
|
|
136
|
+
let formData: XhrFormData = new XhrFormData(this.sourceForm, resoveNamingContainerMapper(this.internalContext), executesArr(), this.partialIdsArray);
|
|
130
137
|
|
|
131
138
|
this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
|
|
132
139
|
|
|
133
140
|
// next step the pass through parameters are merged in for post params
|
|
141
|
+
this.requestContext.$nspEnabled = false;
|
|
134
142
|
let requestContext = this.requestContext;
|
|
135
|
-
let
|
|
143
|
+
let requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR) as ExtConfig;
|
|
136
144
|
|
|
145
|
+
// we are turning off here the jsf, faces remapping because we are now dealing with
|
|
146
|
+
// pass-through parameters
|
|
147
|
+
requestPassThroughParams.$nspEnabled = false;
|
|
137
148
|
// this is an extension where we allow pass through parameters to be sent down additionally
|
|
138
149
|
// this can be used and is used in the impl to enrich the post request parameters with additional
|
|
139
150
|
// information
|
|
140
|
-
|
|
151
|
+
try {
|
|
152
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
153
|
+
} finally {
|
|
154
|
+
this.requestContext.$nspEnabled = true;
|
|
155
|
+
requestPassThroughParams.$nspEnabled = true;
|
|
156
|
+
}
|
|
141
157
|
|
|
142
|
-
this.responseContext =
|
|
158
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
143
159
|
|
|
144
160
|
// we have to shift the internal passthroughs around to build up our response context
|
|
145
161
|
let responseContext = this.responseContext;
|
|
@@ -170,9 +186,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
170
186
|
ignoreErr(() => xhrObject.setRequestHeader(REQ_ACCEPT, STD_ACCEPT));
|
|
171
187
|
|
|
172
188
|
this.sendEvent(BEGIN);
|
|
173
|
-
|
|
174
189
|
this.sendRequest(formData);
|
|
175
|
-
|
|
176
190
|
} catch (e) {
|
|
177
191
|
// _onError
|
|
178
192
|
this.handleError(e);
|
|
@@ -290,7 +304,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
290
304
|
return;
|
|
291
305
|
}
|
|
292
306
|
|
|
293
|
-
(
|
|
307
|
+
$faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
|
|
294
308
|
}
|
|
295
309
|
|
|
296
310
|
private handleMalFormedXML(resolve: Function) {
|
|
@@ -300,9 +314,9 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
300
314
|
status: MALFORMEDXML,
|
|
301
315
|
responseCode: 200,
|
|
302
316
|
responseText: this.xhrObject?.responseText,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
317
|
+
// we remap the element just in case it gets replaced
|
|
318
|
+
// it will be unremapped
|
|
319
|
+
source: this.source.id.value
|
|
306
320
|
};
|
|
307
321
|
try {
|
|
308
322
|
this.handleError(errorData, true);
|
|
@@ -352,6 +366,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
352
366
|
|
|
353
367
|
Implementation.sendEvent(eventData, eventHandler);
|
|
354
368
|
} catch (e) {
|
|
369
|
+
e.source = e?.source ?? this.requestContext.getIf(SOURCE).value;
|
|
355
370
|
this.handleError(e);
|
|
356
371
|
throw e;
|
|
357
372
|
}
|
|
@@ -364,4 +379,5 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
364
379
|
Implementation.sendError(errorData, eventHandler);
|
|
365
380
|
}
|
|
366
381
|
|
|
382
|
+
|
|
367
383
|
}
|
|
@@ -62,18 +62,23 @@ export module oam {
|
|
|
62
62
|
DQ.byId(element).delete();
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
// noinspection JSUnusedGlobalSymbols
|
|
65
|
+
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
66
66
|
/**
|
|
67
67
|
* does special form submit remapping
|
|
68
68
|
* re-maps the issuing command link into something,
|
|
69
|
-
*
|
|
69
|
+
* the "decode" of the command link on the server can understand
|
|
70
70
|
*
|
|
71
71
|
* @param formName
|
|
72
72
|
* @param linkId
|
|
73
73
|
* @param target
|
|
74
74
|
* @param params
|
|
75
75
|
*/
|
|
76
|
-
export const submitForm = function (formName: string, linkId: string, target: string, params:
|
|
76
|
+
export const submitForm = function (formName: string, linkId: string | null = null, target: string |null = null, params: AssocArr<any> | Tuples<string, any> | null = {} ): boolean {
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
//handle a possible incoming null, not sure if this is used that way anywhere, but we allow it
|
|
80
|
+
params = (!params) ? {} : params;
|
|
81
|
+
|
|
77
82
|
let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
|
|
78
83
|
window?.[clearFn]?.(formName);
|
|
79
84
|
|
|
@@ -81,18 +86,23 @@ export module oam {
|
|
|
81
86
|
if (window?.myfaces?.core?.config?.autoScroll && (window as any)?.getScrolling) {
|
|
82
87
|
myfaces.oam.setHiddenInput(formName, 'autoScroll', (window as any)?.getScrolling());
|
|
83
88
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
89
|
+
let paramsStream: Stream<[string, any]> = Array.isArray(params) ? Stream.of(...params) : Stream.ofAssoc(params);
|
|
90
|
+
paramsStream.each(([key, data]) => myfaces.oam.setHiddenInput(formName, key, data));
|
|
87
91
|
|
|
88
92
|
//we call the namespaced function, to allow decoration, via a direct call we would
|
|
89
|
-
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
|
|
93
|
+
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId ?? '');
|
|
94
|
+
|
|
90
95
|
|
|
91
|
-
DQ.byId(document.forms[formName]).each(form => {
|
|
96
|
+
DQ.byId(document.forms?.[formName] ?? document.getElementById(formName)).each(form => {
|
|
92
97
|
const ATTR_TARGET = "target";
|
|
93
98
|
const formElement = form.getAsElem(0).value as HTMLFormElement;
|
|
94
|
-
const oldTarget = form.
|
|
95
|
-
|
|
99
|
+
const oldTarget = (form.getAsElem(0).value as HTMLFormElement).getAttribute("target");
|
|
100
|
+
|
|
101
|
+
if(target != "null" && target) {
|
|
102
|
+
(form.getAsElem(0).value as HTMLFormElement).setAttribute("target", target);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
96
106
|
|
|
97
107
|
const result = formElement?.onsubmit?.(null);
|
|
98
108
|
|
|
@@ -103,9 +113,15 @@ export module oam {
|
|
|
103
113
|
} catch (e) {
|
|
104
114
|
window?.console.error(e);
|
|
105
115
|
} finally {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
if(oldTarget == null || oldTarget == "null") {
|
|
117
|
+
(form.getAsElem(0).value as HTMLFormElement).removeAttribute("target");
|
|
118
|
+
} else {
|
|
119
|
+
(form.getAsElem(0).value as HTMLFormElement).setAttribute("target", oldTarget);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// noinspection JSUnusedLocalSymbols
|
|
123
|
+
paramsStream.each(([key, data]) => {
|
|
124
|
+
myfaces.oam.clearHiddenInput(formName, key);
|
|
109
125
|
});
|
|
110
126
|
myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
|
|
111
127
|
}
|
|
@@ -319,7 +319,7 @@ describe('DOMQuery tests', function () {
|
|
|
319
319
|
|
|
320
320
|
it('it must have parents', function () {
|
|
321
321
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
322
|
-
let coll: Array<any> = probe1.
|
|
322
|
+
let coll: Array<any> = probe1.firstParent("body").stream.collect(new ArrayCollector());
|
|
323
323
|
expect(coll.length == 1).to.be.true;
|
|
324
324
|
|
|
325
325
|
});
|