jsf.js_next_gen 4.0.2-beta.9 → 4.0.3-beta.2

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 (35) hide show
  1. package/dist/window/faces-development.js +71 -37
  2. package/dist/window/faces-development.js.map +1 -1
  3. package/dist/window/faces.js +1 -1
  4. package/dist/window/faces.js.map +1 -1
  5. package/dist/window/jsf-development.js +71 -37
  6. package/dist/window/jsf-development.js.map +1 -1
  7. package/dist/window/jsf.js +1 -1
  8. package/dist/window/jsf.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/main/typescript/impl/PushImpl.ts +1 -1
  11. package/src/main/typescript/impl/core/Const.ts +1 -1
  12. package/src/main/typescript/impl/xhrCore/ErrorData.ts +20 -15
  13. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +77 -26
  14. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  15. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +3 -3
  16. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +3 -3
  17. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +2 -2
  18. package/target/impl/PushImpl.js +3 -3
  19. package/target/impl/PushImpl.js.map +1 -1
  20. package/target/impl/core/Const.js +2 -2
  21. package/target/impl/core/Const.js.map +1 -1
  22. package/target/impl/xhrCore/ErrorData.js +11 -10
  23. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  24. package/target/impl/xhrCore/XhrRequest.js +49 -21
  25. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  26. package/target/test/xhrCore/EventTests.spec.js +1 -1
  27. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  28. package/target/test/xhrCore/RequestTest.spec.js +3 -4
  29. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  30. package/target/test/xhrCore/RequestTest_23.spec.js +3 -3
  31. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  32. package/target/test/xhrCore/ResponseTest.spec.js +2 -2
  33. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  34. package/webpack.config.js +54 -0
  35. package/webpack.config.js.map +1 -0
@@ -5154,14 +5154,14 @@ var PushImpl;
5154
5154
  this.reconnectAttempts = 0;
5155
5155
  }
5156
5156
  onerror(event) {
5157
- var _a, _b;
5158
- let message = JSON.parse(event.data);
5157
+ var _a, _b, _c;
5158
+ let message = JSON.parse((_a = event === null || event === void 0 ? void 0 : event.data) !== null && _a !== void 0 ? _a : null);
5159
5159
  //TODO replace this with a more readable Stream code
5160
5160
  for (let i = PushImpl.clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
5161
5161
  let socketClientId = PushImpl.clientIdsByTokens[this.channelToken][i];
5162
5162
  if (document.getElementById(socketClientId)) {
5163
5163
  try {
5164
- (_b = (_a = PushImpl.components[socketClientId]) === null || _a === void 0 ? void 0 : _a['onerror']) === null || _b === void 0 ? void 0 : _b.call(_a, message, this.channel, event);
5164
+ (_c = (_b = PushImpl.components[socketClientId]) === null || _b === void 0 ? void 0 : _b['onerror']) === null || _c === void 0 ? void 0 : _c.call(_b, message, this.channel, event);
5165
5165
  }
5166
5166
  catch (e) {
5167
5167
  //Ignore
@@ -5303,7 +5303,7 @@ var PushImpl;
5303
5303
  * limitations under the License.
5304
5304
  */
5305
5305
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5306
- exports.CTX_OPTIONS_PARAMS = exports.TIMEOUT_EVENT = exports.CLIENT_ERROR = exports.SERVER_ERROR = exports.MALFORMEDXML = exports.EMPTY_RESPONSE = exports.HTTPERROR = exports.RESPONSE_XML = exports.RESPONSE_TEXT = exports.ERROR_MESSAGE = exports.ERROR_NAME = exports.STATUS = exports.SOURCE = exports.SUCCESS = exports.COMPLETE = exports.BEGIN = exports.ON_EVENT = exports.ON_ERROR = exports.EVENT = exports.ERROR = exports.WINDOW_ID = exports.CTX_PARAM_RENDER = exports.P_BEHAVIOR_EVENT = exports.P_WINDOW_ID = exports.P_RESET_VALUES = exports.P_EVT = exports.P_RENDER_OVERRIDE = exports.P_RENDER = exports.P_EXECUTE = exports.P_AJAX = exports.IDENT_FORM = exports.IDENT_THIS = exports.IDENT_NONE = exports.IDENT_ALL = exports.HTML_CLIENT_WINDOW = exports.HTML_VIEWSTATE = exports.EMPTY_MAP = exports.EMPTY_STR = exports.EMPTY_FUNC = exports.P_RESOURCE = exports.P_VIEWBODY = exports.P_VIEWHEAD = exports.P_VIEWROOT = exports.P_CLIENT_WINDOW = exports.P_VIEWSTATE = exports.VIEW_ID = exports.NAMING_CONTAINER_ID = exports.P_AJAX_SOURCE = exports.NAMED_VIEWROOT = exports.XML_ATTR_NAMED_VIEWROOT = void 0;
5306
+ exports.CTX_OPTIONS_PARAMS = exports.TIMEOUT_EVENT = exports.CLIENT_ERROR = exports.SERVER_ERROR = exports.MALFORMEDXML = exports.EMPTY_RESPONSE = exports.HTTP_ERROR = exports.RESPONSE_XML = exports.RESPONSE_TEXT = exports.ERROR_MESSAGE = exports.ERROR_NAME = exports.STATUS = exports.SOURCE = exports.SUCCESS = exports.COMPLETE = exports.BEGIN = exports.ON_EVENT = exports.ON_ERROR = exports.EVENT = exports.ERROR = exports.WINDOW_ID = exports.CTX_PARAM_RENDER = exports.P_BEHAVIOR_EVENT = exports.P_WINDOW_ID = exports.P_RESET_VALUES = exports.P_EVT = exports.P_RENDER_OVERRIDE = exports.P_RENDER = exports.P_EXECUTE = exports.P_AJAX = exports.IDENT_FORM = exports.IDENT_THIS = exports.IDENT_NONE = exports.IDENT_ALL = exports.HTML_CLIENT_WINDOW = exports.HTML_VIEWSTATE = exports.EMPTY_MAP = exports.EMPTY_STR = exports.EMPTY_FUNC = exports.P_RESOURCE = exports.P_VIEWBODY = exports.P_VIEWHEAD = exports.P_VIEWROOT = exports.P_CLIENT_WINDOW = exports.P_VIEWSTATE = exports.VIEW_ID = exports.NAMING_CONTAINER_ID = exports.P_AJAX_SOURCE = exports.NAMED_VIEWROOT = exports.XML_ATTR_NAMED_VIEWROOT = void 0;
5307
5307
  exports.XML_TAG_REDIRECT = exports.XML_TAG_EXTENSION = exports.XML_TAG_ATTRIBUTES = exports.XML_TAG_ERROR = exports.XML_TAG_EVAL = exports.XML_TAG_INSERT = exports.XML_TAG_DELETE = exports.XML_TAG_UPDATE = exports.XML_TAG_CHANGES = exports.XML_TAG_PARTIAL_RESP = exports.ATTR_ID = exports.ATTR_VALUE = exports.ATTR_NAME = exports.ATTR_URL = exports.MYFACES_OPTION_PPS = exports.ERR_NO_PARTIAL_RESPONSE = exports.PHASE_PROCESS_RESPONSE = exports.SEL_RESPONSE_XML = exports.SEL_CLIENT_WINDOW_ELEM = exports.SEL_VIEWSTATE_ELEM = exports.HTML_TAG_STYLE = exports.HTML_TAG_SCRIPT = exports.HTML_TAG_LINK = exports.HTML_TAG_BODY = exports.HTML_TAG_FORM = exports.HTML_TAG_HEAD = exports.STD_ACCEPT = exports.NO_TIMEOUT = exports.MULTIPART = exports.URL_ENCODED = exports.STATE_EVT_COMPLETE = exports.STATE_EVT_TIMEOUT = exports.STATE_EVT_BEGIN = exports.REQ_TYPE_POST = exports.REQ_TYPE_GET = exports.ENCODED_URL = exports.VAL_AJAX = exports.REQ_ACCEPT = exports.HEAD_FACES_REQ = exports.CONTENT_TYPE = exports.CTX_PARAM_PPS = exports.CTX_PARAM_REQ_PASS_THR = exports.CTX_PARAM_SRC_CTL_ID = exports.CTX_PARAM_SRC_FRM_ID = exports.CTX_PARAM_MF_INTERNAL = exports.CTX_OPTIONS_EXECUTE = exports.CTX_OPTIONS_RESET = exports.CTX_OPTIONS_TIMEOUT = exports.DELAY_NONE = exports.CTX_OPTIONS_DELAY = void 0;
5308
5308
  exports.$nsp = exports.$faces = exports.UNKNOWN = exports.MAX_RECONNECT_ATTEMPTS = exports.RECONNECT_INTERVAL = exports.APPLIED_CLIENT_WINDOW = exports.APPLIED_VST = exports.REASON_EXPIRED = exports.MF_NONE = exports.MYFACES = exports.DEFERRED_HEAD_INSERTS = exports.UPDATE_ELEMS = exports.UPDATE_FORMS = exports.XML_TAG_ATTR = exports.XML_TAG_AFTER = exports.XML_TAG_BEFORE = void 0;
5309
5309
  /*
@@ -5359,7 +5359,7 @@ exports.ERROR_MESSAGE = "error-message";
5359
5359
  exports.RESPONSE_TEXT = "responseText";
5360
5360
  exports.RESPONSE_XML = "responseXML";
5361
5361
  /*ajax errors spec 14.4.2*/
5362
- exports.HTTPERROR = "httpError";
5362
+ exports.HTTP_ERROR = "httpError";
5363
5363
  exports.EMPTY_RESPONSE = "emptyResponse";
5364
5364
  exports.MALFORMEDXML = "malformedXML";
5365
5365
  exports.SERVER_ERROR = "serverError";
@@ -6746,18 +6746,19 @@ var ErrorType;
6746
6746
  * I will add deprecated myfaces backwards compatibility attributes as well
6747
6747
  */
6748
6748
  class ErrorData extends EventData_1.EventData {
6749
- constructor(source, errorName, errorMessage, responseText = null, responseXML = null, responseCode = "200", status = "", type = ErrorType.CLIENT_ERROR) {
6749
+ constructor(source, errorName, errorMessage, responseText = null, responseXML = null, responseCode = -1, statusOverride = null, type = ErrorType.CLIENT_ERROR) {
6750
6750
  super();
6751
6751
  this.type = "error";
6752
- this.source = document.getElementById(source);
6753
- this.sourceId = source;
6752
+ this.source = source;
6754
6753
  this.type = Const_1.ERROR;
6755
6754
  this.errorName = errorName;
6756
6755
  //tck requires that the type is prefixed to the message itself (jsdoc also) in case of a server error
6757
- this.message = this.errorMessage = (type == Const_1.SERVER_ERROR) ? type + ": " + errorMessage : errorMessage;
6758
- this.responseCode = responseCode;
6756
+ this.errorMessage = errorMessage;
6757
+ this.responseCode = `${responseCode}`;
6759
6758
  this.responseText = responseText;
6760
- this.status = status;
6759
+ this.responseXML = responseXML;
6760
+ this.status = statusOverride;
6761
+ this.description = `Status: ${this.status}\nResponse Code: ${this.responseCode}\nError Message: ${this.errorMessage}`;
6761
6762
  this.typeDetails = type;
6762
6763
  if (type == ErrorType.SERVER_ERROR) {
6763
6764
  this.serverErrorName = this.errorName;
@@ -6768,8 +6769,8 @@ class ErrorData extends EventData_1.EventData {
6768
6769
  var _a, _b, _c, _d;
6769
6770
  return new ErrorData((_a = e === null || e === void 0 ? void 0 : e.source) !== null && _a !== void 0 ? _a : "client", (_b = e === null || e === void 0 ? void 0 : e.name) !== null && _b !== void 0 ? _b : Const_1.EMPTY_STR, (_c = e === null || e === void 0 ? void 0 : e.message) !== null && _c !== void 0 ? _c : Const_1.EMPTY_STR, (_d = e === null || e === void 0 ? void 0 : e.stack) !== null && _d !== void 0 ? _d : Const_1.EMPTY_STR);
6770
6771
  }
6771
- static fromHttpConnection(source, name, message, responseText, responseCode, status = Const_1.EMPTY_STR) {
6772
- return new ErrorData(source, name, message, responseText, responseCode, `${responseCode}`, status, ErrorType.HTTP_ERROR);
6772
+ static fromHttpConnection(source, name, message, responseText, responseXML, responseCode, status = Const_1.EMPTY_STR) {
6773
+ return new ErrorData(source, name, message, responseText, responseXML, responseCode, status, ErrorType.HTTP_ERROR);
6773
6774
  }
6774
6775
  static fromGeneric(context, errorCode, errorType = ErrorType.SERVER_ERROR) {
6775
6776
  let getMsg = this.getMsg;
@@ -6778,8 +6779,8 @@ class ErrorData extends EventData_1.EventData {
6778
6779
  let errorMessage = getMsg(context, Const_1.ERROR_MESSAGE);
6779
6780
  let status = getMsg(context, Const_1.STATUS);
6780
6781
  let responseText = getMsg(context, Const_1.RESPONSE_TEXT);
6781
- let responseXML = getMsg(context, Const_1.RESPONSE_XML);
6782
- return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode + Const_1.EMPTY_STR, status, errorType);
6782
+ let responseXML = context.getIf(Const_1.RESPONSE_XML).value;
6783
+ return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode, status, errorType);
6783
6784
  }
6784
6785
  static getMsg(context, param) {
6785
6786
  return getMessage(context.getIf(param).orElse(Const_1.EMPTY_STR).value);
@@ -8225,7 +8226,7 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8225
8226
  // reject means clear queue, in this case we abort entirely the processing
8226
8227
  // does not happen yet, we have to probably rethink this strategy in the future
8227
8228
  // when we introduce cancel functionality
8228
- this.handleGenericError(reject);
8229
+ this.handleHttpError(reject);
8229
8230
  }
8230
8231
  /**
8231
8232
  * request timeout, this must be handled like a generic server error per spec
@@ -8238,7 +8239,7 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8238
8239
  // timeout also means we we probably should clear the queue,
8239
8240
  // the state is unsafe for the next requests
8240
8241
  this.sendEvent(Const_1.STATE_EVT_TIMEOUT);
8241
- this.handleGenericError(resolve);
8242
+ this.handleHttpError(resolve);
8242
8243
  }
8243
8244
  /**
8244
8245
  * the response is received and normally is a normal response
@@ -8249,28 +8250,52 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8249
8250
  * @private
8250
8251
  */
8251
8252
  onResponseReceived(resolve) {
8252
- var _a, _b, _c, _d;
8253
+ var _a;
8253
8254
  this.sendEvent(Const_1.COMPLETE);
8254
- /*
8255
- * second on error path
8256
- */
8257
- if (((_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 0) >= 300 || !((_c = this === null || this === void 0 ? void 0 : this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseXML)) {
8255
+ //request error resolution as per spec:
8256
+ if (!this.processRequestErrors(resolve)) {
8257
+ (0, Const_1.$faces)().ajax.response(this.xhrObject, (_a = this.responseContext.value) !== null && _a !== void 0 ? _a : {});
8258
+ }
8259
+ }
8260
+ processRequestErrors(resolve) {
8261
+ var _a, _b, _c;
8262
+ const responseXML = new mona_dish_1.XMLQuery((_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseXML);
8263
+ const responseCode = (_c = (_b = this.xhrObject) === null || _b === void 0 ? void 0 : _b.status) !== null && _c !== void 0 ? _c : -1;
8264
+ if (responseXML.isXMLParserError()) {
8265
+ // invalid response
8266
+ const errorName = "Invalid Response";
8267
+ const errorMessage = "The response xml is invalid";
8268
+ this.handleGenericResponseError(errorName, errorMessage, Const_1.MALFORMEDXML, resolve);
8269
+ return true;
8270
+ }
8271
+ else if (responseXML.isAbsent()) {
8272
+ // empty response
8273
+ const errorName = "Empty Response";
8274
+ const errorMessage = "The response has provided no data";
8275
+ this.handleGenericResponseError(errorName, errorMessage, Const_1.EMPTY_RESPONSE, resolve);
8276
+ return true;
8277
+ }
8278
+ else if (responseCode >= 300 || responseCode < 200) {
8279
+ // other server errors
8258
8280
  // all errors from the server are resolved without interfering in the queue
8259
- this.handleGenericError(resolve);
8260
- return;
8281
+ this.handleHttpError(resolve);
8282
+ return true;
8261
8283
  }
8262
- (0, Const_1.$faces)().ajax.response(this.xhrObject, (_d = this.responseContext.value) !== null && _d !== void 0 ? _d : {});
8284
+ //additional errors are application errors and must be handled within the response
8285
+ return false;
8263
8286
  }
8264
- handleGenericError(resolveOrReject) {
8287
+ handleGenericResponseError(errorName, errorMessage, responseStatus, resolve) {
8265
8288
  var _a, _b, _c, _d;
8289
+ const errorData = new ErrorData_1.ErrorData(this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value, errorName, errorMessage, (_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseText) !== null && _b !== void 0 ? _b : "", (_d = (_c = this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseXML) !== null && _d !== void 0 ? _d : null, this.xhrObject.status, responseStatus);
8290
+ this.finalizeError(errorData, resolve);
8291
+ }
8292
+ handleHttpError(resolveOrReject, errorMessage = "Generic HTTP Serror") {
8293
+ var _a, _b, _c, _d, _e, _f;
8266
8294
  this.stopProgress = true;
8267
- const errorData = {
8268
- type: Const_1.ERROR,
8269
- status: Const_1.MALFORMEDXML,
8270
- responseCode: (_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 400,
8271
- responseText: (_d = (_c = this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseText) !== null && _d !== void 0 ? _d : "Error",
8272
- source: this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value
8273
- };
8295
+ const errorData = new ErrorData_1.ErrorData(this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value, Const_1.HTTP_ERROR, errorMessage, (_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseText) !== null && _b !== void 0 ? _b : "", (_d = (_c = this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseXML) !== null && _d !== void 0 ? _d : null, (_f = (_e = this.xhrObject) === null || _e === void 0 ? void 0 : _e.status) !== null && _f !== void 0 ? _f : -1, Const_1.HTTP_ERROR);
8296
+ this.finalizeError(errorData, resolveOrReject);
8297
+ }
8298
+ finalizeError(errorData, resolveOrReject) {
8274
8299
  try {
8275
8300
  this.handleError(errorData, true);
8276
8301
  }
@@ -8279,8 +8304,8 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8279
8304
  // reject would clean up the queue
8280
8305
  // resolve would trigger the next element in the queue to be processed
8281
8306
  resolveOrReject(errorData);
8307
+ this.stopProgress = true;
8282
8308
  }
8283
- // non blocking non clearing
8284
8309
  }
8285
8310
  /**
8286
8311
  * last minute cleanup, the request now either is fully done
@@ -8337,14 +8362,18 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8337
8362
  this.reject(e);
8338
8363
  }
8339
8364
  handleError(exception, responseFormatError = false) {
8340
- const errorData = (responseFormatError) ? ErrorData_1.ErrorData.fromHttpConnection(exception.source, exception.type, exception.status, exception.responseText, exception.responseCode, exception.status) : ErrorData_1.ErrorData.fromClient(exception);
8365
+ var _a;
8366
+ const errorData = (responseFormatError) ? ErrorData_1.ErrorData.fromHttpConnection(exception.source, exception.type, (_a = exception.message) !== null && _a !== void 0 ? _a : Const_1.EMPTY_STR, exception.responseText, exception.responseXML, exception.responseCode, exception.status) : ErrorData_1.ErrorData.fromClient(exception);
8341
8367
  const eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_ERROR);
8342
8368
  AjaxImpl_1.Implementation.sendError(errorData, eventHandler);
8343
8369
  }
8344
8370
  appendIssuingItem(formData) {
8345
8371
  const issuingItemId = this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value;
8372
+ //to avoid sideffects with buttons we only can append the issuing item if no behavior event is set
8373
+ //MYFACES-4679!
8374
+ const isBehaviorEvent = !!formData.getIf((0, Const_1.$nsp)(Const_1.P_BEHAVIOR_EVENT)).value;
8346
8375
  //not encoded
8347
- if (issuingItemId && formData.getIf(issuingItemId).isAbsent()) {
8376
+ if (issuingItemId && formData.getIf(issuingItemId).isAbsent() && !isBehaviorEvent) {
8348
8377
  const issuingItem = mona_dish_1.DQ.byId(issuingItemId);
8349
8378
  const itemValue = issuingItem.inputValue;
8350
8379
  const arr = new ExtDomQuery_1.ExtConfig({});
@@ -8357,7 +8386,9 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8357
8386
  else if ((type == XhrRequest.TYPE_CHECKBOX || type == XhrRequest.TYPE_RADIO)) {
8358
8387
  arr.assign(issuingItemId).value = itemValue.orElse(true).value;
8359
8388
  }
8360
- else if (itemValue.isPresent()) {
8389
+ else if (itemValue.isPresent() && (type == XhrRequest.TYPE_BUTTON ||
8390
+ type == XhrRequest.TYPE_SUBMIT ||
8391
+ type == XhrRequest.TYPE_LINK)) {
8361
8392
  arr.assign(issuingItemId).value = itemValue.value;
8362
8393
  }
8363
8394
  formData.shallowMerge(arr, true, true);
@@ -8367,6 +8398,9 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
8367
8398
  exports.XhrRequest = XhrRequest;
8368
8399
  XhrRequest.TYPE_CHECKBOX = "checkbox";
8369
8400
  XhrRequest.TYPE_RADIO = "radio";
8401
+ XhrRequest.TYPE_BUTTON = "button";
8402
+ XhrRequest.TYPE_SUBMIT = "submit";
8403
+ XhrRequest.TYPE_LINK = "a";
8370
8404
 
8371
8405
 
8372
8406
  /***/ }),