jsf.js_next_gen 4.0.0-RC.13 → 4.0.0-RC.14
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/window/faces-development.js +290 -210
- 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 +290 -210
- 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 +4 -4
- package/src/main/typescript/@types/definitions/index.d.ts +2 -0
- package/src/main/typescript/api/_api.ts +2 -2
- package/src/main/typescript/impl/AjaxImpl.ts +40 -29
- package/src/main/typescript/impl/core/Const.ts +41 -38
- package/src/main/typescript/impl/core/Context.ts +19 -0
- package/src/main/typescript/impl/util/Assertions.ts +2 -2
- package/src/main/typescript/impl/util/ExtDomQuery.ts +2 -2
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +63 -0
- package/src/main/typescript/impl/util/Lang.ts +8 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +17 -5
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
- package/src/main/typescript/impl/xhrCore/Response.ts +25 -25
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +110 -121
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +1 -1
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +8 -7
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +19 -0
- 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/NamespacesRequestTest.spec.ts +195 -0
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +2 -0
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +10 -3
- package/target/api/_api.js +1 -1
- package/target/api/_api.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 +34 -23
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +42 -36
- 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 +1 -1
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +2 -2
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +58 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +7 -9
- package/target/impl/util/Lang.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/RequestDataResolver.js +13 -3
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +13 -13
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +92 -109
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +1 -1
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +7 -8
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +18 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.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/xhrCore/NamespacesRequestTest.spec.js +199 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +7 -3
- package/target/test/xhrCore/ResponseTest.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
|
@@ -20,23 +20,23 @@ import {ResponseProcessor} from "./ResponseProcessor";
|
|
|
20
20
|
import {IResponseProcessor} from "./IResponseProcessor";
|
|
21
21
|
import {
|
|
22
22
|
$nsp,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
XML_TAG_ATTRIBUTES,
|
|
24
|
+
XML_TAG_CHANGES,
|
|
25
|
+
XML_TAG_DELETE,
|
|
26
|
+
XML_TAG_ERROR,
|
|
27
|
+
XML_TAG_EVAL,
|
|
28
|
+
XML_TAG_EXTENSION,
|
|
29
|
+
XML_TAG_INSERT,
|
|
30
|
+
XML_TAG_REDIRECT,
|
|
31
|
+
XML_TAG_UPDATE, P_RESOURCE,
|
|
32
32
|
P_VIEWBODY,
|
|
33
33
|
P_VIEWHEAD,
|
|
34
34
|
P_VIEWROOT,
|
|
35
35
|
PARTIAL_ID,
|
|
36
|
-
|
|
36
|
+
XML_TAG_PARTIAL_RESP,
|
|
37
37
|
RESPONSE_XML,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
XML_TAG_AFTER,
|
|
39
|
+
XML_TAG_BEFORE
|
|
40
40
|
} from "../core/Const";
|
|
41
41
|
import {resolveContexts, resolveResponseXML} from "./ResonseDataResolver";
|
|
42
42
|
import {ExtConfig} from "../util/ExtDomQuery";
|
|
@@ -67,7 +67,7 @@ export module Response {
|
|
|
67
67
|
internalContext.assign(RESPONSE_XML).value = responseXML;
|
|
68
68
|
|
|
69
69
|
// we now process the partial tags, or in none given raise an error
|
|
70
|
-
responseXML.querySelectorAll(
|
|
70
|
+
responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP)
|
|
71
71
|
.each(item => processPartialTag(<XMLQuery>item, responseProcessor, internalContext));
|
|
72
72
|
|
|
73
73
|
// We now process the viewStates, client windows and the elements to be evaluated are delayed.
|
|
@@ -89,18 +89,18 @@ export module Response {
|
|
|
89
89
|
function processPartialTag(node: XMLQuery, responseProcessor: IResponseProcessor, internalContext) {
|
|
90
90
|
|
|
91
91
|
internalContext.assign(PARTIAL_ID).value = node.id;
|
|
92
|
-
const SEL_SUB_TAGS = [
|
|
92
|
+
const SEL_SUB_TAGS = [XML_TAG_ERROR, XML_TAG_REDIRECT, XML_TAG_CHANGES].join(",");
|
|
93
93
|
|
|
94
94
|
// now we can process the main operations
|
|
95
95
|
node.querySelectorAll(SEL_SUB_TAGS).each((node: XMLQuery) => {
|
|
96
96
|
switch (node.tagName.value) {
|
|
97
|
-
case
|
|
97
|
+
case XML_TAG_ERROR:
|
|
98
98
|
responseProcessor.error(node);
|
|
99
99
|
break;
|
|
100
|
-
case
|
|
100
|
+
case XML_TAG_REDIRECT:
|
|
101
101
|
responseProcessor.redirect(node);
|
|
102
102
|
break;
|
|
103
|
-
case
|
|
103
|
+
case XML_TAG_CHANGES:
|
|
104
104
|
processChangesTag(node, responseProcessor);
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
@@ -110,7 +110,7 @@ export module Response {
|
|
|
110
110
|
|
|
111
111
|
let processInsert = function (responseProcessor: IResponseProcessor, node: XMLQuery) {
|
|
112
112
|
// path1 insert after as child tags
|
|
113
|
-
if(node.querySelectorAll([
|
|
113
|
+
if(node.querySelectorAll([XML_TAG_BEFORE, XML_TAG_AFTER].join(",")).length) {
|
|
114
114
|
responseProcessor.insertWithSubTags(node);
|
|
115
115
|
} else { // insert before after with id
|
|
116
116
|
responseProcessor.insert(node);
|
|
@@ -125,31 +125,31 @@ export module Response {
|
|
|
125
125
|
* @param responseProcessor
|
|
126
126
|
*/
|
|
127
127
|
function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {
|
|
128
|
-
const ALLOWED_TAGS = [
|
|
128
|
+
const ALLOWED_TAGS = [XML_TAG_UPDATE, XML_TAG_EVAL, XML_TAG_INSERT, XML_TAG_DELETE, XML_TAG_ATTRIBUTES, XML_TAG_EXTENSION].join(", ");
|
|
129
129
|
node.querySelectorAll(ALLOWED_TAGS).each(
|
|
130
130
|
(node: XMLQuery) => {
|
|
131
131
|
switch (node.tagName.value) {
|
|
132
|
-
case
|
|
132
|
+
case XML_TAG_UPDATE:
|
|
133
133
|
processUpdateTag(node, responseProcessor);
|
|
134
134
|
break;
|
|
135
135
|
|
|
136
|
-
case
|
|
136
|
+
case XML_TAG_EVAL:
|
|
137
137
|
responseProcessor.eval(node);
|
|
138
138
|
break;
|
|
139
139
|
|
|
140
|
-
case
|
|
140
|
+
case XML_TAG_INSERT:
|
|
141
141
|
processInsert(responseProcessor, node);
|
|
142
142
|
break;
|
|
143
143
|
|
|
144
|
-
case
|
|
144
|
+
case XML_TAG_DELETE:
|
|
145
145
|
responseProcessor.delete(node);
|
|
146
146
|
break;
|
|
147
147
|
|
|
148
|
-
case
|
|
148
|
+
case XML_TAG_ATTRIBUTES:
|
|
149
149
|
responseProcessor.attributes(node);
|
|
150
150
|
break;
|
|
151
151
|
|
|
152
|
-
case
|
|
152
|
+
case XML_TAG_EXTENSION:
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {Config, DomQueryCollector, DQ, DQ$, Lang, LazyStream, Stream, XMLQuery} from "mona-dish";
|
|
17
|
+
import {Config, DomQuery, DomQueryCollector, DQ, DQ$, Lang, LazyStream, Stream, XMLQuery} from "mona-dish";
|
|
18
18
|
import {Implementation} from "../AjaxImpl";
|
|
19
19
|
import {Assertions} from "../util/Assertions";
|
|
20
20
|
import {IResponseProcessor} from "./IResponseProcessor";
|
|
@@ -23,6 +23,7 @@ import {StateHolder} from "../core/ImplTypes";
|
|
|
23
23
|
import {EventData} from "./EventData";
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
|
+
$faces,
|
|
26
27
|
$nsp,
|
|
27
28
|
APPLIED_CLIENT_WINDOW,
|
|
28
29
|
APPLIED_VST,
|
|
@@ -30,31 +31,40 @@ import {
|
|
|
30
31
|
ATTR_NAME,
|
|
31
32
|
ATTR_URL,
|
|
32
33
|
ATTR_VALUE,
|
|
34
|
+
DEFERRED_HEAD_INSERTS,
|
|
33
35
|
EMPTY_FUNC,
|
|
34
36
|
EMPTY_STR,
|
|
35
37
|
ERROR_MESSAGE,
|
|
36
38
|
ERROR_NAME,
|
|
37
|
-
|
|
39
|
+
HTML_TAG_BODY,
|
|
40
|
+
HTML_TAG_FORM,
|
|
41
|
+
HTML_TAG_HEAD,
|
|
42
|
+
HTML_TAG_LINK,
|
|
43
|
+
HTML_TAG_SCRIPT,
|
|
44
|
+
HTML_TAG_STYLE, IDENT_ALL, IDENT_NONE,
|
|
38
45
|
ON_ERROR,
|
|
39
|
-
ON_EVENT,
|
|
46
|
+
ON_EVENT,
|
|
47
|
+
P_CLIENT_WINDOW,
|
|
48
|
+
P_EXECUTE,
|
|
40
49
|
P_PARTIAL_SOURCE,
|
|
50
|
+
P_RENDER,
|
|
51
|
+
P_RENDER_OVERRIDE,
|
|
41
52
|
P_VIEWSTATE,
|
|
42
|
-
|
|
53
|
+
PARTIAL_ID,
|
|
54
|
+
RESPONSE_XML,
|
|
55
|
+
SEL_CLIENT_WINDOW_ELEM,
|
|
43
56
|
SEL_VIEWSTATE_ELEM,
|
|
44
57
|
SOURCE,
|
|
45
58
|
SUCCESS,
|
|
46
|
-
TAG_AFTER,
|
|
47
|
-
TAG_ATTR,
|
|
48
|
-
TAG_BEFORE,
|
|
49
|
-
TAG_BODY,
|
|
50
|
-
TAG_FORM,
|
|
51
|
-
TAG_HEAD,
|
|
52
59
|
UPDATE_ELEMS,
|
|
53
60
|
UPDATE_FORMS,
|
|
54
|
-
|
|
61
|
+
XML_TAG_AFTER,
|
|
62
|
+
XML_TAG_ATTR,
|
|
63
|
+
XML_TAG_BEFORE
|
|
55
64
|
} from "../core/Const";
|
|
56
|
-
import trim = Lang.trim;
|
|
57
65
|
import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
66
|
+
import {HiddenInputBuilder} from "../util/HiddenInputBuilder";
|
|
67
|
+
import trim = Lang.trim;
|
|
58
68
|
|
|
59
69
|
|
|
60
70
|
/**
|
|
@@ -81,11 +91,11 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
81
91
|
* the data incoming must represent the html representation of the head itself one way or the other
|
|
82
92
|
*/
|
|
83
93
|
replaceHead(shadowDocument: XMLQuery | DQ) {
|
|
84
|
-
|
|
94
|
+
const shadowHead = shadowDocument.querySelectorAll(HTML_TAG_HEAD);
|
|
85
95
|
if (!shadowHead.isPresent()) {
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
|
-
|
|
98
|
+
const head = ExtDomQuery.querySelectorAll(HTML_TAG_HEAD);
|
|
89
99
|
// full replace we delete everything
|
|
90
100
|
head.childNodes.delete();
|
|
91
101
|
this.addToHead(shadowHead);
|
|
@@ -93,14 +103,14 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
93
103
|
|
|
94
104
|
addToHead(shadowHead: XMLQuery | DQ) {
|
|
95
105
|
const mappedHeadData = new ExtDomQuery(shadowHead);
|
|
96
|
-
const postProcessTags = [
|
|
106
|
+
const postProcessTags = [HTML_TAG_STYLE, HTML_TAG_LINK, HTML_TAG_SCRIPT];
|
|
97
107
|
const nonExecutables = mappedHeadData.filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) == -1);
|
|
98
108
|
nonExecutables.runHeadInserts(true);
|
|
99
109
|
|
|
100
110
|
//incoming either the outer head tag or its children
|
|
101
111
|
const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
|
|
102
|
-
// this is stored for post processing
|
|
103
|
-
// after the rest of the "
|
|
112
|
+
// this is stored for "post" processing
|
|
113
|
+
// after the rest of the "physical build up", head before body
|
|
104
114
|
const evalElements = nodesToAdd.stream
|
|
105
115
|
.filter(item => postProcessTags.indexOf(item.tagName.orElse("").value) != -1).collect(new DomQueryCollector());
|
|
106
116
|
this.addToHeadDeferred(evalElements);
|
|
@@ -120,20 +130,20 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
120
130
|
*/
|
|
121
131
|
replaceBody(shadowDocument: XMLQuery | DQ) {
|
|
122
132
|
|
|
123
|
-
|
|
133
|
+
const shadowBody = shadowDocument.querySelectorAll(HTML_TAG_BODY);
|
|
124
134
|
if (!shadowBody.isPresent()) {
|
|
125
135
|
return;
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
|
|
138
|
+
const shadowInnerHTML: string = <string>shadowBody.innerHTML;
|
|
129
139
|
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
const resultingBody = <DQ>ExtDomQuery.querySelectorAll(HTML_TAG_BODY);
|
|
141
|
+
const updateForms = resultingBody.querySelectorAll(HTML_TAG_FORM);
|
|
132
142
|
|
|
133
143
|
// main difference, we cannot replace the body itself, but only its content
|
|
134
144
|
// we need a separate step for post-processing the incoming
|
|
135
145
|
// attributes, like classes, styles etc...
|
|
136
|
-
resultingBody.copyAttrs(shadowBody);
|
|
146
|
+
(resultingBody.html(shadowInnerHTML) as DQ).copyAttrs(shadowBody);
|
|
137
147
|
this.externalContext.assign($nsp(P_RENDER_OVERRIDE)).value = "@all";
|
|
138
148
|
this.storeForPostProcessing(updateForms, resultingBody);
|
|
139
149
|
}
|
|
@@ -161,18 +171,18 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
161
171
|
* <error>
|
|
162
172
|
*/
|
|
163
173
|
|
|
164
|
-
|
|
174
|
+
const mergedErrorData = new ExtConfig({});
|
|
165
175
|
mergedErrorData.assign(SOURCE).value = this.externalContext.getIf(P_PARTIAL_SOURCE).get(0).value;
|
|
166
176
|
mergedErrorData.assign(ERROR_NAME).value = node.querySelectorAll(ERROR_NAME).textContent(EMPTY_STR);
|
|
167
177
|
mergedErrorData.assign(ERROR_MESSAGE).value = node.querySelectorAll(ERROR_MESSAGE).cDATAAsString;
|
|
168
178
|
|
|
169
|
-
|
|
179
|
+
const hasResponseXML = this.internalContext.get(RESPONSE_XML).isPresent();
|
|
170
180
|
|
|
171
181
|
//we now store the response xml also in the error data for further details
|
|
172
182
|
mergedErrorData.assignIf(hasResponseXML, RESPONSE_XML).value = this.internalContext.getIf(RESPONSE_XML).value.get(0).value;
|
|
173
183
|
|
|
174
184
|
// error post-processing and enrichment (standard messages from keys)
|
|
175
|
-
|
|
185
|
+
const errorData = ErrorData.fromServerError(mergedErrorData);
|
|
176
186
|
|
|
177
187
|
// we now trigger an internally stored onError function which might be an attached to the context
|
|
178
188
|
// either we do not have an internal on error, or an on error has been based via params from the outside.
|
|
@@ -190,7 +200,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
190
200
|
redirect(node: XMLQuery) {
|
|
191
201
|
Assertions.assertUrlExists(node);
|
|
192
202
|
|
|
193
|
-
|
|
203
|
+
const redirectUrl = trim(node.attr(ATTR_URL).value);
|
|
194
204
|
if (redirectUrl != EMPTY_STR) {
|
|
195
205
|
window.location.href = redirectUrl;
|
|
196
206
|
}
|
|
@@ -202,8 +212,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
202
212
|
* @param cdataBlock the cdata block with the new html code
|
|
203
213
|
*/
|
|
204
214
|
update(node: XMLQuery, cdataBlock: string) {
|
|
205
|
-
|
|
206
|
-
|
|
215
|
+
const result = ExtDomQuery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
|
|
216
|
+
const sourceForm = result?.firstParent(HTML_TAG_FORM).orElseLazy(() => result.byTagName(HTML_TAG_FORM, true));
|
|
207
217
|
if (sourceForm) {
|
|
208
218
|
this.storeForPostProcessing(sourceForm, result);
|
|
209
219
|
}
|
|
@@ -223,9 +233,9 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
223
233
|
* @param node
|
|
224
234
|
*/
|
|
225
235
|
attributes(node: XMLQuery) {
|
|
226
|
-
|
|
236
|
+
const elem = DQ.byId(node.id.value, true);
|
|
227
237
|
|
|
228
|
-
node.byTagName(
|
|
238
|
+
node.byTagName(XML_TAG_ATTR).each((item: XMLQuery) => {
|
|
229
239
|
elem.attr(item.attr(ATTR_NAME).value).value = item.attr(ATTR_VALUE).value;
|
|
230
240
|
});
|
|
231
241
|
}
|
|
@@ -246,17 +256,17 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
246
256
|
insert(node: XMLQuery) {
|
|
247
257
|
//let insertId = node.id; //not used atm
|
|
248
258
|
|
|
249
|
-
|
|
250
|
-
|
|
259
|
+
const before = node.attr(XML_TAG_BEFORE);
|
|
260
|
+
const after = node.attr(XML_TAG_AFTER);
|
|
251
261
|
|
|
252
|
-
|
|
262
|
+
const insertNodes = DQ.fromMarkup(<any>node.cDATAAsString);
|
|
253
263
|
|
|
254
264
|
if (before.isPresent()) {
|
|
255
265
|
DQ.byId(before.value, true).insertBefore(insertNodes);
|
|
256
266
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
257
267
|
}
|
|
258
268
|
if (after.isPresent()) {
|
|
259
|
-
|
|
269
|
+
const domQuery = DQ.byId(after.value, true);
|
|
260
270
|
domQuery.insertAfter(insertNodes);
|
|
261
271
|
|
|
262
272
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -269,12 +279,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
269
279
|
* @param node the node hosting the insert data
|
|
270
280
|
*/
|
|
271
281
|
insertWithSubTags(node: XMLQuery) {
|
|
272
|
-
|
|
273
|
-
|
|
282
|
+
const before = node.querySelectorAll(XML_TAG_BEFORE);
|
|
283
|
+
const after = node.querySelectorAll(XML_TAG_AFTER);
|
|
274
284
|
|
|
275
285
|
before.each(item => {
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
const insertId = item.attr(ATTR_ID);
|
|
287
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
278
288
|
if (insertId.isPresent()) {
|
|
279
289
|
DQ.byId(insertId.value, true).insertBefore(insertNodes);
|
|
280
290
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -282,8 +292,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
282
292
|
});
|
|
283
293
|
|
|
284
294
|
after.each(item => {
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
const insertId = item.attr(ATTR_ID);
|
|
296
|
+
const insertNodes = DQ.fromMarkup(<any>item.cDATAAsString);
|
|
287
297
|
if (insertId.isPresent()) {
|
|
288
298
|
DQ.byId(insertId.value, true).insertAfter(insertNodes);
|
|
289
299
|
this.internalContext.assign(UPDATE_ELEMS).value.push(insertNodes);
|
|
@@ -298,7 +308,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
298
308
|
*/
|
|
299
309
|
processViewState(node: XMLQuery): boolean {
|
|
300
310
|
if (ResponseProcessor.isViewStateNode(node)) {
|
|
301
|
-
|
|
311
|
+
const state = node.cDATAAsString;
|
|
302
312
|
this.internalContext.assign(APPLIED_VST, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
303
313
|
return true;
|
|
304
314
|
}
|
|
@@ -307,7 +317,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
307
317
|
|
|
308
318
|
processClientWindow(node: XMLQuery): boolean {
|
|
309
319
|
if (ResponseProcessor.isClientWindowNode(node)) {
|
|
310
|
-
|
|
320
|
+
const state = node.cDATAAsString;
|
|
311
321
|
this.internalContext.assign(APPLIED_CLIENT_WINDOW, node.id.value).value = new StateHolder($nsp(node.id.value), state);
|
|
312
322
|
return true;
|
|
313
323
|
}
|
|
@@ -336,15 +346,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
336
346
|
*/
|
|
337
347
|
fixViewStates() {
|
|
338
348
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_VST).orElse({}).value)
|
|
339
|
-
.each((
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
affectedForms = this.getContainerForms(namingContainerId)
|
|
345
|
-
.filter(affectedForm => this.executeOrRenderFilter(affectedForm));
|
|
349
|
+
.each(([, value]) => {
|
|
350
|
+
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
351
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
352
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
346
353
|
|
|
347
|
-
this.appendViewStateToForms(affectedForms, value.value);
|
|
354
|
+
this.appendViewStateToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
348
355
|
});
|
|
349
356
|
}
|
|
350
357
|
|
|
@@ -356,15 +363,12 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
356
363
|
*/
|
|
357
364
|
fixClientWindow() {
|
|
358
365
|
Stream.ofAssoc<StateHolder>(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
|
|
359
|
-
.each((
|
|
360
|
-
const value: StateHolder = item[1];
|
|
366
|
+
.each(([, value]) => {
|
|
361
367
|
const namingContainerId = this.internalContext.getIf(PARTIAL_ID);
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
affectedForms = this.getContainerForms(namingContainerId)
|
|
365
|
-
.filter(affectedForm => this.executeOrRenderFilter(affectedForm));
|
|
368
|
+
const affectedForms = this.getContainerForms(namingContainerId)
|
|
369
|
+
.filter(affectedForm => this.isInExecuteOrRender(affectedForm));
|
|
366
370
|
|
|
367
|
-
this.appendClientWindowToForms(affectedForms, value.value);
|
|
371
|
+
this.appendClientWindowToForms(affectedForms, value.value, namingContainerId.orElse("").value);
|
|
368
372
|
});
|
|
369
373
|
}
|
|
370
374
|
|
|
@@ -372,10 +376,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
372
376
|
* all processing done we can close the request and send the appropriate events
|
|
373
377
|
*/
|
|
374
378
|
done() {
|
|
375
|
-
|
|
379
|
+
const eventData = EventData.createFromRequest(this.request.value, this.externalContext, SUCCESS);
|
|
376
380
|
|
|
377
381
|
//because some frameworks might decorate them over the context in the response
|
|
378
|
-
|
|
382
|
+
const eventHandler = this.externalContext.getIf(ON_EVENT).orElseLazy(() => this.internalContext.getIf(ON_EVENT).value).orElse(EMPTY_FUNC).value;
|
|
379
383
|
Implementation.sendEvent(eventData, eventHandler);
|
|
380
384
|
}
|
|
381
385
|
|
|
@@ -384,9 +388,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
384
388
|
*
|
|
385
389
|
* @param forms the forms to append the viewState to
|
|
386
390
|
* @param viewState the final viewState
|
|
391
|
+
* @param namingContainerId
|
|
387
392
|
*/
|
|
388
|
-
private appendViewStateToForms(forms: DQ, viewState: string) {
|
|
389
|
-
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState);
|
|
393
|
+
private appendViewStateToForms(forms: DQ, viewState: string, namingContainerId = "") {
|
|
394
|
+
this.assignState(forms, $nsp(SEL_VIEWSTATE_ELEM), viewState, namingContainerId);
|
|
390
395
|
}
|
|
391
396
|
|
|
392
397
|
|
|
@@ -395,9 +400,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
395
400
|
*
|
|
396
401
|
* @param forms the forms to append the viewState to
|
|
397
402
|
* @param clientWindow the final viewState
|
|
403
|
+
* @param namingContainerId
|
|
398
404
|
*/
|
|
399
|
-
private appendClientWindowToForms(forms: DQ, clientWindow: string) {
|
|
400
|
-
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow);
|
|
405
|
+
private appendClientWindowToForms(forms: DQ, clientWindow: string, namingContainerId = "") {
|
|
406
|
+
this.assignState(forms, $nsp(SEL_CLIENT_WINDOW_ELEM), clientWindow, namingContainerId);
|
|
401
407
|
}
|
|
402
408
|
|
|
403
409
|
/**
|
|
@@ -407,45 +413,28 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
407
413
|
* @param selector the selector for the state
|
|
408
414
|
* @param state the state itself which needs to be assigned
|
|
409
415
|
*
|
|
416
|
+
* @param namingContainerId
|
|
410
417
|
* @private
|
|
411
418
|
*/
|
|
412
|
-
private assignState(forms: DQ, selector: string, state: string) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
private assignState(forms: DQ, selector: string, state: string, namingContainerId: string) {
|
|
420
|
+
/**
|
|
421
|
+
* creates the viewState or client window id element
|
|
422
|
+
* @param form
|
|
423
|
+
*/
|
|
424
|
+
const createAndAppendHiddenInput = (form: DomQuery) => {
|
|
425
|
+
return new HiddenInputBuilder(selector)
|
|
426
|
+
.withNamingContainerId(namingContainerId)
|
|
427
|
+
.withParent(form)
|
|
428
|
+
.build();
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
forms.each(form => {
|
|
432
|
+
const hiddenInput = form.querySelectorAll(selector)
|
|
433
|
+
.orElseLazy(() => createAndAppendHiddenInput(form));
|
|
434
|
+
hiddenInput.val = state;
|
|
422
435
|
});
|
|
423
436
|
}
|
|
424
437
|
|
|
425
|
-
/**
|
|
426
|
-
* Helper to Create a new JSF ViewState Element
|
|
427
|
-
*
|
|
428
|
-
* @param parent, the parent node to attach the viewState element to
|
|
429
|
-
* (usually a form node)
|
|
430
|
-
*/
|
|
431
|
-
private static newViewStateElement(parent: DQ): DQ {
|
|
432
|
-
let newElement = DQ.fromMarkup($nsp(HTML_VIEWSTATE));
|
|
433
|
-
newElement.appendTo(parent);
|
|
434
|
-
return newElement;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Helper to Create a new JSF ViewState Element
|
|
439
|
-
*
|
|
440
|
-
* @param parent, the parent node to attach the viewState element to
|
|
441
|
-
* (usually a form node)
|
|
442
|
-
*/
|
|
443
|
-
private static newClientWindowElement(parent: DQ): DQ {
|
|
444
|
-
let newElement = DQ.fromMarkup($nsp(HTML_CLIENT_WINDOW));
|
|
445
|
-
newElement.appendTo(parent);
|
|
446
|
-
return newElement;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
438
|
/**
|
|
450
439
|
* Stores certain aspects of the dom for later post-processing
|
|
451
440
|
*
|
|
@@ -482,10 +471,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
482
471
|
* @returns if it is a viewState node
|
|
483
472
|
*/
|
|
484
473
|
private static isViewStateNode(node: XMLQuery): boolean {
|
|
485
|
-
|
|
474
|
+
const SEP = $faces().separatorchar;
|
|
486
475
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_VIEWSTATE) ||
|
|
487
|
-
node?.id?.value?.indexOf([
|
|
488
|
-
node?.id?.value?.indexOf([$nsp(P_VIEWSTATE),
|
|
476
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_VIEWSTATE)].join(EMPTY_STR)) != -1 ||
|
|
477
|
+
node?.id?.value?.indexOf([$nsp(P_VIEWSTATE), SEP].join(EMPTY_STR)) != -1);
|
|
489
478
|
}
|
|
490
479
|
|
|
491
480
|
/**
|
|
@@ -495,10 +484,10 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
495
484
|
* @returns true of it ii
|
|
496
485
|
*/
|
|
497
486
|
private static isClientWindowNode(node: XMLQuery): boolean {
|
|
498
|
-
|
|
487
|
+
const SEP = $faces().separatorchar;
|
|
499
488
|
return "undefined" != typeof node?.id?.value && (node?.id?.value == $nsp(P_CLIENT_WINDOW) ||
|
|
500
|
-
node?.id?.value?.indexOf([
|
|
501
|
-
node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW),
|
|
489
|
+
node?.id?.value?.indexOf([SEP, $nsp(P_CLIENT_WINDOW)].join(EMPTY_STR)) != -1 ||
|
|
490
|
+
node?.id?.value?.indexOf([$nsp(P_CLIENT_WINDOW), SEP].join(EMPTY_STR)) != -1);
|
|
502
491
|
}
|
|
503
492
|
|
|
504
493
|
private triggerOnError(errorData: ErrorData) {
|
|
@@ -510,25 +499,22 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
510
499
|
* @param affectedForm
|
|
511
500
|
* @private
|
|
512
501
|
*/
|
|
513
|
-
private
|
|
514
|
-
|
|
515
|
-
|
|
502
|
+
private isInExecuteOrRender(affectedForm) {
|
|
503
|
+
const executes = this.externalContext.getIf($nsp(P_EXECUTE)).orElse("@none").value.split(/\s+/gi);
|
|
504
|
+
const renders = this.externalContext.getIf(P_RENDER_OVERRIDE)
|
|
516
505
|
.orElseLazy(() => this.externalContext.getIf($nsp(P_RENDER)).value)
|
|
517
|
-
.orElse(
|
|
518
|
-
|
|
506
|
+
.orElse(IDENT_NONE).value.split(/\s+/gi);
|
|
507
|
+
const executeAndRenders = executes.concat(...renders);
|
|
519
508
|
return LazyStream.of(...executeAndRenders).filter(nameOrId => {
|
|
520
|
-
if (nameOrId
|
|
521
|
-
return true;
|
|
522
|
-
}
|
|
523
|
-
if (nameOrId == "@none") {
|
|
509
|
+
if ([IDENT_ALL, IDENT_NONE].indexOf(nameOrId) != -1) {
|
|
524
510
|
return true;
|
|
525
511
|
}
|
|
526
512
|
|
|
527
|
-
const
|
|
513
|
+
const NAME_OR_ID = this.getNameOrIdSelector(nameOrId);
|
|
528
514
|
//either the form directly is in execute or render or one of its children or one of its parents
|
|
529
|
-
return affectedForm.matchesSelector(
|
|
530
|
-
affectedForm.querySelectorAll(
|
|
531
|
-
affectedForm.firstParent(
|
|
515
|
+
return affectedForm.matchesSelector(NAME_OR_ID) ||
|
|
516
|
+
affectedForm.querySelectorAll(NAME_OR_ID).isPresent() ||
|
|
517
|
+
affectedForm.firstParent(NAME_OR_ID).isPresent();
|
|
532
518
|
}).first().isPresent();
|
|
533
519
|
}
|
|
534
520
|
|
|
@@ -540,14 +526,17 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
540
526
|
private getContainerForms(namingContainerId: Config) {
|
|
541
527
|
if (namingContainerId.isPresent()) {
|
|
542
528
|
//naming container mode, all forms under naming container id must be processed
|
|
543
|
-
return DQ.
|
|
544
|
-
.orElse(DQ$(`form[id='${namingContainerId.value}'], form[name='${namingContainerId.value}']`))
|
|
529
|
+
return DQ$(this.getNameOrIdSelector(namingContainerId.value))
|
|
545
530
|
// missing condition if the naming container is not present we have to
|
|
546
531
|
// use the body as fallback
|
|
547
|
-
.
|
|
548
|
-
.byTagName(
|
|
532
|
+
.orElseLazy(() => DQ.byTagName(HTML_TAG_BODY))
|
|
533
|
+
.byTagName(HTML_TAG_FORM, true);
|
|
549
534
|
} else {
|
|
550
|
-
return DQ.byTagName(
|
|
535
|
+
return DQ.byTagName(HTML_TAG_FORM);
|
|
551
536
|
}
|
|
552
537
|
}
|
|
538
|
+
|
|
539
|
+
private getNameOrIdSelector(nameOrId) {
|
|
540
|
+
return `[id='${nameOrId}'], [name='${nameOrId}']`;
|
|
541
|
+
}
|
|
553
542
|
}
|
|
@@ -109,7 +109,7 @@ export class XhrFormData extends Config {
|
|
|
109
109
|
* @param form the form holding the view state value
|
|
110
110
|
*/
|
|
111
111
|
private applyViewState(form: DQ) {
|
|
112
|
-
let viewState = form.
|
|
112
|
+
let viewState = form.querySelectorAllDeep(`[name*='${P_VIEWSTATE}'`).inputValue;
|
|
113
113
|
this.appendIf(viewState.isPresent(), P_VIEWSTATE).value = viewState.value;
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -23,11 +23,12 @@ import {ErrorData} from "./ErrorData";
|
|
|
23
23
|
import {EventData} from "./EventData";
|
|
24
24
|
import {ExtLang} from "../util/Lang";
|
|
25
25
|
import {
|
|
26
|
+
$faces,
|
|
26
27
|
BEGIN,
|
|
27
28
|
COMPLETE,
|
|
28
29
|
CONTENT_TYPE,
|
|
29
30
|
CTX_PARAM_MF_INTERNAL,
|
|
30
|
-
|
|
31
|
+
CTX_PARAM_REQ_PASS_THR,
|
|
31
32
|
ERROR,
|
|
32
33
|
HEAD_FACES_REQ,
|
|
33
34
|
MALFORMEDXML,
|
|
@@ -111,12 +112,12 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
111
112
|
let xhrObject = this.xhrObject;
|
|
112
113
|
|
|
113
114
|
let executesArr = () => {
|
|
114
|
-
return this.requestContext.getIf(
|
|
115
|
+
return this.requestContext.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).get("none").value.split(/\s+/gi);
|
|
115
116
|
};
|
|
116
117
|
try {
|
|
117
118
|
|
|
118
119
|
let formElement = this.sourceForm.getAsElem(0).value;
|
|
119
|
-
let viewState = (
|
|
120
|
+
let viewState = $faces().getViewState(formElement);
|
|
120
121
|
// encoded we need to decode
|
|
121
122
|
// We generated a base representation of the current form
|
|
122
123
|
// in case someone has overloaded the viewState with additional decorators we merge
|
|
@@ -132,14 +133,14 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
132
133
|
|
|
133
134
|
// next step the pass through parameters are merged in for post params
|
|
134
135
|
let requestContext = this.requestContext;
|
|
135
|
-
let
|
|
136
|
+
let requestPassThroughParams = requestContext.getIf(CTX_PARAM_REQ_PASS_THR);
|
|
136
137
|
|
|
137
138
|
// this is an extension where we allow pass through parameters to be sent down additionally
|
|
138
139
|
// this can be used and is used in the impl to enrich the post request parameters with additional
|
|
139
140
|
// information
|
|
140
|
-
formData.shallowMerge(
|
|
141
|
+
formData.shallowMerge(requestPassThroughParams, true, true);
|
|
141
142
|
|
|
142
|
-
this.responseContext =
|
|
143
|
+
this.responseContext = requestPassThroughParams.deepCopy;
|
|
143
144
|
|
|
144
145
|
// we have to shift the internal passthroughs around to build up our response context
|
|
145
146
|
let responseContext = this.responseContext;
|
|
@@ -290,7 +291,7 @@ export class XhrRequest implements AsyncRunnable<XMLHttpRequest> {
|
|
|
290
291
|
return;
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
(
|
|
294
|
+
$faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
private handleMalFormedXML(resolve: Function) {
|