You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2017/10/08 20:04:15 UTC
svn commit: r1811501 - in
/myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore:
_AjaxResponse.js _AjaxResponseJSF22.js
Author: werpu
Date: Sun Oct 8 20:04:15 2017
New Revision: 1811501
URL: http://svn.apache.org/viewvc?rev=1811501&view=rev
Log: (empty)
Removed:
myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponseJSF22.js
Modified:
myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
Modified: myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=1811501&r1=1811500&r2=1811501&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/branches/2.3.x/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Sun Oct 8 20:04:15 2017
@@ -32,29 +32,29 @@
_MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxResponse.prototype */ {
/*partial response types*/
- RESP_PARTIAL:"partial-response",
- RESP_TYPE_ERROR:"error",
- RESP_TYPE_REDIRECT:"redirect",
- RESP_TYPE_CHANGES:"changes",
+ RESP_PARTIAL: "partial-response",
+ RESP_TYPE_ERROR: "error",
+ RESP_TYPE_REDIRECT: "redirect",
+ RESP_TYPE_CHANGES: "changes",
/*partial commands*/
- CMD_CHANGES:"changes",
- CMD_UPDATE:"update",
- CMD_DELETE:"delete",
- CMD_INSERT:"insert",
- CMD_EVAL:"eval",
- CMD_ERROR:"error",
- CMD_ATTRIBUTES:"attributes",
- CMD_EXTENSION:"extension",
- CMD_REDIRECT:"redirect",
+ CMD_CHANGES: "changes",
+ CMD_UPDATE: "update",
+ CMD_DELETE: "delete",
+ CMD_INSERT: "insert",
+ CMD_EVAL: "eval",
+ CMD_ERROR: "error",
+ CMD_ATTRIBUTES: "attributes",
+ CMD_EXTENSION: "extension",
+ CMD_REDIRECT: "redirect",
/*other constants*/
- P_VIEWSTATE:"javax.faces.ViewState",
+ P_VIEWSTATE: "javax.faces.ViewState",
P_CLIENTWINDOW: "javax.faces.ClientWindow",
- P_VIEWROOT:"javax.faces.ViewRoot",
- P_VIEWHEAD:"javax.faces.ViewHead",
- P_VIEWBODY:"javax.faces.ViewBody",
- P_RESOURCE:"javax.faces.Resource",
+ P_VIEWROOT: "javax.faces.ViewRoot",
+ P_VIEWHEAD: "javax.faces.ViewHead",
+ P_VIEWBODY: "javax.faces.ViewBody",
+ P_RESOURCE: "javax.faces.Resource",
/**
* uses response to start Html element replacement
@@ -68,7 +68,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* and if the CDATA block contains a body section the document body must be replaced!
*
*/
- processResponse:function (request, context) {
+ processResponse: function (request, context) {
//mfinternal handling, note, the mfinternal is only optional
//according to the spec
context._mfInternal = context._mfInternal || {};
@@ -79,6 +79,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
mfInternal._updateForms = [];
mfInternal.appliedViewState = null;
mfInternal.appliedClientWindow = null;
+ mfInternal.namingModeId = null;
+
try {
var _Impl = this.attr("impl"), _Lang = this._Lang;
@@ -114,6 +116,18 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
}
+
+ /**
+ * jsf 2.3 naming mode partial response,
+ * we either viewstate all forms (non id mode)
+ * or the forms under the viewroot defined by id
+ *
+ * @type {string} ... the naming mode id is set or an empty string
+ * definitely not a null value to avoid type confusions later on
+ */
+ mfInternal.namingModeId = (partials.id || "");
+
+
var childNodesLength = partials.childNodes.length;
for (var loop = 0; loop < childNodesLength; loop++) {
@@ -141,21 +155,28 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
//fixup missing viewStates due to spec deficiencies
- if(mfInternal.appliedViewState) {
+ if (mfInternal.appliedViewState) {
this.fixViewStates(context);
}
- if(mfInternal.appliedClientWindow) {
+ if (mfInternal.appliedClientWindow) {
this.fixClientWindows(context);
}
//spec jsdoc, the success event must be sent from response
_Impl.sendEvent(request, context, _Impl["SUCCESS"]);
+ } catch (e) {
+ if (window.console && window.console.error) {
+ //any error should be logged
+ console.error(e);
+ }
+ throw e;
} finally {
delete mfInternal._updateElems;
delete mfInternal._updateForms;
delete mfInternal.appliedViewState;
delete mfInternal.appliedClientWindow;
+ delete mfInternal.namingModeId;
}
},
@@ -164,7 +185,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
*
* @param context
*/
- fixViewStates:function (context) {
+ fixViewStates: function (context) {
var _Lang = this._Lang;
var mfInternal = context._mfInternal;
@@ -172,125 +193,65 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
return;
}
- //if we set our no portlet env we safely can update all forms with
- //the new viewstate
- if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) {
- for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) {
- this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedViewState, this.P_VIEWSTATE);
- }
- return;
- }
-
- var updatedForm = this._getUpdatedForm(context, mfInternal._updateForms);
- if (updatedForm != null) {
- var baseViewStateField = this._Dom.getNamedElementFromForm(updatedForm, this.P_VIEWSTATE);
- var viewStateId = baseViewStateField.id;
- var viewStatePrefix = viewStateId.substring(0,
- viewStateId.indexOf(this.P_VIEWSTATE)+this.P_VIEWSTATE.length);
- var viewStateFields = document.getElementsByName(this.P_VIEWSTATE);
- for (var cnt = viewStateFields.length - 1; cnt >= 0; cnt--) {
- if (viewStateFields[cnt].id.startsWith(viewStatePrefix)) {
- this._setVSTCWForm(context, viewStateFields[cnt].form, mfInternal.appliedViewState, this.P_VIEWSTATE);
- }
- }
- }else{
- // Now update the forms that were not replaced but forced to be updated, because contains child ajax tags
- // we should only update forms with view state hidden field. If by some reason, the form was set to be
- // updated but the form was replaced, it does not have hidden view state, so later in changeTrace processing the
- // view state is updated.
-
- //set the viewstates of all outer forms parents of our updated elements
- _Lang.arrForEach(mfInternal._updateForms, function (elem) {
- this._setVSTCWForm(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE);
- }, 0, this);
-
- //set the viewstate of all forms within our updated elements
- _Lang.arrForEach(mfInternal._updateElems, function (elem) {
- this._setVSTCWInnerForms(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE);
- }, 0, this);
- }
+ /**
+ * JSF 2.3 we set all the viewstates under a given declared viewRoot or all forms
+ * if none is given
+ */
+ this._updateJSFClientArtifacts(context, mfInternal.appliedViewState, this.P_VIEWSTATE);
},
- fixClientWindows:function (context, theForm) {
+
+ fixClientWindows: function (context, theForm) {
var _Lang = this._Lang;
var mfInternal = context._mfInternal;
if (null == mfInternal.appliedClientWindow) {
return;
}
- //if we set our no portlet env we safely can update all forms with
- //the new viewstate
- if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) {
- for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) {
- this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedClientWindow, this.P_CLIENTWINDOW);
- }
- return;
- }
-
- var updatedForm = this._getUpdatedForm(context, mfInternal._updateForms);
- if (updatedForm != null) {
- var baseCWField = this._Dom.getNamedElementFromForm(updatedForm, this.P_CLIENTWINDOW);
- var cwId = baseCWField.id;
- var cwPrefix = cwId.substring(0,
- cwId.indexOf(this.P_CLIENTWINDOW)+this.P_CLIENTWINDOW.length);
- var cwFields = document.getElementsByName(this.P_CLIENTWINDOW);
- for (var cnt = cwFields.length - 1; cnt >= 0; cnt--) {
- if (cwFields[cnt].id.startsWith(cwPrefix)) {
- this._setVSTCWForm(context, cwFields[cnt].form, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW);
- }
- }
- } else{
- //set the client window of all outer form of updated elements
- _Lang.arrForEach(mfInternal._updateForms, function (elem) {
- this._setVSTCWForm(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW);
- }, 0, this);
-
- //set the client window of all forms within our updated elements
- _Lang.arrForEach(mfInternal._updateElems, function (elem) {
- this._setVSTCWInnerForms(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW);
- }, 0, this);
- }
+ /**
+ * JSF 2.3 we set all the viewstates under a given declared viewRoot or all forms
+ * if none is given
+ */
+ this._updateJSFClientArtifacts(context, mfInternal.appliedViewState, this.P_CLIENTWINDOW);
+
},
- _getUpdatedForm:function(context, updateForms) {
- if (updateForms != null) {
- for (var i = 0; i < updateForms.length; i++) {
- var elem = this._Lang.byId(updateForms[i]);
- if (!elem){
- continue;
- }else{
- return elem;
- }
- }
- }
- },
-
/**
- * sets the viewstate element in a given form
+ * sets the a jsf artifact element with a given identifier to a new value or adds this element
*
- * @param theForm the form to which the element has to be set to
+ * @param theForm {Node} the form to which the element has to be set to
* @param context the current request context
*/
- _setVSTCWForm:function (context, theForm, value, identifier) {
- if (typeof theForm === 'string' || theForm instanceof String) {
- theForm = this._Lang.byId(theForm);
- }
- var mfInternal = context._mfInternal;
+ _applyJSFArtifactValueToForm: function (context, theForm, value, identifier) {
if (!theForm) return;
+ var prefix = this._getPrefix(context);
+
//in IE7 looking up form elements with complex names (such as 'javax.faces.ViewState') fails in certain cases
//iterate through the form elements to find the element, instead
- var fieldToApply = this._Dom.getNamedElementFromForm(theForm, identifier);
+ var fieldsFound = [];
- if (fieldToApply) {
- this._Dom.setAttribute(fieldToApply, "value", value);
- } else if (!fieldToApply) {
+ var elements = theForm.elements;
+ for (var i = 0, l = elements.length; i < l; i++) {
+ var e = elements[i];
+ if (e.name.indexOf(identifier) != -1) {
+ fieldsFound.push(e);
+ }
+ }
+
+ if (fieldsFound.length) {
+ this._Lang.arrForEach(fieldsFound, function (fieldFound) {
+ this._Dom.setAttribute(fieldFound, "value", value);
+ });
+ } else {
var element = this._Dom.getDummyPlaceHolder();
- //spec error, two elements with the same id should not be there, TODO recheck the space if the name does not suffice alone
- element.innerHTML = ["<input type='hidden'", "id='", identifier+jsf.separatorchar+Math.random() , "' name='", identifier , "' value='" , value , "' />"].join("");
+
+ //per JSF 2.3 spec the identifier of the element must be unique in the dom tree
+ //otherwise we will break the html spec here
+ element.innerHTML = ["<input type='hidden'", "id='", this._fetchUniqueId(prefix, identifier), "' name='", prefix + identifier, "' value='", value, "' />"].join("");
//now we go to proper dom handling after having to deal with another ie screwup
try {
theForm.appendChild(element.childNodes[0]);
@@ -300,25 +261,81 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
},
- _setVSTCWInnerForms:function (context, elem, value, identifier) {
+ _fetchUniqueId: function(prefix, identifier) {
+ var cnt = 0;
+ var retVal = prefix + identifier + jsf.separatorchar+cnt;
+ while(this._Dom.byId(retVal) != null) {
+ cnt++;
+ prefix + identifier + jsf.separatorchar+cnt;
+ }
+ return retVal;
+ },
+
+ /**
+ * updates/inserts the jsf client artifacts under a given viewroot element
+ *
+ * @param context the client context holding all request context data and some internal data
+ * @param elem the root to start with, must be a dom node not an identifier
+ * @param value the new value
+ * @param identifier the identifier for the client artifact aka javax.faces.ViewState, ClientWindowId etc...
+ *
+ * @private
+ */
+ _updateJSFClientArtifacts: function (context, value, identifier) {
- var _Lang = this._Lang, _Dom = this._Dom;
- elem = _Dom.byIdOrName(elem);
//elem not found for whatever reason
//https://issues.apache.org/jira/browse/MYFACES-3544
- if (!elem) return;
- var replacedForms = _Dom.findByTagName(elem, "form", false);
+ var prefix = this._getPrefix(context);
- var applyVST = _Lang.hitch(this, function (elem) {
- this._setVSTCWForm(context, elem, value, identifier);
- });
+ //do we still need the issuing form update? I guess it is needed.
+ var sourceForm = (context._mfInternal._mfSourceFormId) ? this._Dom.byId(context._mfInternal._mfSourceFormId) : null;
+ if (sourceForm) {
+ sourceForm = this._Dom.byId(sourceForm);
+ if (sourceForm) {
+ //some cases where the source form cannot be updated
+ //because it is gone
+ this._applyJSFArtifactValueToForm(context, sourceForm, value, identifier);
+ }
+ }
- try {
- _Lang.arrForEach(replacedForms, applyVST, 0, this);
- } finally {
- applyVST = null;
+ //We update all elements under viewroot
+ //this clearly violates the jsf 2.3 jsdocs
+ //however I think that the jsdocs were sloppily updated
+ //because just updating the render targets under one viewroot and the issuing form
+ //again would leave broken viewstates
+ var viewRoot = this._getViewRoot(context);
+ var forms = viewRoot.getElementsByTagName("form") || [];
+
+ _Lang.arrForEach(forms, _Lang.hitch(this, function (elem) {
+ //update all forms which start with prefix (all render and execute targets
+ if (elem.id && elem.id.indexOf(prefix) == 0) {
+ this._applyJSFArtifactValueToForm(context, elem, value, identifier);
+ }
+ }));
+ },
+
+ _getViewRoot: function (context) {
+ var prefix = this._getPrefix(context);
+ if (prefix == "") {
+ return document.getElementsByTagName("body")[0];
}
+ prefix = prefix.substr(0, prefix.length() - 1);
+ var viewRoot = document.getElementById(prefix);
+ if (viewRoot) {
+ return viewRoot;
+ }
+ return document.getElementsByTagName("body")[0];
+ },
+
+
+ _getPrefix: function (context) {
+ var mfInternal = context._mfInternal;
+ var prefix = mfInternal.namingModeId;
+ if (prefix != "") {
+ prefix = prefix + jsf.separatorchar;
+ }
+ return prefix;
},
/**
@@ -328,7 +345,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param context the contect object
* @param node the node in the xml hosting the error message
*/
- processError:function (request, context, node) {
+ processError: function (request, context, node) {
/**
* <error>
* <error-name>String</error-name>
@@ -336,10 +353,11 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* <error>
*/
var errorName = node.firstChild.textContent || node.firstChild.text || "",
- errorMessage = node.childNodes[1].firstChild.data || "";
+ errorMessage = node.childNodes[1].firstChild.data || "";
this.attr("impl").sendError(request, context, this.attr("impl").SERVER_ERROR, errorName, errorMessage, "myfaces._impl.xhrCore._AjaxResponse", "processError");
- },
+ }
+ ,
/**
* processes an incoming xml redirect directive from the ajax response
@@ -347,7 +365,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param context the context
* @param node the node hosting the redirect data
*/
- processRedirect:function (request, context, node) {
+ processRedirect: function (request, context, node) {
/**
* <redirect url="url to redirect" />
*/
@@ -362,7 +380,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
window.location = redirectUrl;
return true;
- },
+ }
+ ,
/**
* main entry point for processing the changes
@@ -373,7 +392,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param context the context map
* @param node the changes node to be processed
*/
- processChanges:function (request, context, node) {
+ processChanges: function (request, context, node) {
var changes = node.childNodes;
var _Lang = this._Lang;
//note we need to trace the changes which could affect our insert update or delete
@@ -407,7 +426,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
return true;
- },
+ }
+ ,
/**
* First sub-step process a pending update tag
@@ -416,45 +436,19 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param context the context map
* @param node the changes node to be processed
*/
- processUpdate:function (request, context, node) {
- if ( (node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) || (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) ) {
- //update the submitting forms viewstate to the new value
- // The source form has to be pulled out of the CURRENT document first because the context object
- // may refer to an invalid document if an update of the entire body has occurred before this point.
- var mfInternal = context._mfInternal,
- fuzzyFormDetection = this._Lang.hitch(this._Dom, this._Dom.fuzzyFormDetection);
- var elemId = (mfInternal._mfSourceControlId) ? mfInternal._mfSourceControlId :
- ((context.source) ? context.source.id : null);
-
- //theoretically a source of null can be given, then our form detection fails for
- //the source element case and hence updateviewstate is skipped for the source
- //form, but still render targets still can get the viewstate
- var sourceForm = (mfInternal && mfInternal["_mfSourceFormId"] &&
- document.forms[mfInternal["_mfSourceFormId"]]) ?
- document.forms[mfInternal["_mfSourceFormId"]] : ((elemId) ? fuzzyFormDetection(elemId) : null);
-
- if(node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) {
+ processUpdate: function (request, context, node) {
+ var mfInternal = context._mfInternal;
+ if ((node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) || (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1)) {
+ if (node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) {
mfInternal.appliedViewState = this._Dom.concatCDATABlocks(node);//node.firstChild.nodeValue;
- } else if(node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) {
+ } else if (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) {
mfInternal.appliedClientWindow = node.firstChild.nodeValue;
}
- //source form could not be determined either over the form identifer or the element
- //we now skip this phase and just add everything we need for the fixup code
-
- if (!sourceForm) {
- //no source form found is not an error because
- //we might be able to recover one way or the other
- return true;
- }
-
- mfInternal._updateForms.push(sourceForm.id);
-
}
else {
// response may contain several blocks
var cDataBlock = this._Dom.concatCDATABlocks(node),
- resultNode = null,
- pushOpRes = this._Lang.hitch(this, this._pushOperationResult);
+ resultNode = null;
switch (node.getAttribute('id')) {
case this.P_VIEWROOT:
@@ -463,10 +457,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
var parsedData = this._replaceHead(request, context, cDataBlock);
- resultNode = ('undefined' != typeof parsedData && null != parsedData) ? this._replaceBody(request, context, cDataBlock, parsedData) : this._replaceBody(request, context, cDataBlock);
- if (resultNode) {
- pushOpRes(context, resultNode);
- }
+ ('undefined' != typeof parsedData && null != parsedData) ? this._replaceBody(request, context, cDataBlock, parsedData) : this._replaceBody(request, context, cDataBlock);
+
break;
case this.P_VIEWHEAD:
//we cannot replace the head, almost no browser allows this, some of them throw errors
@@ -476,51 +468,25 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
break;
case this.P_VIEWBODY:
//we assume the cdata block is our body including the tag
- resultNode = this._replaceBody(request, context, cDataBlock);
- if (resultNode) {
- pushOpRes(context, resultNode);
- }
+ this._replaceBody(request, context, cDataBlock);
+
break;
case this.P_RESOURCE:
-
- this._addResourceToHead(request,context,cDataBlock);
+
+ this._addResourceToHead(request, context, cDataBlock);
break;
default:
- resultNode = this.replaceHtmlItem(request, context, node.getAttribute('id'), cDataBlock);
- if (resultNode) {
- pushOpRes(context, resultNode);
- }
+
+ this.replaceHtmlItem(request, context, node.getAttribute('id'), cDataBlock);
+
break;
}
}
return true;
- },
-
- _pushOperationResult:function (context, resultNode) {
- var mfInternal = context._mfInternal;
- var pushSubnode = this._Lang.hitch(this, function (currNode) {
- var parentForm = this._Dom.getParent(currNode, "form");
- //if possible we work over the ids
- //so that elements later replaced are referenced
- //at the latest possibility
- if (null != parentForm) {
- mfInternal._updateForms.push(parentForm.id || parentForm);
- }
- else {
- mfInternal._updateElems.push(currNode.id || currNode);
- }
- });
- var isArr = 'undefined' != typeof resultNode.length && 'undefined' == typeof resultNode.nodeType;
- if (isArr && resultNode.length) {
- for (var cnt = 0; cnt < resultNode.length; cnt++) {
- pushSubnode(resultNode[cnt]);
- }
- } else if (!isArr) {
- pushSubnode(resultNode);
- }
+ }
+ ,
- },
/**
* replaces a current head theoretically,
@@ -533,15 +499,15 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
*
* @return an xml representation of the page for further processing if possible
*/
- _replaceHead:function (request, context, newData) {
+ _replaceHead: function (request, context, newData) {
var _Lang = this._Lang,
- _Dom = this._Dom,
- isWebkit = this._RT.browser.isWebKit,
- //we have to work around an xml parsing bug in Webkit
- //see https://issues.apache.org/jira/browse/MYFACES-3061
- doc = (!isWebkit) ? _Lang.parseXML(newData) : null,
- newHead = null;
+ _Dom = this._Dom,
+ isWebkit = this._RT.browser.isWebKit,
+ //we have to work around an xml parsing bug in Webkit
+ //see https://issues.apache.org/jira/browse/MYFACES-3061
+ doc = (!isWebkit) ? _Lang.parseXML(newData) : null,
+ newHead = null;
if (!isWebkit && _Lang.isXMLParseError(doc)) {
doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->"));
@@ -570,7 +536,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
newHead = doc.getElementsByTagName("head")[0];
}
- var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"link":true, "style":true});
+ var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"link": true, "style": true});
_Dom.runCss(newHead, true);
_Dom.deleteItems(oldTags);
@@ -579,16 +545,16 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
_Dom.runScripts(newHead, true);
return doc;
- },
-
- _addResourceToHead:function (request, context, newData) {
+ }
+ ,
+
+ _addResourceToHead: function (request, context, newData) {
var lastHeadChildTag = document.getElementsByTagName("head")[0].lastChild;
- var replacementFragment = this._Dom.insertAfter(lastHeadChildTag, newData);
- if (replacementFragment) {
- this._pushOperationResult(context, replacementFragment);
- }
- },
+ this._Dom.insertAfter(lastHeadChildTag, newData);
+
+ }
+ ,
/**
* special method to handle the body dom manipulation,
@@ -601,14 +567,14 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param {String} newData the markup which replaces the old dom node!
* @param {Node} parsedData (optional) preparsed XML representation data of the current document
*/
- _replaceBody:function (request, context, newData /*varargs*/) {
+ _replaceBody: function (request, context, newData /*varargs*/) {
var _RT = this._RT,
- _Dom = this._Dom,
- _Lang = this._Lang,
+ _Dom = this._Dom,
+ _Lang = this._Lang,
- oldBody = document.getElementsByTagName("body")[0],
- placeHolder = document.createElement("div"),
- isWebkit = _RT.browser.isWebKit;
+ oldBody = document.getElementsByTagName("body")[0],
+ placeHolder = document.createElement("div"),
+ isWebkit = _RT.browser.isWebKit;
placeHolder.id = "myfaces_bodyplaceholder";
@@ -660,11 +626,9 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData);
- if (returnedElement) {
- this._pushOperationResult(context, returnedElement);
- }
return returnedElement;
- },
+ }
+ ,
/**
* Replaces HTML elements through others and handle errors if the occur in the replacement part
@@ -674,17 +638,18 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param {Object} itemIdToReplace (String|Node) - ID of the element to replace
* @param {String} markup - the new tag
*/
- replaceHtmlItem:function (request, context, itemIdToReplace, markup) {
+ replaceHtmlItem: function (request, context, itemIdToReplace, markup) {
var _Lang = this._Lang, _Dom = this._Dom;
var item = (!_Lang.isString(itemIdToReplace)) ? itemIdToReplace :
- _Dom.byIdOrName(itemIdToReplace);
+ _Dom.byIdOrName(itemIdToReplace);
if (!item) {
throw this._raiseError(new Error(), _Lang.getMessage("ERR_ITEM_ID_NOTFOUND", null, "_AjaxResponse.replaceHtmlItem", (itemIdToReplace) ? itemIdToReplace.toString() : "undefined"), "replaceHtmlItem");
}
return _Dom.outerHTML(item, markup, this._RT.getLocalOrGlobalConfig(context, "preserveFocus", false));
- },
+ }
+ ,
/**
* xml insert command handler
@@ -695,12 +660,12 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @return true upon successful completion, false otherwise
*
**/
- processInsert:function (request, context, node) {
+ processInsert: function (request, context, node) {
/*remapping global namespaces for speed and readability reasons*/
var _Dom = this._Dom,
- _Lang = this._Lang,
- //determine which path to go:
- insertData = this._parseInsertData(request, context, node);
+ _Lang = this._Lang,
+ //determine which path to go:
+ insertData = this._parseInsertData(request, context, node);
if (!insertData) return false;
@@ -710,12 +675,11 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
//call insertBefore or insertAfter in our dom routines
- var replacementFragment = _Dom[insertData.insertType](opNode, insertData.cDataBlock);
- if (replacementFragment) {
- this._pushOperationResult(context, replacementFragment);
- }
+ _Dom[insertData.insertType](opNode, insertData.cDataBlock);
+
return true;
- },
+ }
+ ,
/**
* determines the corner data from the insert tag parsing process
@@ -734,18 +698,18 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* TODO we have to find a mechanism to replace the direct sendError calls with a javascript exception
* which we then can use for cleaner error code handling
*/
- _parseInsertData:function (request, context, node) {
+ _parseInsertData: function (request, context, node) {
var _Lang = this._Lang,
- _Dom = this._Dom,
- concatCDATA = _Dom.concatCDATABlocks,
+ _Dom = this._Dom,
+ concatCDATA = _Dom.concatCDATABlocks,
- INSERT_TYPE_BEFORE = "insertBefore",
- INSERT_TYPE_AFTER = "insertAfter",
+ INSERT_TYPE_BEFORE = "insertBefore",
+ INSERT_TYPE_AFTER = "insertAfter",
- id = node.getAttribute("id"),
- beforeId = node.getAttribute("before"),
- afterId = node.getAttribute("after"),
- ret = {};
+ id = node.getAttribute("id"),
+ beforeId = node.getAttribute("before"),
+ afterId = node.getAttribute("after"),
+ ret = {};
//now we have to make a distinction between two different parsing paths
//due to a spec malalignment
@@ -778,18 +742,19 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
ret.cDataBlock = concatCDATA(node.childNodes[0]);
} else {
throw this._raiseError(new Error(), [_Lang.getMessage("ERR_PPR_IDREQ"),
- "\n ",
- _Lang.getMessage("ERR_PPR_INSERTBEFID")].join(""), "_parseInsertData");
+ "\n ",
+ _Lang.getMessage("ERR_PPR_INSERTBEFID")].join(""), "_parseInsertData");
}
ret.opId = _Lang.trim(ret.opId);
return ret;
- },
+ }
+ ,
- processDelete:function (request, context, node) {
+ processDelete: function (request, context, node) {
var _Lang = this._Lang,
- _Dom = this._Dom,
- deleteId = node.getAttribute('id');
+ _Dom = this._Dom,
+ deleteId = node.getAttribute('id');
if (!deleteId) {
throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_UNKNOWNCID", null, "_AjaxResponse.processDelete", ""), "processDelete");
@@ -807,9 +772,10 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
_Dom.deleteItem(item);
return true;
- },
+ }
+ ,
- processAttributes:function (request, context, node) {
+ processAttributes: function (request, context, node) {
//we now route into our attributes function to bypass
//IE quirks mode incompatibilities to the biggest possible extent
//most browsers just have to do a setAttributes but IE
@@ -817,8 +783,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
//myfaces._impl._util.this._Dom.setAttribute(domNode, attribute, value;
var _Lang = this._Lang,
- //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
- elemId = node.getAttribute('id');
+ //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
+ elemId = node.getAttribute('id');
if (!elemId) {
throw this._raiseError(new Error(), "Error in attributes, id not in xml markup", "processAttributes");
@@ -830,8 +796,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
for (var loop2 = 0; loop2 < childNodes.length; loop2++) {
var attributesNode = childNodes[loop2],
- attrName = attributesNode.getAttribute("name"),
- attrValue = attributesNode.getAttribute("value");
+ attrName = attributesNode.getAttribute("name"),
+ attrValue = attributesNode.getAttribute("value");
if (!attrName) {
continue;
@@ -862,7 +828,8 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
}
}
return true;
- },
+ }
+ ,
/**
* internal helper which raises an error in the
@@ -872,7 +839,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
* @param title the title of the error (optional)
* @param name the name of the error (optional)
*/
- _raiseError:function (error, message, caller, title, name) {
+ _raiseError: function (error, message, caller, title, name) {
var _Impl = this.attr("impl");
var finalTitle = title || _Impl.MALFORMEDXML;
var finalName = name || _Impl.MALFORMEDXML;
@@ -880,4 +847,5 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse",
return this._Lang.makeException(error, finalTitle, finalName, this._nameSpace, caller || ( (arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMessage);
}
-});
+})
+;