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.
Files changed (98) hide show
  1. package/dist/window/faces-development.js +290 -210
  2. package/dist/window/faces-development.js.br +0 -0
  3. package/dist/window/faces-development.js.gz +0 -0
  4. package/dist/window/faces-development.js.map +1 -1
  5. package/dist/window/faces.js +1 -1
  6. package/dist/window/faces.js.LICENSE.txt +0 -2
  7. package/dist/window/faces.js.br +0 -0
  8. package/dist/window/faces.js.gz +0 -0
  9. package/dist/window/faces.js.map +1 -1
  10. package/dist/window/jsf-development.js +290 -210
  11. package/dist/window/jsf-development.js.br +0 -0
  12. package/dist/window/jsf-development.js.gz +0 -0
  13. package/dist/window/jsf-development.js.map +1 -1
  14. package/dist/window/jsf.js +1 -1
  15. package/dist/window/jsf.js.LICENSE.txt +0 -2
  16. package/dist/window/jsf.js.br +0 -0
  17. package/dist/window/jsf.js.gz +0 -0
  18. package/dist/window/jsf.js.map +1 -1
  19. package/package.json +4 -4
  20. package/src/main/typescript/@types/definitions/index.d.ts +2 -0
  21. package/src/main/typescript/api/_api.ts +2 -2
  22. package/src/main/typescript/impl/AjaxImpl.ts +40 -29
  23. package/src/main/typescript/impl/core/Const.ts +41 -38
  24. package/src/main/typescript/impl/core/Context.ts +19 -0
  25. package/src/main/typescript/impl/util/Assertions.ts +2 -2
  26. package/src/main/typescript/impl/util/ExtDomQuery.ts +2 -2
  27. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +63 -0
  28. package/src/main/typescript/impl/util/Lang.ts +8 -10
  29. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  30. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +17 -5
  31. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
  32. package/src/main/typescript/impl/xhrCore/Response.ts +25 -25
  33. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +110 -121
  34. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +1 -1
  35. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +8 -7
  36. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +19 -0
  37. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  38. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
  39. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +195 -0
  40. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +2 -0
  41. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +10 -3
  42. package/target/api/_api.js +1 -1
  43. package/target/api/_api.js.map +1 -1
  44. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  45. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  46. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  47. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  48. package/target/impl/AjaxImpl.js +34 -23
  49. package/target/impl/AjaxImpl.js.map +1 -1
  50. package/target/impl/core/Const.js +42 -36
  51. package/target/impl/core/Const.js.map +1 -1
  52. package/target/impl/core/Context.js +10 -0
  53. package/target/impl/core/Context.js.map +1 -0
  54. package/target/impl/util/Assertions.js +1 -1
  55. package/target/impl/util/Assertions.js.map +1 -1
  56. package/target/impl/util/ExtDomQuery.js +2 -2
  57. package/target/impl/util/ExtDomQuery.js.map +1 -1
  58. package/target/impl/util/HiddenElementBuilder.js +7 -0
  59. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  60. package/target/impl/util/HiddenInputBuilder.js +58 -0
  61. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  62. package/target/impl/util/Lang.js +7 -9
  63. package/target/impl/util/Lang.js.map +1 -1
  64. package/target/impl/xhrCore/EventData.js +1 -1
  65. package/target/impl/xhrCore/EventData.js.map +1 -1
  66. package/target/impl/xhrCore/RequestDataResolver.js +13 -3
  67. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  68. package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
  69. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  70. package/target/impl/xhrCore/Response.js +13 -13
  71. package/target/impl/xhrCore/Response.js.map +1 -1
  72. package/target/impl/xhrCore/ResponseProcessor.js +92 -109
  73. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  74. package/target/impl/xhrCore/XhrFormData.js +1 -1
  75. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  76. package/target/impl/xhrCore/XhrRequest.js +7 -8
  77. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  78. package/target/test/frameworkBase/_ext/shared/StandardInits.js +18 -0
  79. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  80. package/target/test/impl/ImplTest.spec.js +2 -2
  81. package/target/test/impl/ImplTest.spec.js.map +1 -1
  82. package/target/test/impl/ImplTest_23.spec.js +2 -2
  83. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  84. package/target/test/xhrCore/NamespacesRequestTest.spec.js +199 -0
  85. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  86. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  87. package/target/test/xhrCore/ResponseTest.spec.js +7 -3
  88. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  89. package/target/test-classes/.gz +0 -0
  90. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  91. package/target/test-classes/fileuploadtest.html +24 -0
  92. package/target/test-classes/jsf-development.js +3559 -0
  93. package/target/test-classes/jsf-development.js.br +0 -0
  94. package/target/test-classes/jsf-development.js.gz +0 -0
  95. package/target/test-classes/jsf-development.js.map +1 -0
  96. package/target/test-classes/jsf.js +3 -0
  97. package/target/test-classes/jsf.js.br +0 -0
  98. package/target/test-classes/jsf.js.gz +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "4.0.0-RC.13",
3
+ "version": "4.0.0-RC.14",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/faces.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "devDependencies": {
23
23
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
24
24
  "@types/chai": "^4.3.4",
25
- "@types/mocha": "^10.0.0",
25
+ "@types/mocha": "^10.0.1",
26
26
  "@types/node": "^18.11.9",
27
27
  "@types/sinon": "^10.0.13",
28
28
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
@@ -37,7 +37,7 @@
37
37
  "nyc": "^15.1.0",
38
38
  "replace-in-file": "^6.3.5",
39
39
  "rxjs": "^7.5.7",
40
- "sinon": "^14.0.2",
40
+ "sinon": "^15.0.0",
41
41
  "terser-webpack-plugin": "^5.3.6",
42
42
  "ts-loader": "^9.4.1",
43
43
  "ts-node": "^10.9.1",
@@ -48,6 +48,6 @@
48
48
  "webpack-dev-server": "^4.11.1"
49
49
  },
50
50
  "dependencies": {
51
- "mona-dish": "^0.23.9"
51
+ "mona-dish": "^0.23.10"
52
52
  }
53
53
  }
@@ -134,6 +134,8 @@ declare global {
134
134
  };
135
135
  }
136
136
 
137
+
138
+
137
139
  /*
138
140
  * Global namespaces type definitions
139
141
  */
@@ -16,7 +16,7 @@
16
16
  import {Implementation} from "../impl/AjaxImpl";
17
17
  import {PushImpl} from "../impl/PushImpl";
18
18
  import {oam as _oam} from "../myfaces/OamSubmit";
19
- import {$nsp, CTX_PARAM_EXECUTE, CTX_PARAM_RENDER, P_BEHAVIOR_EVENT} from "../impl/core/Const";
19
+ import {$nsp, CTX_OPTIONS_EXECUTE, CTX_PARAM_RENDER, P_BEHAVIOR_EVENT} from "../impl/core/Const";
20
20
  import {ErrorData} from "../impl/xhrCore/ErrorData";
21
21
  import {EventData} from "../impl/xhrCore/EventData";
22
22
 
@@ -257,7 +257,7 @@ export module myfaces {
257
257
  options[$nsp(P_BEHAVIOR_EVENT)] = eventName;
258
258
  }
259
259
  if (execute) {
260
- options[CTX_PARAM_EXECUTE] = execute;
260
+ options[CTX_OPTIONS_EXECUTE] = execute;
261
261
  }
262
262
  if (render) {
263
263
  options[CTX_PARAM_RENDER] = render;
@@ -27,11 +27,10 @@ import {EventData} from "./xhrCore/EventData";
27
27
  import {ExtLang} from "./util/Lang";
28
28
 
29
29
  import {
30
- CTX_PARAM_EXECUTE,
31
- CTX_PARAM_PASS_THR,
30
+ CTX_OPTIONS_EXECUTE,
31
+ CTX_PARAM_REQ_PASS_THR,
32
32
  CTX_PARAM_SRC_CTL_ID,
33
33
  CTX_PARAM_SRC_FRM_ID,
34
- CTX_PARAM_TR_TYPE,
35
34
  IDENT_ALL,
36
35
  IDENT_FORM,
37
36
  IDENT_NONE,
@@ -48,15 +47,14 @@ import {
48
47
  P_RESET_VALUES,
49
48
  P_WINDOW_ID,
50
49
  CTX_PARAM_RENDER,
51
- REQ_TYPE_POST,
52
50
  SOURCE,
53
- TAG_FORM, CTX_PARAM_SPEC_PARAMS
51
+ HTML_TAG_FORM, CTX_OPTIONS_PARAMS, VIEW_ID, $faces
54
52
  } from "./core/Const";
55
53
  import {
56
54
  resolveDefaults,
57
55
  resolveDelay,
58
56
  resolveForm,
59
- resolveTimeout
57
+ resolveTimeout, resolveViewId
60
58
  } from "./xhrCore/RequestDataResolver";
61
59
 
62
60
  /*
@@ -263,6 +261,7 @@ export module Implementation {
263
261
  * with detached objects
264
262
  */
265
263
  const form: DQ = resolveForm(requestCtx, elem, resolvedEvent);
264
+ const viewId: string = resolveViewId(form);
266
265
  const formId = form.id.value;
267
266
  const delay: number = resolveDelay(options);
268
267
  const timeout: number = resolveTimeout(options);
@@ -270,12 +269,12 @@ export module Implementation {
270
269
  requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;
271
270
 
272
271
  // old non spec behavior will be removed after it is clear whether the removal breaks any code
273
- requestCtx.assign(CTX_PARAM_PASS_THR).value = filterPassThroughValues(options.value);
272
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR).value = filterPassThroughValues(options.value);
274
273
 
275
274
  // spec conform behavior, all passthrough params must be under "passthrough
276
- const params = remapArrayToAssocArr(options.getIf(CTX_PARAM_SPEC_PARAMS).orElse({}).value);
277
- requestCtx.getIf(CTX_PARAM_PASS_THR).shallowMerge(new Config(params), true);
278
- requestCtx.assignIf(!!resolvedEvent, CTX_PARAM_PASS_THR, P_EVT).value = resolvedEvent?.type;
275
+ const params = remapArrayToAssocArr(options.getIf(CTX_OPTIONS_PARAMS).orElse({}).value);
276
+ requestCtx.getIf(CTX_PARAM_REQ_PASS_THR).shallowMerge(new Config(params), true);
277
+ requestCtx.assignIf(!!resolvedEvent, CTX_PARAM_REQ_PASS_THR, P_EVT).value = resolvedEvent?.type;
279
278
 
280
279
  /**
281
280
  * ajax pass through context with the source
@@ -283,6 +282,8 @@ export module Implementation {
283
282
  */
284
283
  requestCtx.assign(SOURCE).value = elementId;
285
284
 
285
+ requestCtx.assign(VIEW_ID).value = viewId;
286
+
286
287
  /**
287
288
  * on resolvedEvent and onError...
288
289
  * those values will be traversed later on
@@ -299,12 +300,12 @@ export module Implementation {
299
300
  /**
300
301
  * binding contract the jakarta.faces.source must be set
301
302
  */
302
- requestCtx.assign(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
303
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value = elementId;
303
304
 
304
305
  /**
305
306
  * jakarta.faces.partial.ajax must be set to true
306
307
  */
307
- requestCtx.assign(CTX_PARAM_PASS_THR, P_AJAX).value = true;
308
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, P_AJAX).value = true;
308
309
 
309
310
  /**
310
311
  * if resetValues is set to true
@@ -313,7 +314,7 @@ export module Implementation {
313
314
  * the value has to be explicitly true, according to
314
315
  * the specs jsdoc
315
316
  */
316
- requestCtx.assignIf(isResetValues, CTX_PARAM_PASS_THR, P_RESET_VALUES).value = true;
317
+ requestCtx.assignIf(isResetValues, CTX_PARAM_REQ_PASS_THR, P_RESET_VALUES).value = true;
317
318
 
318
319
  // additional meta information to speed things up, note internal non jsf
319
320
  // pass through options are stored under _mfInternal in the context
@@ -324,9 +325,8 @@ export module Implementation {
324
325
  // mojarra under blackbox conditions.
325
326
  // I assume it does the same as our formId_submit=1 so leaving it out
326
327
  // won't hurt but for the sake of compatibility we are going to add it
327
- requestCtx.assign(CTX_PARAM_PASS_THR, formId).value = formId;
328
+ requestCtx.assign(CTX_PARAM_REQ_PASS_THR, formId).value = formId;
328
329
  internalCtx.assign(CTX_PARAM_SRC_CTL_ID).value = elementId;
329
- internalCtx.assign(CTX_PARAM_TR_TYPE).value = REQ_TYPE_POST;
330
330
 
331
331
  assignClientWindowId(form, requestCtx);
332
332
  assignExecute(options, requestCtx, form, elementId);
@@ -512,7 +512,7 @@ export module Implementation {
512
512
  */
513
513
 
514
514
  let element: DQ = DQ.byId(form, true);
515
- if (!element.isTag(TAG_FORM)) {
515
+ if (!element.isTag(HTML_TAG_FORM)) {
516
516
  throw new Error(getMessage("ERR_VIEWSTATE"));
517
517
  }
518
518
 
@@ -553,7 +553,7 @@ export module Implementation {
553
553
  */
554
554
  function assignRender(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
555
555
  if (requestOptions.getIf(CTX_PARAM_RENDER).isPresent()) {
556
- remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_RENDER, <string>requestOptions.getIf(CTX_PARAM_RENDER).value, issuingForm, <any>sourceElementId);
556
+ 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);
557
557
  }
558
558
  }
559
559
 
@@ -571,15 +571,15 @@ export module Implementation {
571
571
  */
572
572
  function assignExecute(requestOptions: Config, targetContext: Config, issuingForm: DQ, sourceElementId: string) {
573
573
 
574
- if (requestOptions.getIf(CTX_PARAM_EXECUTE).isPresent()) {
574
+ if (requestOptions.getIf(CTX_OPTIONS_EXECUTE).isPresent()) {
575
575
  /*the options must be a blank delimited list of strings*/
576
576
  /*compliance with Mojarra which automatically adds @this to an execute
577
577
  * the spec rev 2.0a however states, if none is issued nothing at all should be sent down
578
578
  */
579
- requestOptions.assign(CTX_PARAM_EXECUTE).value = [requestOptions.getIf(CTX_PARAM_EXECUTE).value, IDENT_THIS].join(" ");
580
- remapDefaultConstants(targetContext.getIf(CTX_PARAM_PASS_THR).get({}), P_EXECUTE, <string>requestOptions.getIf(CTX_PARAM_EXECUTE).value, issuingForm, <any>sourceElementId);
579
+ requestOptions.assign(CTX_OPTIONS_EXECUTE).value = [requestOptions.getIf(CTX_OPTIONS_EXECUTE).value, IDENT_THIS].join(" ");
580
+ 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);
581
581
  } else {
582
- targetContext.assign(CTX_PARAM_PASS_THR, P_EXECUTE).value = sourceElementId;
582
+ targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value = sourceElementId;
583
583
  }
584
584
  }
585
585
 
@@ -591,9 +591,9 @@ export module Implementation {
591
591
  */
592
592
  function assignClientWindowId(form: DQ, targetContext: Config) {
593
593
 
594
- let clientWindow = (window?.faces ?? window?.jsf).getClientWindow(form.getAsElem(0).value);
594
+ let clientWindow = $faces().getClientWindow(form.getAsElem(0).value);
595
595
  if (clientWindow) {
596
- targetContext.assign(CTX_PARAM_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;
596
+ targetContext.assign(CTX_PARAM_REQ_PASS_THR, P_CLIENT_WINDOW).value = clientWindow;
597
597
  }
598
598
  }
599
599
 
@@ -611,14 +611,25 @@ export module Implementation {
611
611
  * @param userValues the passed user values (aka input string which needs to be transformed)
612
612
  * @param issuingForm the form where the issuing element originates
613
613
  * @param issuingElementId the issuing element
614
+ * @param viewId the naming container id ("" default if none is given)
614
615
  */
615
- function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string): Config {
616
+ function remapDefaultConstants(targetConfig: Config, targetKey: string, userValues: string, issuingForm: DQ, issuingElementId: string, viewId: string = ""): Config {
616
617
  //a cleaner implementation of the transform list method
617
-
618
+ const SEP = $faces().separatorchar;
618
619
  let iterValues: string[] = (userValues) ? trim(userValues).split(/\s+/gi) : [];
619
620
  let ret = [];
620
621
  let processed: {[key: string]: boolean} = {};
621
622
 
623
+ //TODO check if this is right
624
+ const remapNamingContainer = item => {
625
+ if(item.indexOf(SEP) === 0 && viewId !== "") {
626
+ item = [viewId, SEP, item.substring(1)].join("");
627
+ } else if(item.indexOf(SEP) === 0) {
628
+ item = item.substring(1);
629
+ }
630
+ return item;
631
+ };
632
+
622
633
  // in this case we do not use lazy stream because it wont bring any code reduction
623
634
  // or speedup
624
635
  for (let cnt = 0; cnt < iterValues.length; cnt++) {
@@ -636,22 +647,22 @@ export module Implementation {
636
647
  return targetConfig;
637
648
  //@form pushes the issuing form id into our list
638
649
  case IDENT_FORM:
639
- ret.push(issuingForm.id.value);
650
+ ret.push(remapNamingContainer(issuingForm.id.value));
640
651
  processed[issuingForm.id.value] = true;
641
652
  break;
642
653
  //@this is replaced with the current issuing element id
643
654
  case IDENT_THIS:
644
655
  if (!(issuingElementId in processed)) {
645
- ret.push(issuingElementId);
656
+ ret.push(remapNamingContainer(issuingElementId));
646
657
  processed[issuingElementId] = true;
647
658
  }
648
659
  break;
649
660
  default:
650
- ret.push(iterValues[cnt]);
661
+ ret.push(remapNamingContainer(iterValues[cnt]));
651
662
  processed[iterValues[cnt]] = true;
652
663
  }
653
664
  }
654
- //We now add the target as joined list
665
+
655
666
  targetConfig.assign(targetKey).value = ret.join(" ");
656
667
  return targetConfig;
657
668
  }
@@ -17,8 +17,11 @@
17
17
  /*
18
18
  * [export const] constants
19
19
  */
20
+
21
+
20
22
  export const P_PARTIAL_SOURCE = "jakarta.faces.source";
21
23
  export const PARTIAL_ID = "partialId";
24
+ export const VIEW_ID = "myfaves.viewId";
22
25
  export const P_VIEWSTATE = "jakarta.faces.ViewState";
23
26
  export const P_CLIENT_WINDOW = "jakarta.faces.ClientWindow";
24
27
  export const P_VIEWROOT = "jakarta.faces.ViewRoot";
@@ -91,21 +94,16 @@ export const SERVER_ERROR = "serverError";
91
94
  export const CLIENT_ERROR = "clientError";
92
95
  export const TIMEOUT_EVENT = "timeout";
93
96
 
94
- export const CTX_PARAM_MF_INTERNAL = "_mfInternal";
95
-
96
- export const CTX_PARAM_SRC_FRM_ID = "_mfSourceFormId";
97
- export const CTX_PARAM_SRC_CTL_ID = "_mfSourceControlId";
98
- export const CTX_PARAM_TR_TYPE = "_mfTransportType";
99
- export const CTX_PARAM_PASS_THR = "passThrgh";
100
- export const CTX_PARAM_SPEC_PARAMS = "params";
101
-
102
- export const CTX_PARAM_DELAY = "delay";
103
- export const CTX_PARAM_TIMEOUT = "timeout";
104
- export const CTX_PARAM_RST = "resetValues";
105
- export const CTX_PARAM_EXECUTE = "execute";
106
-
107
- export const STAGE_DEVELOPMENT = "Development";
97
+ export const CTX_OPTIONS_PARAMS = "params";
98
+ export const CTX_OPTIONS_DELAY = "delay";
99
+ export const CTX_OPTIONS_TIMEOUT = "timeout";
100
+ export const CTX_OPTIONS_RESET = "resetValues";
101
+ export const CTX_OPTIONS_EXECUTE = "execute";
108
102
 
103
+ export const CTX_PARAM_MF_INTERNAL = "myfaces.internal";
104
+ export const CTX_PARAM_SRC_FRM_ID = "myfaces.source.formId";
105
+ export const CTX_PARAM_SRC_CTL_ID = "myfaces.source.controlId";
106
+ export const CTX_PARAM_REQ_PASS_THR = "myfaces.request.passThrough";
109
107
 
110
108
  export const CONTENT_TYPE = "Content-Type";
111
109
  export const HEAD_FACES_REQ = "Faces-Request";
@@ -122,13 +120,12 @@ export const MULTIPART = "multipart/form-data";
122
120
  export const NO_TIMEOUT = 0;
123
121
  export const STD_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
124
122
 
125
- export const TAG_HEAD = "HEAD";
126
- export const TAG_FORM = "FORM";
127
- export const TAG_BODY = "BODY";
128
- export const TAG_BEFORE = "before";
129
- export const TAG_AFTER = "after";
130
-
131
- export const TAG_ATTR = "attribute";
123
+ export const HTML_TAG_HEAD = "HEAD";
124
+ export const HTML_TAG_FORM = "FORM";
125
+ export const HTML_TAG_BODY = "BODY";
126
+ export const HTML_TAG_LINK = "LINK";
127
+ export const HTML_TAG_SCRIPT = "SCRIPT";
128
+ export const HTML_TAG_STYLE = "STYLE";
132
129
 
133
130
 
134
131
  export const SEL_VIEWSTATE_ELEM = "[name='" + P_VIEWSTATE + "']";
@@ -146,38 +143,40 @@ export const ATTR_VALUE = "value";
146
143
  export const ATTR_ID = "id";
147
144
 
148
145
  /*partial response types*/
149
- export const RESP_PARTIAL = "partial-response";
146
+ export const XML_TAG_PARTIAL_RESP = "partial-response";
150
147
 
151
148
  /*partial commands*/
152
- export const CMD_CHANGES = "changes";
153
- export const CMD_UPDATE = "update";
154
- export const CMD_DELETE = "delete";
155
- export const CMD_INSERT = "insert";
156
- export const CMD_EVAL = "eval";
157
- export const CMD_ERROR = "error";
158
- export const CMD_ATTRIBUTES = "attributes";
159
- export const CMD_EXTENSION = "extension";
160
- export const CMD_REDIRECT = "redirect";
149
+ export const XML_TAG_CHANGES = "changes";
150
+ export const XML_TAG_UPDATE = "update";
151
+ export const XML_TAG_DELETE = "delete";
152
+ export const XML_TAG_INSERT = "insert";
153
+ export const XML_TAG_EVAL = "eval";
154
+ export const XML_TAG_ERROR = "error";
155
+ export const XML_TAG_ATTRIBUTES = "attributes";
156
+ export const XML_TAG_EXTENSION = "extension";
157
+ export const XML_TAG_REDIRECT = "redirect";
158
+ export const XML_TAG_BEFORE = "before";
159
+ export const XML_TAG_AFTER = "after";
160
+ export const XML_TAG_ATTR = "attribute";
161
+
161
162
 
162
163
  /*other constants*/
163
164
 
164
- export const UPDATE_FORMS = "_updateForms";
165
- export const UPDATE_ELEMS = "_updateElems";
165
+ export const UPDATE_FORMS = "myfaces.updateForms";
166
+ export const UPDATE_ELEMS = "myfaces.updateElems";
166
167
 
167
168
  //we want the head elements to be processed before we process the body
168
169
  //but after the inner html is done
169
- export const DEFERRED_HEAD_INSERTS = "_headElems";
170
+ export const DEFERRED_HEAD_INSERTS = "myfaces.headElems";
170
171
 
171
172
  export const MYFACES = "myfaces";
172
173
 
173
- export const SEL_SCRIPTS_STYLES = "script, style, link";
174
-
175
174
  export const MF_NONE = "__mf_none__";
176
175
 
177
176
  export const REASON_EXPIRED = "Expired";
178
177
 
179
- export const APPLIED_VST = "appliedViewState";
180
- export const APPLIED_CLIENT_WINDOW = "appliedClientWindow";
178
+ export const APPLIED_VST = "myfaces.appliedViewState";
179
+ export const APPLIED_CLIENT_WINDOW = "myfaces.appliedClientWindow";
181
180
 
182
181
  export const RECONNECT_INTERVAL = 500;
183
182
  export const MAX_RECONNECT_ATTEMPTS = 25;
@@ -192,6 +191,10 @@ export const UNKNOWN = "UNKNOWN";
192
191
  * changed to a simple value passthrough
193
192
  */
194
193
 
194
+ export function $faces(): FacesAPI {
195
+ return (window?.faces ?? window?.jsf) as FacesAPI;
196
+ }
197
+
195
198
  export function $nsp(inputNamespace?: any): any {
196
199
  if((!inputNamespace) || !inputNamespace?.replace) {
197
200
  return inputNamespace;
@@ -0,0 +1,19 @@
1
+ import {Config} from "mona-dish";
2
+
3
+
4
+
5
+ export class Context {
6
+ P_PARTIAL_SOURCE?: string;
7
+ PARTIAL_ID?: string;
8
+ P_WINDOW_ID?:string;
9
+ VIEW_ID?: string;
10
+ P_VIEWSTATE?: string;
11
+ P_CLIENT_WINDOW?: string;
12
+ SOURCE: string;
13
+ CTX_PARAM_SRC_FRM_ID?: string;
14
+ CTX_PARAM_SRC_CTL_ID?: string;
15
+ ON_EVENT ?: (HTMLEvent) => boolean | void;
16
+ ON_ERROR ?: (HTMLEvent) => boolean | void;
17
+ MYFACES ?: Config;
18
+ CTX_PARAM_REQ_PASS_THR = {};
19
+ }
@@ -23,7 +23,7 @@ import {
23
23
  ON_ERROR,
24
24
  ON_EVENT,
25
25
  PHASE_PROCESS_RESPONSE,
26
- RESP_PARTIAL
26
+ XML_TAG_PARTIAL_RESP
27
27
  } from "../core/Const";
28
28
  import {ExtLang} from "./Lang";
29
29
 
@@ -60,7 +60,7 @@ export module Assertions {
60
60
  export function assertValidXMLResponse(responseXML: XMLQuery) : void | never {
61
61
  assert(!responseXML.isAbsent(), EMPTY_RESPONSE, PHASE_PROCESS_RESPONSE);
62
62
  assert(!responseXML.isXMLParserError(), responseXML.parserErrorText(EMPTY_STR), PHASE_PROCESS_RESPONSE);
63
- assert(responseXML.querySelectorAll(RESP_PARTIAL).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);
63
+ assert(responseXML.querySelectorAll(XML_TAG_PARTIAL_RESP).isPresent(), ERR_NO_PARTIAL_RESPONSE, PHASE_PROCESS_RESPONSE);
64
64
  }
65
65
 
66
66
  /**
@@ -201,8 +201,8 @@ export class ExtDomQuery extends DQ {
201
201
  return true;
202
202
  }
203
203
  let reference = element.attr("href")
204
- .orElse(element.attr("src").value)
205
- .orElse(element.attr("rel").value);
204
+ .orElseLazy(() => element.attr("src").value)
205
+ .orElseLazy(() => element.attr("rel").value);
206
206
 
207
207
  if (!reference.isPresent()) {
208
208
  return true;
@@ -0,0 +1,63 @@
1
+ /*! Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import {DomQuery, DQ, DQ$} from "mona-dish";
19
+ import {$faces, $nsp, HTML_CLIENT_WINDOW, HTML_VIEWSTATE, P_CLIENT_WINDOW, P_VIEWSTATE} from "../core/Const";
20
+
21
+ /**
22
+ * Builder for hidden inputs.
23
+ * ATM only ViewState and Client window
24
+ * are supported (per spec)
25
+ *
26
+ * Improves readability in the response processor!
27
+ */
28
+ export class HiddenInputBuilder {
29
+ private namingContainerId?: string;
30
+ private parent?: DomQuery;
31
+ private readonly name: string;
32
+ private readonly template: string;
33
+
34
+ constructor(private selector: string) {
35
+ const isViewState = selector.indexOf($nsp(P_VIEWSTATE)) != -1;
36
+ this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW
37
+ this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW
38
+ }
39
+
40
+ withNamingContainerId(namingContainer: string): HiddenInputBuilder {
41
+ this.namingContainerId = namingContainer;
42
+ return this;
43
+ }
44
+
45
+ withParent(parent: DomQuery): HiddenInputBuilder {
46
+ this.parent = parent;
47
+ return this;
48
+ }
49
+
50
+
51
+ build(): DomQuery {
52
+ //TODO naming container id?
53
+ const cnt = DQ$(`[name='${$nsp(this.name)}']`).length;
54
+ const SEP = $faces().separatorchar;
55
+ const newElement = DQ.fromMarkup($nsp(this.template));
56
+ newElement.id.value = ((this.namingContainerId?.length) ?
57
+ [this.namingContainerId, $nsp(this.name), cnt]:
58
+ [$nsp(this.name), cnt]).join(SEP);
59
+
60
+ this?.parent?.append(newElement);
61
+ return newElement;
62
+ }
63
+ }
@@ -13,13 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  *
16
- * todo replace singleton with module definition
17
- *
18
16
  */
19
17
 
20
18
  import {Lang as LangBase, Config, Optional, DomQuery, DQ, Stream} from "mona-dish";
21
19
  import {Messages} from "../i18n/Messages";
22
- import {EMPTY_STR, TAG_FORM} from "../core/Const";
20
+ import {EMPTY_STR, HTML_TAG_FORM} from "../core/Const";
23
21
  import {getEventTarget} from "../xhrCore/RequestDataResolver";
24
22
 
25
23
 
@@ -162,23 +160,23 @@ export module ExtLang {
162
160
  let queryElem = new DQ(elem);
163
161
  let eventTarget = (event) ? new DQ(getEventTarget(event)) : DomQuery.absent;
164
162
 
165
- if (queryElem.isTag(TAG_FORM)) {
163
+ if (queryElem.isTag(HTML_TAG_FORM)) {
166
164
  return queryElem;
167
165
  }
168
166
 
169
167
  //html 5 for handling
170
- if (queryElem.attr(TAG_FORM).isPresent()) {
171
- let formId = queryElem.attr(TAG_FORM).value;
168
+ if (queryElem.attr(HTML_TAG_FORM).isPresent()) {
169
+ let formId = queryElem.attr(HTML_TAG_FORM).value;
172
170
  let foundForm = DQ.byId(formId, true);
173
171
  if (foundForm.isPresent()) {
174
172
  return foundForm;
175
173
  }
176
174
  }
177
175
 
178
- let form = queryElem.firstParent(TAG_FORM)
179
- .orElseLazy(() => queryElem.byTagName(TAG_FORM, true))
180
- .orElseLazy(() => eventTarget.firstParent(TAG_FORM))
181
- .orElseLazy(() => eventTarget.byTagName(TAG_FORM))
176
+ let form = queryElem.firstParent(HTML_TAG_FORM)
177
+ .orElseLazy(() => queryElem.byTagName(HTML_TAG_FORM, true))
178
+ .orElseLazy(() => eventTarget.firstParent(HTML_TAG_FORM))
179
+ .orElseLazy(() => eventTarget.byTagName(HTML_TAG_FORM))
182
180
  .first();
183
181
 
184
182
  assertFormExists(form);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import {Config, DQ} from "mona-dish";
17
- import {BEGIN, CTX_PARAM_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
17
+ import {BEGIN, CTX_PARAM_REQ_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
18
18
 
19
19
  export class EventData implements IEventData{
20
20
  type: string;
@@ -33,7 +33,7 @@ export class EventData implements IEventData{
33
33
 
34
34
  let sourceId: string = context.getIf(SOURCE)
35
35
  .orElseLazy(() => context.getIf(P_PARTIAL_SOURCE).value)
36
- .orElseLazy(() => context.getIf(CTX_PARAM_PASS_THR, P_PARTIAL_SOURCE).value)
36
+ .orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value)
37
37
  .value;
38
38
  if (sourceId) {
39
39
  eventData.source = DQ.byId(sourceId, true).first().value.value;
@@ -16,12 +16,14 @@
16
16
 
17
17
  import {AssocArrayCollector, Config, DomQuery, DQ, Stream} from "mona-dish";
18
18
  import {
19
- CTX_PARAM_DELAY,
20
- CTX_PARAM_TIMEOUT,
19
+ $faces,
20
+ $nsp,
21
+ CTX_OPTIONS_DELAY,
22
+ CTX_OPTIONS_TIMEOUT,
21
23
  EMPTY_FUNC,
22
24
  EMPTY_STR,
23
25
  ENCODED_URL,
24
- MF_NONE,
26
+ MF_NONE, P_VIEWSTATE,
25
27
  REQ_TYPE_GET,
26
28
  REQ_TYPE_POST
27
29
  } from "../core/Const";
@@ -80,9 +82,19 @@ export function resolveForm(requestCtx: Config, elem: DQ, event: Event): DQ {
80
82
  .orElseLazy(() => ExtLang.getForm(elem.getAsElem(0).value, event));
81
83
  }
82
84
 
85
+ export function resolveViewId(form: DQ): string {
86
+ let viewState = form.querySelectorAll(`input[type='hidden'][name*='${$nsp(P_VIEWSTATE)}']`).id.orElse("").value;
87
+ let divider = $faces().separatorchar;
88
+ let viewId = viewState.split(divider, 2)[0];
89
+ if(viewId.indexOf($nsp(P_VIEWSTATE)) === -1) {
90
+ return viewId;
91
+ }
92
+ return "";
93
+ }
94
+
83
95
  export function resolveTimeout(options: Config): number {
84
96
  let getCfg = ExtLang.getLocalOrGlobalConfig;
85
- return options.getIf(CTX_PARAM_TIMEOUT).value ?? getCfg(options.value, CTX_PARAM_TIMEOUT, 0);
97
+ return options.getIf(CTX_OPTIONS_TIMEOUT).value ?? getCfg(options.value, CTX_OPTIONS_TIMEOUT, 0);
86
98
  }
87
99
 
88
100
  /**
@@ -94,7 +106,7 @@ export function resolveDelay(options: Config): number {
94
106
  let getCfg = ExtLang.getLocalOrGlobalConfig;
95
107
 
96
108
  // null or non undefined will automatically be mapped to 0 aka no delay
97
- let ret = options.getIf(CTX_PARAM_DELAY).value ?? getCfg(options.value, CTX_PARAM_DELAY, 0);
109
+ let ret = options.getIf(CTX_OPTIONS_DELAY).value ?? getCfg(options.value, CTX_OPTIONS_DELAY, 0);
98
110
  // if delay === none, no delay must be used, aka delay 0
99
111
  if('none' === ret) {
100
112
  ret = 0;
@@ -25,7 +25,7 @@ import {
25
25
  CTX_PARAM_SRC_FRM_ID,
26
26
  SEL_RESPONSE_XML,
27
27
  SOURCE,
28
- TAG_FORM,
28
+ HTML_TAG_FORM,
29
29
  UPDATE_ELEMS,
30
30
  UPDATE_FORMS,
31
31
  DEFERRED_HEAD_INSERTS
@@ -106,9 +106,9 @@ export function resolveSourceForm(internalContext: Config, elem: DQ): DQ {
106
106
  let sourceFormId = internalContext.getIf(CTX_PARAM_SRC_FRM_ID);
107
107
  let sourceForm = new DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);
108
108
 
109
- sourceForm = sourceForm.orElseLazy(() => elem.firstParent(TAG_FORM))
110
- .orElseLazy(() => elem.querySelectorAll(TAG_FORM))
111
- .orElseLazy(() => DQ.querySelectorAll(TAG_FORM));
109
+ sourceForm = sourceForm.orElseLazy(() => elem.firstParent(HTML_TAG_FORM))
110
+ .orElseLazy(() => elem.querySelectorAll(HTML_TAG_FORM))
111
+ .orElseLazy(() => DQ.querySelectorAll(HTML_TAG_FORM));
112
112
 
113
113
  return sourceForm;
114
114
  }