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 * @namespace 19 * @name window 20 * @description Eval routines, depending on the browser. 21 * <p/> 22 * The problem solved in this class is the problem on how to perform 23 * a global eval on multiple browsers. Some browsers auto eval themselves 24 * they do not need to be called 25 * <li>Some work with a window.eval.call(window,... </li> 26 * <li>Others use simply execScript <li> 27 * <li>Some others work only with the head appendix method 28 * head.appendChild(<script...., head.removeChild(<script </li> 29 * <p/> 30 * Note: The code here already is precompressed because the compressor 31 * fails on it, the deficits in readability will be covered by more comments 32 * 33 */ 34 35//sausages full 36if (!window.myfaces) { 37 /** 38 * @namespace 39 * @name myfaces 40 */ 41 var myfaces = new function() { 42 }; 43 window.myfaces = myfaces; 44} 45 46/** 47 * @memberOf myfaces 48 * @namespace 49 * @name _impl 50 */ 51myfaces._impl = (myfaces._impl) ? myfaces._impl : {}; 52/** 53 * @memberOf myfaces._impl 54 * @namespace 55 * @name core 56 */ 57myfaces._impl.core = (myfaces._impl.core) ? myfaces._impl.core :{}; 58 59if (!myfaces._impl.core._EvalHandlers) { 60 /** 61 * @memberOf myfaces._impl.core 62 * @namespace 63 * @name _EvalHandlers 64 */ 65 myfaces._impl.core._EvalHandlers = new function() { 66 //the rest of the namespaces can be handled by our namespace feature 67 //helper to avoid unneeded hitches 68 /** 69 * @borrows myfaces._impl.core._Runtime as _T 70 */ 71 var _T = this; 72 73 /*cascaded eval methods depending upon the browser*/ 74 75 /** 76 * @function 77 * @param code 78 79 * 80 * evals a script globally using exec script (ie6 fallback) 81 * @param {String} code the code which has to be evaluated 82 * @borrows myfaces._impl.core._Runtime as _T 83 * 84 * TODO eval if we cannot replace this method with the head appendix 85 * method which is faster for ie this also would reduce our code 86 * by a few bytes 87 */ 88 _T._evalExecScript = function(code) { 89 //execScript definitely only for IE otherwise we might have a custom 90 //window extension with undefined behavior on our necks 91 //window.execScript does not return anything 92 //on htmlunit it return "null object" 93 //_r == ret 94 var _r = window.execScript(code); 95 if ('undefined' != typeof _r && _r == "null" /*htmlunit bug*/) { 96 return null; 97 } 98 return _r; 99 }; 100 101 /** 102 * flakey head appendix method which does not work in the correct 103 * order or at all for all modern browsers 104 * but seems to be the only method which works on blackberry correctly 105 * hence we are going to use it as fallback 106 * 107 * @param {String} code the code part to be evaled 108 * @borrows myfaces._impl.core._Runtime as _T 109 */ 110 _T._evalHeadAppendix = function(code) { 111 //_l == location 112 var _l = document.getElementsByTagName("head")[0] || document.documentElement; 113 //_p == placeHolder 114 var _p = document.createElement("script"); 115 _p.type = "text/javascript"; 116 _p.text = code; 117 _l.insertBefore(_p, _l.firstChild); 118 _l.removeChild(_p); 119 return null; 120 }; 121 122 /** 123 * @name myfaces._impl.core._Runtime._standardGlobalEval 124 * @private 125 * @param {String} code 126 */ 127 _T._standardGlobalEval = function(code) {
128 //fix which works in a cross browser way 129 //we used to scope an anonymous function 130 //but I think this is better 131 //the reason is some Firefox versions 132 // apply a wrong scope 133 //if we call eval by not scoping 134 //_U == "undefined" 135 var _U = "undefined"; 136 var gEval = function () { 137 //_r == retVal; 138 var _r = window.eval.call(window, code); 139 if (_U == typeof _r) return null; 140 return _r; 141 }; 142 var _r = gEval(); 143 if (_U == typeof _r) return null; 144 return _r; 145 }; 146 147 /** 148 * global eval on scripts 149 * @param {String} c (code abbreviated since the compression does not work here) 150 * @name myfaces._impl.core._Runtime.globalEval 151 * @function 152 */ 153 _T.globalEval = function(c) { 154 //TODO add a config param which allows to evaluate global scripts even if the call 155 //is embedded in an iframe 156 //We lazy init the eval type upon the browsers 157 //capabilities 158 var _e = "_evalType"; 159 var _w = window; 160 var _b = myfaces._impl.core._Runtime.browser; 161 //central routine to determine the eval method 162 if (!_T[_e]) { 163 //execScript supported 164 _T[_e] = _w.execScript ? "_evalExecScript" : null; 165 166 //in case of no support we go to the standard global eval window.eval.call(window, 167 // with Firefox fixes for scoping 168 _T[_e] = _T[_e] ||(( _w.eval && (!_b.isBlackBerry ||_b.isBlackBerry >= 6)) ? "_standardGlobalEval" : null); 169 170 //this one routes into the hed appendix method 171 _T[_e] = _T[_e] ||((_w.eval ) ? "_evalHeadAppendix" : null); 172 } 173 if (_T[_e]) { 174 //we now execute the eval method 175 return _T[_T[_e]](c); 176 } 177 //we probably have covered all browsers, but this is a safety net which might be triggered 178 //by some foreign browser which is not covered by the above cases 179 eval.call(window, c); 180 return null; 181 }; 182 183 }; 184} 185/* Licensed to the Apache Software Foundation (ASF) under one or more 186 * contributor license agreements. See the NOTICE file distributed with 187 * this work for additional information regarding copyright ownership. 188 * The ASF licenses this file to you under the Apache License, Version 2.0 189 * (the "License"); you may not use this file except in compliance with 190 * the License. You may obtain a copy of the License at 191 * 192 * http://www.apache.org/licenses/LICENSE-2.0 193 * 194 * Unless required by applicable law or agreed to in writing, software 195 * distributed under the License is distributed on an "AS IS" BASIS, 196 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 197 * See the License for the specific language governing permissions and 198 * limitations under the License. 199 */ 200 201 202/** 203 * Runtime/Startup class 204 * this is the central class which initializes all base mechanisms 205 * used by the rest of the system such as 206 * a) namespacing system 207 * b) browser detection 208 * c) loose configuration coupling 209 * d) utils methods to fetch the implementation 210 * e) ajaxed script loading 211 * f) global eval (because it is used internally) 212 * g) Structural base patterns as singleton, delegate and inheritance 213 * 214 * Note this class is self contained and must!!! be loaded 215 * as absolute first class before going into anything else 216 * 217 * 218 */ 219/** @namespace myfaces._impl.core._Runtime*/ 220 221myfaces._impl.core = (myfaces._impl.core) ? myfaces._impl.core : {}; 222//now this is the only time we have to do this cascaded and manually 223//for the rest of the classes our reserveNamespace function will do the trick 224//Note, this class uses the classical closure approach (to save code) 225//it cannot be inherited by our inheritance mechanism, but must be delegated 226//if you want to derive from it 227//closures and prototype inheritance do not mix, closures and delegation however do 228/** 229 * @ignore 230 */ 231if (!myfaces._impl.core._Runtime) { 232 /** 233 * @memberOf myfaces._impl.core 234 * @namespace 235 * @name _Runtime 236 */ 237 myfaces._impl.core._Runtime = new function() { 238 //the rest of the namespaces can be handled by our namespace feature 239 //helper to avoid unneeded hitches 240 /** 241 * @borrows myfaces._impl.core._Runtime as _T 242 */ 243 var _T = this; 244 245 //namespace idx to speed things up by hitting eval way less 246 this._reservedNMS = {}; 247 this._registeredSingletons = {}; 248 this._registeredClasses = []; 249 /** 250 * replacement counter for plugin classes 251 */ 252 this._classReplacementCnt = 0; 253 254 /** 255 * global eval on scripts 256 * @param {String} code 257 * @name myfaces._impl.core._Runtime.globalEval 258 * @function 259 */ 260 _T.globalEval = function(code) { 261 return myfaces._impl.core._EvalHandlers.globalEval(code); 262 }; 263 264 /** 265 * applies an object to a namespace 266 * basically does what bla.my.name.space = obj does 267 * note we cannot use var myNameSpace = fetchNamespace("my.name.space") 268 * myNameSpace = obj because the result of fetch is already the object 269 * which the namespace points to, hence this function 270 * 271 * @param {String} nms the namespace to be assigned to 272 * @param {Object} obj the object to be assigned 273 * @name myfaces._impl.core._Runtime.applyToGlobalNamespace 274 * @function 275 */ 276 _T.applyToGlobalNamespace = function(nms, obj) { 277 var splitted = nms.split(/\./); 278 if (splitted.length == 1) { 279 window[nms] = obj; 280 return; 281 } 282 var parent = splitted.slice(0, splitted.length - 1); 283 var child = splitted[splitted.length - 1]; 284 var parentNamespace = _T.fetchNamespace(parent.join(".")); 285 parentNamespace[child] = obj; 286 }; 287 288 /** 289 * fetches the object the namespace points to 290 * @param {String} nms the namespace which has to be fetched 291 * @return the object the namespace points to or null if nothing is found 292 */ 293 this.fetchNamespace = function(nms) { 294 if ('undefined' == typeof nms || null == nms || !_T._reservedNMS[nms]) { 295 return null; 296 } 297 298 var ret = null; 299 try { 300 //blackberries have problems as well in older non webkit versions 301 if (!_T.browser.isIE) {
302 //in ie 6 and 7 we get an error entry despite the suppression 303 ret = _T.globalEval("window." + nms); 304 } 305 //namespace could point to numeric or boolean hence full 306 //save check 307 308 } catch (e) {/*wanted*/ 309 } 310 //ie fallback for some ie versions path because it cannot eval namespaces 311 //ie in any version does not like that particularily 312 //we do it the hard way now 313 if ('undefined' != typeof ret && null != ret) { 314 return ret; 315 } 316 return _T._manuallyResolveNMS(nms); 317 318 }; 319 320 _T._manuallyResolveNMS = function(nms) { 321 //ie fallback for some ie versions path because it cannot eval namespaces 322 //ie in any version does not like that particularily 323 //we do it the hard way now 324 325 nms = nms.split(/\./); 326 var ret = window; 327 var len = nms.length; 328 329 for (var cnt = 0; cnt < len; cnt++) { 330 ret = ret[nms[cnt]]; 331 if ('undefined' == typeof ret || null == ret) { 332 return null; 333 } 334 } 335 return ret; 336 }; 337 338 /** 339 * Backported from dojo 340 * a failsafe string determination method 341 * (since in javascript String != "" typeof alone fails!) 342 * @param {Object} it the object to be checked for being a string 343 * @return {boolean} true in case of being a string false otherwise 344 */ 345 this.isString = function(/*anything*/ it) { 346 // summary: 347 // Return true if it is a String 348 return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean 349 }; 350 351 /** 352 * reserves a namespace in the specific scope 353 * 354 * usage: 355 * if(_T.reserve("org.apache.myfaces.MyUtils")) { 356 * org.apache.myfaces.MyUtils = function() { 357 * } 358 * } 359 * 360 * reserves a namespace and if the namespace is new the function itself is reserved 361 * 362 * 363 * 364 * or: 365 * _T.reserve("org.apache.myfaces.MyUtils", function() { .. }); 366 * 367 * reserves a namespace and if not already registered directly applies the function the namespace 368 * 369 * note for now the reserved namespaces reside as global maps justl like jsf.js but 370 * we also use a speedup index which is kept internally to reduce the number of evals or loops to walk through those 371 * namespaces (eval is a heavy operation and loops even only for namespace resolution introduce (O)2 runtime 372 * complexity while a simple map lookup is (O)log n with additional speedup from the engine. 373 * 374 * 375 * @param {String} nms 376 * @returns {boolean} true if it was not provided 377 * false otherwise for further action 378 */ 379 this.reserveNamespace = function(nms, obj) { 380 381 if (!_T.isString(nms)) { 382 throw Error("Namespace must be a string with . as delimiter"); 383 } 384 if (_T._reservedNMS[nms] || null != _T.fetchNamespace(nms)) { 385 return false; 386 } 387 388 var entries = nms.split(/\./); 389 var currNms = window; 390 391 var tmpNmsName = []; 392 var UDEF = "undefined"; 393 for (var cnt = 0; cnt < entries.length; cnt++) { 394 var subNamespace = entries[cnt]; 395 tmpNmsName.push(subNamespace); 396 if (UDEF == typeof currNms[subNamespace]) { 397 currNms[subNamespace] = {}; 398 } 399 if (cnt == entries.length - 1 && UDEF != typeof obj) { 400 currNms[subNamespace] = obj; 401 } else { 402 currNms = currNms[subNamespace]; 403 } 404 _T._reservedNMS[tmpNmsName.join(".")] = true; 405 } 406 return true; 407 }; 408 409 /** 410 * iterates over all registered singletons in the namespace 411 * @param operator a closure which applies a certain function 412 * on the namespace singleton 413 */ 414 this.iterateSingletons = function(operator) { 415 var singletons = _T._registeredSingletons; 416 for(var key in singletons) { 417 var nms = _T.fetchNamespace(key); 418 operator(nms); 419 } 420 }; 421 /** 422 * iterates over all registered singletons in the namespace 423 * @param operator a closure which applies a certain function 424 * on the namespace singleton 425 */ 426 this.iterateClasses = function(operator) { 427 var classes = _T._registeredClasses; 428 for(var cnt = 0; cnt < classes.length; cnt++) { 429 operator(classes[cnt], cnt); 430 } 431 }; 432 433 /** 434 * check if an element exists in the root 435 * also allows to check for subelements 436 * usage 437 * _T.exists(rootElem,"my.name.space") 438 * @param {Object} root the root element 439 * @param {String} subNms the namespace 440 */ 441 this.exists = function(root, subNms) { 442 if (!root) { 443 return false;
444 } 445 //special case locally reserved namespace 446 if (root == window && _T._reservedNMS[subNms]) { 447 return true; 448 } 449 450 //initial condition root set element not set or null 451 //equals to element exists 452 if (!subNms) { 453 return true; 454 } 455 var UDEF = "undefined"; 456 try { 457 //special condition subnamespace exists as full blown key with . instead of function map 458 if (UDEF != typeof root[subNms]) { 459 return true; 460 } 461 462 //crossported from the dojo toolkit 463 // summary: determine if an object supports a given method 464 // description: useful for longer api chains where you have to test each object in the chain 465 var p = subNms.split("."); 466 var len = p.length; 467 for (var i = 0; i < len; i++) { 468 //the original dojo code here was false because 469 //they were testing against ! which bombs out on exists 470 //which has a value set to false 471 // (TODO send in a bugreport to the Dojo people) 472 473 if (UDEF == typeof root[p[i]]) { 474 return false; 475 } // Boolean 476 root = root[p[i]]; 477 } 478 return true; // Boolean 479 480 } catch (e) { 481 //ie (again) has a special handling for some object attributes here which automatically throw an unspecified error if not existent 482 return false; 483 } 484 }; 485 486 487 488 /** 489 * fetches a global config entry 490 * @param {String} configName the name of the configuration entry 491 * @param {Object} defaultValue 492 * 493 * @return either the config entry or if none is given the default value 494 */ 495 this.getGlobalConfig = function(configName, defaultValue) { 496 /** 497 * note we could use exists but this is an heavy operation, since the config name usually 498 * given this function here is called very often 499 * is a single entry without . in between we can do the lighter shortcut 500 */ 501 return (myfaces["config"] && 'undefined' != typeof myfaces.config[configName] ) ? 502 myfaces.config[configName] 503 : 504 defaultValue; 505 }; 506 507 /** 508 * gets the local or global options with local ones having higher priority 509 * if no local or global one was found then the default value is given back 510 * 511 * @param {String} configName the name of the configuration entry 512 * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely 513 * 514 * @param {Object} defaultValue 515 * 516 * @return either the config entry or if none is given the default value 517 */ 518 this.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) { 519 /*use(myfaces._impl._util)*/ 520 var _local = !!localOptions; 521 var _localResult; 522 var MYFACES = "myfaces"; 523 524 if (_local) { 525 //note we also do not use exist here due to performance improvement reasons 526 //not for now we loose the subnamespace capabilities but we do not use them anyway 527 //this code will give us a performance improvement of 2-3% 528 _localResult = (localOptions[MYFACES]) ? localOptions[MYFACES][configName] : undefined; 529 _local = "undefined" != typeof _localResult; 530 } 531 532 return (!_local) ? _T.getGlobalConfig(configName, defaultValue) : _localResult; 533 }; 534 535 /** 536 * determines the xhr level which either can be 537 * 1 for classical level1 538 * 1.5 for mozillas send as binary implementation 539 * 2 for xhr level 2 540 */ 541 this.getXHRLvl = function() { 542 if (!_T.XHR_LEVEL) { 543 _T.getXHRObject(); 544 } 545 return _T.XHR_LEVEL; 546 }; 547 548 /** 549 * encapsulated xhr object which tracks down various implementations 550 * of the xhr object in a browser independent fashion 551 * (ie pre 7 used to have non standard implementations because 552 * the xhr object standard came after IE had implemented it first 553 * newer ie versions adhere to the standard and all other new browsers do anyway) 554 * 555 * @return the xhr object according to the browser type 556 */ 557 this.getXHRObject = function() { 558 var _ret = new XMLHttpRequest(); 559 //we now check the xhr level 560 //sendAsBinary = 1.5 which means mozilla only 561 //upload attribute present == level2 562 var XHR_LEVEL = "XHR_LEVEL"; 563 if (!_T[XHR_LEVEL]) { 564 var _e = _T.exists; 565 _T[XHR_LEVEL] = (_e(_ret, "sendAsBinary")) ? 1.5 : 1; 566 _T[XHR_LEVEL] = (_e(_ret, "upload") && 'undefined' != typeof FormData) ? 2 : _T.XHR_LEVEL; 567 } 568 return _ret; 569 }; 570 571 /** 572 * loads a script and executes it under a global scope 573 * @param {String} src the source of the script 574 * @param {String} type the type of the script 575 * @param {Boolean} defer defer true or false, same as the javascript tag defer param 576 * @param {String} charSet the charset under which the script has to be loaded 577 * @param {Boolean} async tells whether the script can be asynchronously loaded or not, currently 578 * not used 579 */ 580 this.loadScriptEval = function(src, type, defer, charSet, async) { 581 var xhr = _T.getXHRObject(); 582 xhr.open("GET", src, false); 583 584 if (charSet) { 585 xhr.setRequestHeader("Content-Type", "text/javascript; charset:" + charSet); 586 } 587 588 xhr.send(null); 589 590 //since we are synchronous we do it after not with onReadyStateChange 591 592 if (xhr.readyState == 4) { 593 if (xhr.status == 200) { 594 //defer also means we have to process after the ajax response 595 //has been processed 596 //we can achieve that with a small timeout, the timeout 597 //triggers after the processing is done! 598 if (!defer) { 599 //we moved the sourceurl notation to # instead of @ be
599cause ie does not cover it correctly 600 //newer browsers understand # including ie since windows 8.1 601 //see http://updates.html5rocks.com/2013/06/sourceMappingURL-and-sourceURL-syntax-changed 602 _T.globalEval(xhr.responseText.replace("\n", "\r\n") + "\r\n//# sourceURL=" + src); 603 } else { 604 //TODO not ideal we maybe ought to move to something else here 605 //but since it is not in use yet, it is ok 606 setTimeout(function() { 607 _T.globalEval(xhr.responseText.replace("\n", "\r\n") + "\r\n//# sourceURL=" + src); 608 }, 1); 609 } 610 } else { 611 throw Error(xhr.responseText); 612 } 613 } else { 614 throw Error("Loading of script " + src + " failed "); 615 } 616 617 }; 618 619 /** 620 * load script functionality which utilizes the browser internal 621 * script loading capabilities 622 * 623 * @param {String} src the source of the script 624 * @param {String} type the type of the script 625 * @param {Boolean} defer defer true or false, same as the javascript tag defer param 626 * @param {String} charSet the charset under which the script has to be loaded 627 */ 628 this.loadScriptByBrowser = function(src, type, defer, charSet, async) { 629 //if a head is already present then it is safer to simply 630 //use the body, some browsers prevent head alterations 631 //after the first initial rendering 632 633 //ok this is nasty we have to do a head modification for ie pre 8 634 //the rest can be finely served with body 635 var position = "head"; 636 var UDEF = "undefined"; 637 try { 638 var holder = document.getElementsByTagName(position)[0]; 639 if (UDEF == typeof holder || null == holder) { 640 holder = document.createElement(position); 641 var html = document.getElementsByTagName("html"); 642 html.appendChild(holder); 643 } 644 var script = document.createElement("script"); 645 646 script.type = type || "text/javascript"; 647 script.src = src; 648 if (charSet) { 649 script.charset = charSet; 650 } 651 if (defer) { 652 script.defer = defer; 653 } 654 /*html5 capable browsers can deal with script.async for 655 * proper head loading*/ 656 if (UDEF != typeof script.async) { 657 script.async = async; 658 } 659 holder.appendChild(script); 660 661 } catch (e) { 662 //in case of a loading error we retry via eval 663 return false; 664 } 665 666 return true; 667 }; 668 669 this.loadScript = function(src, type, defer, charSet, async) { 670 //the chrome engine has a nasty javascript bug which prevents 671 //a correct order of scripts being loaded 672 //if you use script source on the head, we have to revert 673 //to xhr+ globalEval for those 674 var b = _T.browser; 675 if (!b.isFF && !b.isWebkit && !b.isOpera >= 10) { 676 _T.loadScriptEval(src, type, defer, charSet); 677 } else { 678 //only firefox keeps the order, sorry ie... 679 _T.loadScriptByBrowser(src, type, defer, charSet, async); 680 } 681 }; 682 683 //Base Patterns, Inheritance, Delegation and Singleton 684 685 686 687 /* 688 * prototype based delegation inheritance 689 * 690 * implements prototype delegaton inheritance dest <- a 691 * 692 * usage 693 * <pre> 694 * var newClass = _T.extends( function (var1, var2) { 695 * _T._callSuper("constructor", var1,var2); 696 * }; 697 * ,origClass); 698 * 699 * newClass.prototype.myMethod = function(arg1) { 700 * _T._callSuper("myMethod", arg1,"hello world"); 701 * .... 702 * 703 * other option 704 * 705 * myfaces._impl._core._Runtime.extends("myNamespace.newClass", parent, { 706 * init: function() {constructor...}, 707 * method1: function(f1, f2) {}, 708 * method2: function(f1, f2,f3) { 709 * _T._callSuper("method2", F1,"hello world"); 710 * } 711 * }); 712 * </p> 713 * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace 714 * @param {function} extendCls the function class to be extended 715 * @param {Object} protoFuncs (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method 716 * 717 * To explain further 718 * prototype functions: 719 * <pre> 720 * newClass.prototype.<prototypeFunction> 721 * namspace function 722 * newCls.<namespaceFunction> = function() {...} 723 * </pre> 724 */ 725 726 this.extendClass = function(newCls, extendCls, protoFuncs, nmsFuncs) { 727 728 if (!_T.isString(newCls)) {
729 throw Error("new class namespace must be of type String"); 730 } 731 var className = newCls; 732 733 if (_T._reservedNMS[newCls]) { 734 return _T.fetchNamespace(newCls); 735 } 736 var constr = "constructor_"; 737 var parClassRef = "_mfClazz"; 738 if(!protoFuncs[constr]) { 739 protoFuncs[constr] = (extendCls[parClassRef] || (extendCls.prototype && extendCls.prototype[parClassRef])) ? 740 function() {this._callSuper("constructor_");}: function() {}; 741 var assigned = true; 742 } 743 744 if ('function' != typeof newCls) { 745 newCls = _reserveClsNms(newCls, protoFuncs); 746 if (!newCls) return null; 747 } 748 //if the type information is known we use that one 749 //with this info we can inherit from objects also 750 //instead of only from classes 751 //sort of like this.extendClass(newCls, extendObj._mfClazz... 752 753 if (extendCls[parClassRef]) { 754 extendCls = extendCls[parClassRef]; 755 } 756 757 if ('undefined' != typeof extendCls && null != extendCls) { 758 //first we have to get rid of the constructor calling problem 759 //problem 760 var tmpFunc = function() { 761 }; 762 tmpFunc.prototype = extendCls.prototype; 763 764 var newClazz = newCls; 765 newClazz.prototype = new tmpFunc(); 766 tmpFunc = null; 767 var clzProto = newClazz.prototype; 768 clzProto.constructor = newCls; 769 clzProto._parentCls = extendCls.prototype; 770 //in case of overrides the namespace is altered with mfclazz 771 //we want the final namespace 772 clzProto._nameSpace = className.replace(/(\._mfClazz)+$/,""); 773 /** 774 * @ignore 775 */ 776 clzProto._callSuper = function(methodName) { 777 var passThrough = (arguments.length == 1) ? [] : Array.prototype.slice.call(arguments, 1); 778 var accDescLevel = "_mfClsDescLvl"; 779 //we store the descension level of each method under a mapped 780 //name to avoid name clashes 781 //to avoid name clashes with internal methods of array 782 //if we don't do this we trap the callSuper in an endless 783 //loop after descending one level 784 var _mappedName = ["_",methodName,"_mf_r"].join(""); 785 this[accDescLevel] = this[accDescLevel] || new Array(); 786 var descLevel = this[accDescLevel]; 787 //we have to detect the descension level 788 //we now check if we are in a super descension for the current method already 789 //if not we are on this level 790 var _oldDescLevel = this[accDescLevel][_mappedName] || this; 791 //we now step one level down 792 var _parentCls = _oldDescLevel._parentCls; 793 var ret = null; 794 try { 795 //we now store the level position as new descension level for callSuper 796 descLevel[_mappedName] = _parentCls; 797 //and call the code on this 798 if(!_parentCls[methodName]) { 799 throw Error("Method _callSuper('"+ methodName+"') called from "+className+" Method does not exist "); 800 } 801 ret = _parentCls[methodName].apply(this, passThrough); 802 } finally { 803 descLevel[_mappedName] = _oldDescLevel; 804 } 805 if('undefined' != typeof ret) { 806 return ret; 807 } 808 }; 809 //reference to its own type 810 clzProto[parClassRef] = newCls; 811 _T._registeredClasses.push(clzProto); 812 } 813 814 //we now map the function map in 815 _T._applyFuncs(newCls, protoFuncs, true); 816 //we could add inherited but that would make debugging harder 817 //see http://www.ruzee.com/blog/2008/12/javascript-inheritance-via-prototypes-and-closures on how to do it 818 819 _T._applyFuncs(newCls, nmsFuncs, false); 820 821 return newCls; 822 }; 823 824 825 826 /** 827 * Extends a class and puts a singleton instance at the reserved namespace instead 828 * of its original class 829 * 830 * @param {function|String} newCls either a unnamed function which can be assigned later or a namespace 831 * @param {function} extendsCls the function class to be extended 832 * @param {Object} protoFuncs (Map) an optional map of prototype functions which in case of overwriting a base function get an inherited method 833 */ 834 this.singletonExtendClass = function(newCls, extendsCls, protoFuncs, nmsFuncs) { 835 _T._registeredSingletons[newCls] = true; 836 return _T._makeSingleton(_T.extendClass, newCls, extendsCls, protoFuncs, nmsFuncs); 837 }; 838 839 840 841 //since the object is self contained and only
842 //can be delegated we can work with real private 843 //functions here, the other parts of the 844 //system have to emulate them via _ prefixes 845 this._makeSingleton = function(ooFunc, newCls, delegateObj, protoFuncs, nmsFuncs) { 846 if (_T._reservedNMS[newCls]) { 847 return _T._reservedNMS[newCls]; 848 } 849 850 var clazz = ooFunc(newCls + "._mfClazz", delegateObj, protoFuncs, nmsFuncs); 851 if (clazz != null) { 852 _T.applyToGlobalNamespace(newCls, new clazz()); 853 } 854 return _T.fetchNamespace(newCls)["_mfClazz"] = clazz; 855 }; 856 857 //internal class namespace reservation depending on the type (string or function) 858 var _reserveClsNms = function(newCls, protoFuncs) { 859 var constr = null; 860 var UDEF = "undefined"; 861 if (UDEF != typeof protoFuncs && null != protoFuncs) { 862 constr = (UDEF != typeof null != protoFuncs['constructor_'] && null != protoFuncs['constructor_']) ? protoFuncs['constructor_'] : function() { 863 }; 864 } else { 865 constr = function() { 866 }; 867 } 868 869 if (!_T.reserveNamespace(newCls, constr)) { 870 return null; 871 } 872 newCls = _T.fetchNamespace(newCls); 873 return newCls; 874 }; 875 876 this._applyFuncs = function (newCls, funcs, proto) { 877 if (funcs) { 878 for (var key in funcs) { 879 //constructor already passed, callSuper already assigned 880 if ('undefined' == typeof key || null == key || key == "_callSuper") { 881 continue; 882 } 883 if (!proto) 884 newCls[key] = funcs[key]; 885 else 886 newCls.prototype[key] = funcs[key]; 887 } 888 } 889 }; 890 891 /** 892 * general type assertion routine 893 * 894 * @param probe the probe to be checked for the correct type 895 * @param theType the type to be checked for 896 */ 897 this.assertType = function(probe, theType) { 898 return _T.isString(theType) ? probe == typeof theType : probe instanceof theType; 899 }; 900 901 /** 902 * onload wrapper for chaining the onload cleanly 903 * @param func the function which should be added to the load 904 * chain (note we cannot rely on return values here, hence jsf.util.chain will fail) 905 */ 906 this.addOnLoad = function(target, func) { 907 var oldonload = (target) ? target.onload : null; 908 target.onload = (!oldonload) ? func : function() { 909 try { 910 oldonload(); 911 } catch (e) { 912 throw e; 913 } finally { 914 func(); 915 } 916 }; 917 }; 918 919 /** 920 * returns the internationalisation setting 921 * for the given browser so that 922 * we can i18n our messages 923 * 924 * @returns a map with following entires: 925 * <ul> 926 * <li>language: the lowercase language iso code</li> 927 * <li>variant: the uppercase variant iso code</li> 928 * </ul> 929 * null is returned if the browser fails to determine the language settings 930 */ 931 this.getLanguage = function(lOverride) { 932 var deflt = {language: "en", variant: "UK"}; //default language and variant 933 try { 934 var lang = lOverride || navigator.language || navigator.browserLanguage; 935 if (!lang || lang.length < 2) return deflt; 936 return { 937 language: lang.substr(0, 2), 938 variant: (lang.length >= 5) ? lang.substr(3, 5) : null 939 }; 940 } catch(e) { 941 return deflt; 942 } 943 }; 944 945 //implemented in extruntime 946 this.singletonDelegateObj = function() {}; 947 948 /** 949 * browser detection code 950 * cross ported from dojo 1.2 951 * 952 * dojos browser detection code is very sophisticated 953 * hence we port it over it allows a very fine grained detection of 954 * browsers including the version number 955 * this however only can work out if the user 956 * does not alter the user agent, which they normally dont! 957 *
958 * the exception is the ie detection which relies on specific quirks in ie 959 */ 960 var n = navigator; 961 var dua = n.userAgent, 962 dav = n.appVersion, 963 tv = parseFloat(dav); 964 var _T = this; 965 _T.browser = {}; 966 myfaces._impl.core._EvalHandlers.browser = _T.browser; 967 var d = _T.browser; 968 969 if (dua.indexOf("Opera") >= 0) { 970 _T.isOpera = tv; 971 } 972 if (dua.indexOf("AdobeAIR") >= 0) { 973 d.isAIR = 1; 974 } 975 if (dua.indexOf("BlackBerry") >= 0) { 976 d.isBlackBerry = tv; 977 } 978 d.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : 0; 979 d.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined; 980 d.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined; 981 982 // safari detection derived from: 983 // http://developer.apple.com/internet/safari/faq.html#anchor2 984 // http://developer.apple.com/internet/safari/uamatrix.html 985 var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0); 986 if (index && !d.isChrome) { 987 // try to grab the explicit Safari version first. If we don't get 988 // one, look for less than 419.3 as the indication that we're on something 989 // "Safari 2-ish". 990 d.isSafari = parseFloat(dav.split("Version/")[1]); 991 if (!d.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3) { 992 d.isSafari = 2; 993 } 994 } 995 996 //>>excludeStart("webkitMobile", kwArgs.webkitMobile); 997 998 if (dua.indexOf("Gecko") >= 0 && !d.isKhtml && !d.isWebKit) { 999 d.isMozilla = d.isMoz = tv; 1000 } 1001 if (d.isMoz) { 1002 //We really need to get away from _T. Consider a sane isGecko approach for the future. 1003 d.isFF = parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1] || dua.split("Shiretoko/")[1]) || undefined; 1004 } 1005 1006 if (document.all && !d.isOpera && !d.isBlackBerry) { 1007 d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined; 1008 d.isIEMobile = parseFloat(dua.split("IEMobile")[1]); 1009 //In cases where the page has an HTTP header or META tag with 1010 //X-UA-Compatible, then it is in emulation mode, for a previous 1011 //version. Make sure isIE reflects the desired version. 1012 //document.documentMode of 5 means quirks mode. 1013 1014 /** @namespace document.documentMode */ 1015 if (d.isIE >= 8 && document.documentMode != 5) { 1016 d.isIE = document.documentMode; 1017 } 1018 } 1019 }; 1020} 1021 1022 1023/* Licensed to the Apache Software Foundation (ASF) under one or more 1024 * contributor license agreements. See the NOTICE file distributed with 1025 * this work for additional information regarding copyright ownership. 1026 * The ASF licenses this file to you under the Apache License, Version 2.0 1027 * (the "License"); you may not use this file except in compliance with 1028 * the License. You may obtain a copy of the License at 1029 * 1030 * http://www.apache.org/licenses/LICENSE-2.0 1031 * 1032 * Unless required by applicable law or agreed to in writing, software 1033 * distributed under the License is distributed on an "AS IS" BASIS, 1034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1035 * See the License for the specific language governing permissions and 1036 * limitations under the License. 1037 */ 1038if (!document.querySelectorAll || !window.XMLHttpRequest) { 1039 1040 //initial browser detection, we encapsule it in a closure 1041 //to drop all temporary variables from ram as soon as possible 1042 //we run into the quirks fallback if XMLHttpRequest is not enabled 1043 (function() { 1044 var _T = myfaces._impl.core._Runtime; 1045 1046 _T.getXHRObject = function() { 1047 //since this is a global object ie hates it if we do not check for undefined 1048 if (window.XMLHttpRequest) { 1049 var _ret = new XMLHttpRequest(); 1050 //we now check the xhr level 1051 //sendAsBinary = 1.5 which means mozilla only 1052 //upload attribute present == level2 1053 1054 if (!_T.XHR_LEVEL) { 1055 var _e = _T.exists; 1056 _T.XHR_LEVEL = (_e(_ret, "sendAsBinary")) ? 1.5 : 1; 1057 _T.XHR_LEVEL = (_e(_ret, "upload") && 'undefined' != typeof FormData) ? 2 : _T.XHR_LEVEL; 1058 } 1059 return _ret; 1060 } 1061 //IE 1062 try { 1063 _T.XHR_LEVEL = 1; 1064 return new ActiveXObject("Msxml2.XMLHTTP"); 1065 } catch (e) { 1066 1067 } 1068 return new ActiveXObject('Microsoft.XMLHTTP'); 1069 }; 1070 1071 1072 })(); 1073} 1074/* Licensed to the Apache Software Foundation (ASF) under one or more 1075 * contributor license agreements. See the NOTICE file distributed with 1076 * this work for additional information regarding copyright ownership. 1077 * The ASF licenses this file to you under the Apache License, Version 2.0 1078 * (the "License");
1078 you may not use this file except in compliance with 1079 * the License. You may obtain a copy of the License at 1080 * 1081 * http://www.apache.org/licenses/LICENSE-2.0 1082 * 1083 * Unless required by applicable law or agreed to in writing, software 1084 * distributed under the License is distributed on an "AS IS" BASIS, 1085 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1086 * See the License for the specific language governing permissions and 1087 * limitations under the License. 1088 */ 1089/*we cannot privatize with a global function hence we store the values away for the init part*/ 1090(function() { 1091 var target = window || document.body; 1092 var impl = "myfaces._impl."; 1093 var params = {_PFX_UTIL: impl + "_util.", 1094 _PFX_CORE:impl + "core.", 1095 _PFX_XHR: impl + "xhrCore.", 1096 _PFX_I18N: impl + "i18n."}; 1097 if ('undefined' != typeof target.myfaces) { 1098 //some mobile browsers do not have a window object 1099 var _RT = myfaces._impl.core._Runtime; 1100 params._MF_CLS = _RT.extendClass; 1101 params._MF_SINGLTN = _RT.singletonExtendClass; 1102 } else { 1103 params._MF_CLS = false; 1104 params._MF_SINGLTN = false; 1105 target.myfaces = {}; 1106 } 1107 target.myfaces._implTemp = {}; 1108 for (var key in params) { 1109 target.myfaces._implTemp[key] = target[key]; 1110 target[key] = params[key]; 1111 } 1112})(); 1113 1114/* Licensed to the Apache Software Foundation (ASF) under one or more 1115 * contributor license agreements. See the NOTICE file distributed with 1116 * this work for additional information regarding copyright ownership. 1117 * The ASF licenses this file to you under the Apache License, Version 2.0 1118 * (the "License"); you may not use this file except in compliance with 1119 * the License. You may obtain a copy of the License at 1120 * 1121 * http://www.apache.org/licenses/LICENSE-2.0 1122 * 1123 * Unless required by applicable law or agreed to in writing, software 1124 * distributed under the License is distributed on an "AS IS" BASIS, 1125 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1126 * See the License for the specific language governing permissions and 1127 * limitations under the License. 1128 */ 1129 1130/** 1131 * @memberOf myfaces._impl 1132 * @namespace 1133 * @name i18n 1134 */ 1135 1136/** 1137 * System messages base version <p /> 1138 * (note the base version is basically the en_US) version 1139 * of all messages 1140 * 1141 * @class 1142 * @name Messages 1143 * @memberOf myfaces._impl.i18n 1144 */ 1145_MF_CLS && _MF_CLS(_PFX_I18N+"Messages", Object, 1146/** 1147 * @lends myfaces._impl.i18n.Messages.prototype 1148 */ 1149{ 1150 1151 MSG_TEST: "Testmessage", 1152 1153 /*Messages*/ 1154 /** @constant */ 1155 MSG_DEV_MODE: "Note, this message is only sent, because project stage is development and no " + 1156 "other error listeners are registered.", 1157 /** @constant */ 1158 MSG_AFFECTED_CLASS: "Affected Class:", 1159 /** @constant */ 1160 MSG_AFFECTED_METHOD: "Affected Method:", 1161 /** @constant */ 1162 MSG_ERROR_NAME: "Error Name:", 1163 /** @constant */ 1164 MSG_ERROR_MESSAGE: "Error Message:", 1165 /** @constant */ 1166 MSG_SERVER_ERROR_NAME: "Server Error Name:", 1167 1168 /** @constant */ 1169 MSG_ERROR_DESC: "Error Description:", 1170 /** @constant */ 1171 MSG_ERROR_NO: "Error Number:", 1172 /** @constant */ 1173 MSG_ERROR_LINENO: "Error Line Number:", 1174 1175 /*Errors and messages*/ 1176 /** @constant */ 1177 ERR_FORM: "Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing", 1178 /** @constant */ 1179 ERR_VIEWSTATE: "jsf.viewState: param value not of type form!", 1180 /** @constant */ 1181 ERR_TRANSPORT: "Transport type {0} does not exist", 1182 /** @constant */ 1183 ERR_EVT_PASS: "an event must be passed down (either a an event object null or undefined) ", 1184 /** @constant */ 1185 ERR_CONSTRUCT: "Parts of the response couldn't be retrieved when constructing the event data: {0} ", 1186 /** @constant */ 1187 ERR_MALFORMEDXML: "The server response could not be parsed, the server has returned with a response which is not xml !", 1188 /** @constant */ 1189 ERR_SOURCE_FUNC: "source cannot be a function (probably source and event were not defined or set to null", 1190 /** @constant */ 1191 ERR_EV_OR_UNKNOWN: "An event object or unknown must be passed as second parameter", 1192 /** @constant */ 1193 ERR_SOURCE_NOSTR: "source cannot be a string", 1194 /** @constant */ 1195 ERR_SOURCE_DEF_NULL: "source must be defined or null", 1196 1197 //_Lang.js 1198 /** @constant */ 1199 ERR_MUST_STRING: "{0}: {1}
1199 namespace must be of type String", 1200 /** @constant */ 1201 ERR_REF_OR_ID: "{0}: {1} a reference node or identifier must be provided", 1202 /** @constant */ 1203 ERR_PARAM_GENERIC: "{0}: parameter {1} must be of type {2}", 1204 /** @constant */ 1205 ERR_PARAM_STR: "{0}: {1} param must be of type string", 1206 /** @constant */ 1207 ERR_PARAM_STR_RE: "{0}: {1} param must be of type string or a regular expression", 1208 /** @constant */ 1209 ERR_PARAM_MIXMAPS: "{0}: both a source as well as a destination map must be provided", 1210 /** @constant */ 1211 ERR_MUST_BE_PROVIDED: "{0}: an {1} and a {2} must be provided", 1212 /** @constant */ 1213 ERR_MUST_BE_PROVIDED1: "{0}: {1} must be set", 1214 1215 /** @constant */ 1216 ERR_REPLACE_EL: "replaceElements called while evalNodes is not an array", 1217 1218 /** @constant */ 1219 ERR_EMPTY_RESPONSE: "{0}: The response cannot be null or empty!", 1220 /** @constant */ 1221 ERR_ITEM_ID_NOTFOUND: "{0}: item with identifier {1} could not be found", 1222 /** @constant */ 1223 ERR_PPR_IDREQ: "{0}: Error in PPR Insert, id must be present", 1224 /** @constant */ 1225 ERR_PPR_INSERTBEFID: "{0}: Error in PPR Insert, before id or after id must be present", 1226 /** @constant */ 1227 ERR_PPR_INSERTBEFID_1: "{0}: Error in PPR Insert, before node of id {1} does not exist in document", 1228 /** @constant */ 1229 ERR_PPR_INSERTBEFID_2: "{0}: Error in PPR Insert, after node of id {1} does not exist in document", 1230 1231 /** @constant */ 1232 ERR_PPR_DELID: "{0}: Error in delete, id not in xml markup", 1233 /** @constant */ 1234 ERR_PPR_UNKNOWNCID: "{0}: Unknown Html-Component-ID: {1}", 1235 1236 /** @constant */ 1237 ERR_NO_VIEWROOTATTR: "{0}: Changing of ViewRoot attributes is not supported", 1238 /** @constant */ 1239 ERR_NO_HEADATTR: "{0}: Changing of Head attributes is not supported", 1240 /** @constant */ 1241 ERR_RED_URL: "{0}: Redirect without url", 1242 1243 /** @constant */ 1244 ERR_REQ_FAILED_UNKNOWN: "Request failed with unknown status", 1245 1246 /** @constant */ 1247 ERR_REQU_FAILED: "Request failed with status {0} and reason {1}", 1248 1249 /** @constant */ 1250 UNKNOWN: "UNKNOWN", 1251 1252 ERR_NO_MULTIPART_FORM: "The form with the id {0} has an input file element, but is not a multipart form" 1253}); 1254 1255 1256/* Licensed to the Apache Software Foundation (ASF) under one or more 1257 * contributor license agreements. See the NOTICE file distributed with 1258 * this work for additional information regarding copyright ownership. 1259 * The ASF licenses this file to you under the Apache License, Version 2.0 1260 * (the "License"); you may not use this file except in compliance with 1261 * the License. You may obtain a copy of the License at 1262 * 1263 * http://www.apache.org/licenses/LICENSE-2.0 1264 * 1265 * Unless required by applicable law or agreed to in writing, software 1266 * distributed under the License is distributed on an "AS IS" BASIS, 1267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1268 * See the License for the specific language governing permissions and 1269 * limitations under the License. 1270 */ 1271 1272 1273/** 1274 * System messages german version 1275 * (note the base version is basically the en_US) version 1276 * of all messages 1277 * <p /> 1278 * We use inheritance to overide the default messages with our 1279 * german one, variants can derive from the german one (like 1280 * suisse which do not have the emphasized s) 1281 * <p /> 1282 * By using inheritance we can be sure that we fall back to the default one 1283 * automatically and that our variants only have to override the parts 1284 * which have changed from the baseline 1285 * 1286 * @class 1287 * @name Messages_de 1288 * @extends myfaces._impl.i18n.Messages 1289 * @memberOf myfaces._impl.i18n 1290 */ 1291 1292_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_de", myfaces._impl.i18n.Messages, 1293 /** @lends myfaces._impl.i18n.Messages_de.prototype */ 1294 { 1295 1296 MSG_TEST: "Testnachricht", 1297 1298 /*Messages*/ 1299 MSG_DEV_MODE: "Sie sehen diese Nachricht, da sie sich gerade im Entwicklungsmodus befinden " + 1300 "und sie keine Fehlerbehandlungsfunktionen registriert haben.", 1301 1302 MSG_AFFECTED_CLASS: "Klasse:", 1303 MSG_AFFECTED_METHOD: "Methode:", 1304 1305 MSG_ERROR_NAME: "Fehler Name:", 1306 MSG_ERROR_MESSAGE: "Nachricht:", 1307 MSG_SERVER_ERROR_NAME: "Server Fehler Name:", 1308 1309 MSG_ERROR_DESC: "Fehlerbeschreibung:", 1310 MSG_ERROR_NO: "Fehlernummer:", 1311 MSG_ERROR_LINENO: "Zeilennummer:", 1312 1313 /*Errors and messages*/ 1314 ERR_FORM: "Das Quellformular konnte nicht gefunden werden. " + 1315 "Mögliche Gründe: Sie haben entweder kein formular definiert, oder es kommen mehrere Formulare vor, " + 1316 "die alle das auslösende Element mit demselben Namen besitzen. " + 1317 "Die Weitere Ajax Ausführung wird gestoppt.", 1318 1319 ERR_VIEWSTATE: "jsf.viewState: der Parameter ist not vom Typ form!", 1320 1321 ERR_TRANSPORT: "Transport typ {0} existiert nicht", 1322 ERR_EVT_PASS: "Ein Event Objekt muss übergeben werden (entweder ein event Objekt oder null oder undefined)", 1323 ERR_CONSTRUCT: "Teile des response konnten nicht ermittelt werden während die Event Daten bearbeitet wurden: {0} ", 1324 ERR_MALFORMEDXML: "Es gab zwar eine Antwort des Servers, jedoch war diese nicht im erwarteten XML Format. Der Server hat kein valides XML gesendet! Bearbeitung abgebrochen.", 1325 ERR_SOURCE_FUNC: "source darf keine Funktion sein", 1326 ERR_EV_OR_UNKNOWN: "Ein Ereignis Objekt oder UNKNOWN muss als 2. Parameter übergeben werden", 1327 ERR_SOURCE_NOSTR: "source darf kein String sein", 1328 ERR_SOURCE_DEF_NULL: "source muss entweder definiert oder null sein", 1329 1330 //_Lang.js 1331 ERR_MUST_STRING: "{0}: {1} namespace muss vom Typ String sein", 1332 ERR_REF_OR_ID: "{0}: {1} Ein Referenzknoten oder id muss übergeben werden", 1333 ERR_PARAM_GENERIC: "{0}: Paramter {1} muss vom Typ {2} sein", 1334 ERR_PARAM_STR: "{0}: Parameter {1} muss vom Typ String sein", 1335 ERR_PARAM_STR_RE: "{0}: Parameter {1} muss entweder ein String oder ein Regulärer Ausdruck sein", 1336 ERR_PARAM_MIXMAPS: "{0}: both a source as well as a destination map must be provided", 1337 ERR_MUST_BE_PROVIDED: "{0}: ein {1} und ein {2} müssen übergeben werden", 1338 ERR_MUST_BE_PROVIDED1: "{0}: {1} muss gesetzt sein", 1339 1340 ERR_REPLACE_EL: "replaceElements aufgerufen während evalNodes nicht ein Array ist", 1341 ERR_EMPTY_RESPONSE: "{0}: Die Antwort darf nicht null oder leer sein!", 1342 ERR_ITEM_ID_NOTFOUND: "{0}: Element mit ID {1} konnte nicht gefunden werden", 1343 ERR_PPR_IDREQ: "{0}: Fehler im PPR Insert, ID muss gesetzt sein", 1344 ERR_PPR_INSERTBEFID: "{0}: Fehler im PPR Insert, before ID oder after ID muss gesetzt sein", 1345 ERR_PPR_INSERTBEFID_1: "{0}: Fehler im PPR Insert, before Knoten mit ID {1} Existiert nicht", 1346 ERR_PPR_INSERTBEFID_2: "{0}: Fehler im PPR Insert, after Knoten mit ID {1} Existiert nicht", 1347 1348 ERR_PPR_DELID: "{0}: Fehler im PPR delete, id ist nicht im xml Markup vorhanden", 1349 ERR_PPR_UNKNOWNCID: "{0}: Unbekannte Html-Komponenten-ID: {1}", 1350 ERR_NO_VIEWROOTATTR: "{0}: Ãnderung von ViewRoot Attributen ist nicht erlaubt", 1351 ERR_NO_HEADATTR: "{0}: Ãnderung von Head Attributen ist nicht erlaubt", 1352 ERR_RED_URL: "{0}: Redirect ohne URL", 1353 1354 ERR_REQ_FAILED_UNKNOWN: "Anfrage mit unbekanntem Status fehlgeschlagen", 1355 ERR_REQU_FAILED: "Anfrage mit Status {0} and Ursache {1} fehlgeschlagen", 1356 UNKNOWN: "Unbekannt", 1357 ERR_NO_MULTIPART_FORM: "Das Form Element mit der ID {0} hat ein Fileupload Feld aber ist kein Multipart Form" 1358 1359 }); 1360 1361 1362/* Licensed to the Apache Software Foundation (ASF) under one or more 1363 * contributor license agreements. See the NOTICE file distributed with 1364 * this work for additional information regarding copyright ownership. 1365 * The ASF licenses this file to you under the Apache License, Version 2.0 1366 * (the "License");
1366 you may not use this file except in compliance with 1367 * the License. You may obtain a copy of the License at 1368 * 1369 * http://www.apache.org/licenses/LICENSE-2.0 1370 * 1371 * Unless required by applicable law or agreed to in writing, software 1372 * distributed under the License is distributed on an "AS IS" BASIS, 1373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1374 * See the License for the specific language governing permissions and 1375 * limitations under the License. 1376 */ 1377 1378/** 1379 * System messages dutch version 1380 * 1381 * @class 1382 * @name Messages_nl 1383 * @extends myfaces._impl.i18n.Messages 1384 * @memberOf myfaces._impl.i18n 1385 */ 1386_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_nl", myfaces._impl.i18n.Messages, 1387 /** @lends myfaces._impl.i18n.Messages_nl.prototype */ 1388 { 1389 1390 MSG_TEST: "Testbericht", 1391 1392 /*Messages*/ 1393 MSG_DEV_MODE: "Opmerking, dit bericht is enkel gestuurd omdat het project stadium develoment is en er geen " + 1394 "andere listeners zijn geconfigureerd.", 1395 MSG_AFFECTED_CLASS: "Betrokken Klasse:", 1396 MSG_AFFECTED_METHOD: "Betrokken Methode:", 1397 1398 MSG_ERROR_NAME: "Naam foutbericht:", 1399 MSG_ERROR_MESSAGE: "Naam foutbericht:", 1400 1401 MSG_ERROR_DESC: "Omschrijving fout:", 1402 MSG_ERROR_NO: "Fout nummer:", 1403 MSG_ERROR_LINENO: "Fout lijn nummer:", 1404 1405 /*Errors and messages*/ 1406 ERR_FORM: "De doel form kon niet bepaald worden, ofwel omdat het element niet tot een form behoort, ofwel omdat er verschillende forms zijn met 'named element' met dezelfde identifier of naam, ajax verwerking is gestopt.", 1407 ERR_VIEWSTATE: "jsf.viewState: param waarde is niet van het type form!", 1408 ERR_TRANSPORT: "Transport type {0} bestaat niet", 1409 ERR_EVT_PASS: "een event moet opgegegevn worden (ofwel een event object null of undefined) ", 1410 ERR_CONSTRUCT: "Delen van het antwoord konden niet opgehaald worden bij het aanmaken van de event data: {0} ", 1411 ERR_MALFORMEDXML: "Het antwoordt van de server kon niet ontleed worden, de server heeft een antwoord gegeven welke geen xml bevat!", 1412 ERR_SOURCE_FUNC: "source kan geen functie zijn (waarschijnlijk zijn source en event niet gedefinieerd of kregen de waarde null)", 1413 ERR_EV_OR_UNKNOWN: "Een event object of 'unknown' moet gespecifieerd worden als tweede parameter", 1414 ERR_SOURCE_NOSTR: "source kan geen string zijn", 1415 ERR_SOURCE_DEF_NULL: "source moet gedefinieerd zijn of null bevatten", 1416 1417 //_Lang.js 1418 ERR_MUST_STRING: "{0}: {1} namespace moet van het type String zijn", 1419 ERR_REF_OR_ID: "{0}: {1} een referentie node of identifier moet opgegeven worden", 1420 ERR_PARAM_GENERIC: "{0}: parameter {1} moet van het type {2} zijn", 1421 ERR_PARAM_STR: "{0}: {1} parameter moet van het type string zijn", 1422 ERR_PARAM_STR_RE: "{0}: {1} parameter moet van het type string zijn of een reguliere expressie", 1423 ERR_PARAM_MIXMAPS: "{0}: zowel source als destination map moeten opgegeven zijn", 1424 ERR_MUST_BE_PROVIDED: "{0}: een {1} en een {2} moeten opgegeven worden", 1425 ERR_MUST_BE_PROVIDED1: "{0}: {1} moet gezet zijn", 1426 1427 ERR_REPLACE_EL: "replaceElements opgeroepen maar evalNodes is geen array", 1428 ERR_EMPTY_RESPONSE: "{0}: Het antwoord kan geen null of leeg zijn!", 1429 ERR_ITEM_ID_NOTFOUND: "{0}: item met identifier {1} kan niet gevonden worden", 1430 ERR_PPR_IDREQ: "{0}: Fout in PPR Insert, id moet bestaan", 1431 ERR_PPR_INSERTBEFID: "{0}: Fout in PPR Insert, before id of after id moet bestaan", 1432 ERR_PPR_INSERTBEFID_1: "{0}: Fout in PPR Insert, before node van id {1} bestaat niet in het document", 1433 ERR_PPR_INSERTBEFID_2: "{0}: Fout in PPR Insert, after node van id {1} bestaat niet in het document", 1434 1435 ERR_PPR_DELID: "{0}: Fout in delete, id is niet in de xml markup", 1436 ERR_PPR_UNKNOWNCID: "{0}: Onbekende Html-Component-ID: {1}", 1437 ERR_NO_VIEWROOTATTR: "{0}: Wijzigen van ViewRoot attributen is niet ondersteund", 1438 ERR_NO_HEADATTR: "{0}: Wijzigen van Head attributen is niet ondersteund", 1439 ERR_RED_URL: "{0}: Redirect zonder url", 1440 1441 ERR_REQ_FAILED_UNKNOWN: "Request mislukt met onbekende status", 1442 ERR_REQU_FAILED: "Request mislukt met status {0} en reden {1}", 1443 UNKNOWN: "ONBEKEND" 1444 1445 }); 1446 1447/* Licensed to the Apache Software Foundation (ASF) under one or more 1448 * contributor license agreements. See the NOTICE file distributed with 1449 * this work for additional information regarding copyright ownership. 1450 * The ASF licenses this file to you under the Apache License, Version 2.0 1451 * (the "License");
1451 you may not use this file except in compliance with 1452 * the License. You may obtain a copy of the License at 1453 * 1454 * http://www.apache.org/licenses/LICENSE-2.0 1455 * 1456 * Unless required by applicable law or agreed to in writing, software 1457 * distributed under the License is distributed on an "AS IS" BASIS, 1458 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1459 * See the License for the specific language governing permissions and 1460 * limitations under the License. 1461 */ 1462 1463 1464/** 1465 * System messages spanish version version 1466 * (note the base version is basically the en_US) version 1467 * of all messages 1468 * 1469 * @class 1470 * @name Messages_es 1471 * @extends myfaces._impl.i18n.Messages 1472 * @memberOf myfaces._impl.i18n 1473 */ 1474 1475_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_es", myfaces._impl.i18n.Messages, 1476 /** @lends myfaces._impl.i18n.Messages_es.prototype */ 1477 { 1478 1479 1480 MSG_TEST: "Mensajeprueba", 1481 1482 /*Messages*/ 1483 MSG_DEV_MODE: "Aviso. Este mensaje solo se envia porque el 'Project Stage' es 'Development' y no hay otros 'listeners' de errores registrados.", 1484 MSG_AFFECTED_CLASS: "Clase Afectada:", 1485 MSG_AFFECTED_METHOD: "M�todo Afectado:", 1486 1487 MSG_ERROR_NAME: "Nombre del Error:", 1488 MSG_ERROR_MESSAGE: "Mensaje del Error:", 1489 MSG_SERVER_ERROR_NAME: "Mensaje de error de servidor:", 1490 1491 MSG_ERROR_DESC: "Descripci�n del Error:", 1492 MSG_ERROR_NO: "N�mero de Error:", 1493 MSG_ERROR_LINENO: "N�mero de L�nea del Error:", 1494 1495 /*Errors and messages*/
1496 ERR_FORM: "El formulario de origen no ha podido ser determinado, debido a que el elemento no forma parte de un formulario o hay diversos formularios con elementos usando el mismo nombre o identificador. Parando el procesamiento de Ajax.", 1497 ERR_VIEWSTATE: "jsf.viewState: el valor del par�metro no es de tipo 'form'!", 1498 ERR_TRANSPORT: "El tipo de transporte {0} no existe", 1499 ERR_EVT_PASS: "un evento debe ser transmitido (sea null o no definido)", 1500 ERR_CONSTRUCT: "Partes de la respuesta no pudieron ser recuperadas cuando construyendo los datos del evento: {0} ", 1501 ERR_MALFORMEDXML: "La respuesta del servidor no ha podido ser interpretada. El servidor ha devuelto una respuesta que no es xml !", 1502 ERR_SOURCE_FUNC: "el origen no puede ser una funci�n (probablemente 'source' y evento no han sido definidos o son 'null'", 1503 ERR_EV_OR_UNKNOWN: "Un objeto de tipo evento o desconocido debe ser pasado como segundo par�metro", 1504 ERR_SOURCE_NOSTR: "el origen no puede ser 'string'", 1505 ERR_SOURCE_DEF_NULL: "el origen debe haber sido definido o ser 'null'", 1506 1507 //_Lang.js 1508 ERR_MUST_STRING: "{0}: {1} namespace debe ser de tipo String", 1509 ERR_REF_OR_ID: "{0}: {1} una referencia a un nodo o identificador tiene que ser pasada", 1510 ERR_PARAM_GENERIC: "{0}: el par�metro {1} tiene que ser de tipo {2}", 1511 ERR_PARAM_STR: "{0}: el par�metro {1} tiene que ser de tipo string", 1512 ERR_PARAM_STR_RE: "{0}: el par�metro {1} tiene que ser de tipo string o una expresi�n regular", 1513 ERR_PARAM_MIXMAPS: "{0}: han de ser pasados tanto un origen como un destino", 1514 ERR_MUST_BE_PROVIDED: "{0}: {1} y {2} deben ser pasados", 1515 ERR_MUST_BE_PROVIDED1: "{0}: {1} debe estar definido", 1516 1517 ERR_REPLACE_EL: "replaceElements invocado mientras que evalNodes no es un an array", 1518 ERR_EMPTY_RESPONSE: "{0}: �La respuesta no puede ser de tipo 'null' o vac�a!", 1519 ERR_ITEM_ID_NOTFOUND: "{0}: el elemento con identificador {1} no ha sido encontrado", 1520 ERR_PPR_IDREQ: "{0}: Error en PPR Insert, 'id' debe estar presente", 1521 ERR_PPR_INSERTBEFID: "{0}: Error in PPR Insert, antes de 'id' o despu�s de 'id' deben estar presentes", 1522 ERR_PPR_INSERTBEFID_1: "{0}: Error in PPR Insert, antes de nodo con id {1} no existe en el documento", 1523 ERR_PPR_INSERTBEFID_2: "{0}: Error in PPR Insert, despu�s de nodo con id {1} no existe en el documento", 1524 1525 ERR_PPR_DELID: "{0}: Error durante borrado, id no presente en xml", 1526 ERR_PPR_UNKNOWNCID: "{0}: Desconocido Html-Component-ID: {1}", 1527 ERR_NO_VIEWROOTATTR: "{0}: El cambio de atributos de ViewRoot attributes no es posible", 1528 ERR_NO_HEADATTR: "{0}: El cambio de los atributos de Head attributes no es posible", 1529 ERR_RED_URL: "{0}: Redirecci�n sin url", 1530 1531 ERR_REQ_FAILED_UNKNOWN: "La petici�n ha fallado con estado desconocido", 1532 ERR_REQU_FAILED: "La petici�n ha fallado con estado {0} y raz�n {1}", 1533 UNKNOWN: "DESCONOCIDO" 1534 1535 }); 1536 1537 1538 1539/* Licensed to the Apache Software Foundation (ASF) under one or more 1540 * contributor license agreements. See the NOTICE file distributed with 1541 * this work for additional information regarding copyright ownership. 1542 * The ASF licenses this file to you under the Apache License, Version 2.0 1543 * (the "License"); you may not use this file except in compliance with 1544 * the License. You may obtain a copy of the License at 1545 * 1546 * http://www.apache.org/licenses/LICENSE-2.0 1547 * 1548 * Unless required by applicable law or agreed to in writing, software 1549 * distributed under the License is distributed on an "AS IS" BASIS, 1550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1551 * See the License for the specific language governing permissions and 1552 * limitations under the License. 1553 */ 1554 1555 1556 /** 1557 * System messages french version version 1558 * (note the base version is basically the en) version 1559 * of all messages 1560 * 1561 * @class 1562 * @name Messages_fr 1563 * @extends myfaces._impl.i18n.Messages 1564 * @memberOf myfaces._impl.i18n 1565 */ 1566_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_fr", myfaces._impl.i18n.Messages, 1567 /** @lends myfaces._impl.i18n.Messages_fr.prototype */ 1568 { 1569 MSG_TEST: "MessageTest FR", 1570 1571 /*Messages*/ 1572 MSG_DEV_MODE: "Note : ce message n'est envoyé que parce que le projet est au stade de développement et " + 1573 "qu'aucun autre listener d'erreurs n'est enregistré.", 1574 MSG_AFFECTED_CLASS: "Classe affectée : ", 1575 MSG_AFFECTED_METHOD: "Méthode affectée : ", 1576 1577 MSG_ERROR_NAME: "Nom de l'erreur : ", 1578 MSG_ERROR_MESSAGE: "Nom de l'erreur : ", 1579 1580 MSG_ERROR_DESC: "Description de l'erreur : ", 1581 MSG_ERROR_NO: "Numéro de l'erreur : ", 1582 MSG_ERROR_LINENO: "Erreur à la ligne : ", 1583 1584 /*Errors and messages*/ 1585 ERR_FORM: "Le formulaire source n'a pas pu être déterminé, soit parce que l'élément n'est rattaché à aucun formulaire, soit parce qu'ils y a plusieurs formulaires contenant des éléments avec le même nom ou identifiant. Arrêt du traitement AJAX", 1586 ERR_VIEWSTATE: "jsf.viewState: La valeur de 'param' n'est pas de type 'form' !", 1587 ERR_TRANSPORT: "Le type de tansport {0} n'existe pas", 1588 ERR_EVT_PASS: "Un évènement doit être transmis (soit un objet évènement, soit null ou undefined) ", 1589 ERR_CONSTRUCT: "Des éléments de la réponse n'ont pu être récupérés lors de la construction des données de l'évènement : {0} ", 1590 ERR_MALFORMEDXML: "La réponse du serveur n'a pas pu être analysée : le serveur n'a pas renvoyé une réponse en xml !", 1591 ERR_SOURCE_FUNC: "La source ne peut pas être une fonction (Il est probable que 'source' et 'event' n'ont pas été définis ou mis à null", 1592 ERR_EV_OR_UNKNOWN: "Le second paramètre doit être un objet évènement ou 'unknown' ", 1593 ERR_SOURCE_NOSTR: "La source ne peut pas être de type Str
1593ing", 1594 ERR_SOURCE_DEF_NULL: "La source doit être définie ou égale à null", 1595 1596 //_Lang.js 1597 ERR_MUST_STRING: "{0}: Le namespace {1} doit être de type String", 1598 ERR_REF_OR_ID: "{0}: {1} un noeud de référence ou un identifiant doit être passé", 1599 ERR_PARAM_GENERIC: "{0}: Le paramètre {1} doit être de type {2}", 1600 ERR_PARAM_STR: "{0}: Le paramètre {1} doit être de type String", 1601 ERR_PARAM_STR_RE: "{0}: Le paramètre {1} doit être de type String ou être une expression régulière", 1602 ERR_PARAM_MIXMAPS: "{0}: Un Map de source et un Map de destination doivent être passés", 1603 ERR_MUST_BE_PROVIDED: "{0}: un(e) {1} et un(e) {2} doivent être passés", 1604 ERR_MUST_BE_PROVIDED1: "{0}: {1} doit être défini", 1605 1606 ERR_REPLACE_EL: "replaceElements a été appelé alors que evalNodes n'est pas un tableau", 1607 ERR_EMPTY_RESPONSE: "{0}: La réponse ne peut pas être nulle ou vide !", 1608 ERR_ITEM_ID_NOTFOUND: "{0}: l'élément portant l'identifiant {1} n'a pas pu être trouvé", 1609 ERR_PPR_IDREQ: "{0}: Erreur lors de l'insertion PPR, l'id doit être présent", 1610 ERR_PPR_INSERTBEFID: "{0}: Erreur lors de l'insertion PPR, 'before id' ou 'after id' doivent être présents", 1611 ERR_PPR_INSERTBEFID_1: "{0}: Erreur lors de l'insertion PPR, le noeud before de l'id {1} n'existe pas dans le document", 1612 ERR_PPR_INSERTBEFID_2: "{0}: Erreur lors de l'insertion PPR, le noeud after de l'id {1} n'existe pas dans le document", 1613 1614 ERR_PPR_DELID: "{0}: Erreur lors de la suppression, l'id n'est pas présent dans le xml", 1615 ERR_PPR_UNKNOWNCID: "{0}: Html-Component-ID inconnu : {1}", 1616 ERR_NO_VIEWROOTATTR: "{0}: Le changement d'attributs dans ViewRoot n'est pas supporté", 1617 ERR_NO_HEADATTR: "{0}: Le changement d'attributs dans Head n'est pas supporté", 1618 ERR_RED_URL: "{0}: Redirection sans url" 1619 }); 1620 1621/* Licensed to the Apache Software Foundation (ASF) under one or more 1622 * contributor license agreements. See the NOTICE file distributed with 1623 * this work for additional information regarding copyright ownership. 1624 * The ASF licenses this file to you under the Apache License, Version 2.0 1625 * (the "License"); you may not use this file except in compliance with 1626 * the License. You may obtain a copy of the License at 1627 * 1628 * http://www.apache.org/licenses/LICENSE-2.0 1629 * 1630 * Unless required by applicable law or agreed to in writing, software 1631 * distributed under the License is distributed on an "AS IS" BASIS, 1632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1633 * See the License for the specific language governing permissions and 1634 * limitations under the License. 1635 */ 1636 1637/** 1638 * System messages italian version version 1639 * (note the base version is basically the en_US) version 1640 * of all messages 1641 * 1642 * @class 1643 * @name Messages_it 1644 * @extends myfaces._impl.i18n.Messages 1645 * @memberOf myfaces._impl.i18n 1646 */ 1647_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_it", myfaces._impl.i18n.Messages, 1648 /** @lends myfaces._impl.i18n.Messages_it.prototype */ 1649 { 1650 /*Messages*/ 1651 MSG_DEV_MODE: "Questo messaggio � stato inviato esclusivamente perch� il progetto � in development stage e nessun altro listener � stato registrato.", 1652 MSG_AFFECTED_CLASS: "Classi coinvolte:", 1653 MSG_AFFECTED_METHOD: "Metodi coinvolti:", 1654 1655 MSG_ERROR_NAME: "Nome dell'errore:", 1656 MSG_ERROR_MESSAGE: "Nome dell'errore:", 1657 1658 MSG_ERROR_DESC: "Descrizione dell'errore:", 1659 MSG_ERROR_NO: "Numero errore:", 1660 MSG_ERROR_LINENO: "Numero di riga dell'errore:", 1661 1662 /*Errors and messages*/ 1663 ERR_FORM: "Il Sourceform non puo' essere determinato a causa di una delle seguenti ragioni: l'elemento non e' agganciato ad un form oppure sono presenti pi� form con elementi con lo stesso nome, il che blocca l'elaborazione aja
1663x", 1664 ERR_VIEWSTATE: "jsf.viewState: il valore del parametro non � di tipo form!", 1665 ERR_TRANSPORT: "Il transport type {0} non esiste", 1666 ERR_EVT_PASS: "� necessario passare un evento (sono accettati anche gli event object null oppure undefined) ", 1667 ERR_CONSTRUCT: "Durante la costruzione dell' event data: {0} non � stato possibile acquisire alcune parti della response ", 1668 ERR_MALFORMEDXML: "Il formato della risposta del server non era xml, non � stato quindi possibile effettuarne il parsing!", 1669 ERR_SOURCE_FUNC: "source non puo' essere una funzione (probabilmente source and event non erano stati definiti o sono null", 1670 ERR_EV_OR_UNKNOWN: "Come secondo parametro bisogna passare un event object oppure unknown", 1671 ERR_SOURCE_NOSTR: "source non pu� essere una stringa di testo", 1672 ERR_SOURCE_DEF_NULL: "source deve essere definito oppure null", 1673 1674 //_Lang.js 1675 ERR_MUST_STRING: "{0}: {1} namespace deve essere di tipo String", 1676 ERR_REF_OR_ID: "{0}: {1} un reference node oppure un identificatore deve essere fornito", 1677 ERR_PARAM_GENERIC: "{0}: il parametro {1} deve essere di tipo {2}", 1678 ERR_PARAM_STR: "{0}: {1} parametro deve essere di tipo String", 1679 ERR_PARAM_STR_RE: "{0}: {1} parametro deve essere di tipo String oppure una regular expression", 1680 ERR_PARAM_MIXMAPS: "{0}: � necessario specificare sia source che destination map", 1681 ERR_MUST_BE_PROVIDED: "{0}: � necessario specificare sia {1} che {2} ", 1682 ERR_MUST_BE_PROVIDED1: "{0}: {1} deve essere settato", 1683 1684 ERR_REPLACE_EL: "replaceElements chiamato metre evalNodes non � un array", 1685 ERR_EMPTY_RESPONSE: "{0}: La response non puo' essere nulla o vuota!", 1686 ERR_ITEM_ID_NOTFOUND: "{0}: non � stato trovato alcun item con identificativo {1}", 1687 ERR_PPR_IDREQ: "{0}: Errore durante la PPR Insert, l' id deve essere specificato", 1688 ERR_PPR_INSERTBEFID: "{0}: Errore durante la PPR Insert, before id o after id deve essere specificato", 1689 ERR_PPR_INSERTBEFID_1: "{0}: Errore durante la PPR Insert, before node of id {1} non esiste nel document", 1690 ERR_PPR_INSERTBEFID_2: "{0}: Errore durante la PPR Insert, after node of id {1} non esiste nel in document", 1691 1692 ERR_PPR_DELID: "{0}: Errore durante la delete, l'id non e' nella forma di un markup xml", 1693 ERR_PPR_UNKNOWNCID: "{0}: Html-Component-ID: {1} sconosciuto", 1694 ERR_NO_VIEWROOTATTR: "{0}: La modifica degli attributi del ViewRoot non � supportata", 1695 ERR_NO_HEADATTR: "{0}: La modifica degli attributi di Head non � supportata", 1696 ERR_RED_URL: "{0}: Redirect senza url" 1697 }); 1698 1699 1700/* Licensed to the Apache Software Foundation (ASF) under one or more 1701 * contributor license agreements. See the NOTICE file distributed with 1702 * this work for additional information regarding copyright ownership. 1703 * The ASF licenses this file to you under the Apache License, Version 2.0 1704 * (the "License"); you may not use this file except in compliance with 1705 * the License. You may obtain a copy of the License at 1706 * 1707 * http://www.apache.org/licenses/LICENSE-2.0 1708 * 1709 * Unless required by applicable law or agreed to in writing, software 1710 * distributed under the License is distributed on an "AS IS" BASIS, 1711 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1712 * See the License for the specific language governing permissions and 1713 * limitations under the License. 1714 */ 1715if (_MF_CLS) { 1716/** 1717 * System messages kyrillic/russian version 1718 * 1719 * @class 1720 * @name Messages_nl 1721 * @extends myfaces._impl.i18n.Messages 1722 * @memberOf myfaces._impl.i18n 1723 */ 1724_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_ru", myfaces._impl.i18n.Messages, 1725 /** myfaces._impl.i18n.Messages_ru.prototype */ 1726 { 1727 1728 MSG_TEST: "ТеÑÑовоеСообÑение", 1729 1730 /*Messages*/ 1731 MSG_DEV_MODE: "ÐÑо ÑообÑение вÑдано, поÑÐ¾Ð¼Ñ ÑÑо 'project stage' бÑло пÑиÑоено знаÑение 'development', и Ð½Ð¸ÐºÐ°ÐºÐ¸Ñ " + 1732 "дÑÑÐ³Ð¸Ñ error listeners заÑегиÑÑÑиÑовано не бÑло.", 1733 MSG_AFFECTED_CLASS: "ÐадейÑÑвованнÑй клаÑÑ:", 1734 MSG_AFFECTED_METHOD: "ÐадейÑÑвованнÑй меÑод:", 1735 1736 MSG_ERROR_NAME: "ÐÐ¼Ñ Ð¾Ñибки:", 1737 MSG_ERROR_MESSAGE: "ÐÐ¼Ñ Ð¾Ñибки:", 1738 1739 MSG_ERROR_DESC: "ÐпиÑание оÑибки:", 1740 MSG_ERROR_NO: "ÐÐ¾Ð¼ÐµÑ Ð¾Ñибки:", 1741 MSG_ERROR_LINENO: "ÐÐ¾Ð¼ÐµÑ ÑÑÑоки оÑибки:", 1742 1743 /*Errors and messages*/ 1744 ERR_FORM: "Sourceform не найдена, поÑÐ¾Ð¼Ñ ÑÑо ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð½Ðµ Ð½Ð°Ñ Ð¾Ð´Ð¸ÑÑÑ Ð²Ð½ÑÑÑи <form>, либо бÑли Ð½Ð°Ð¹Ð´ÐµÐ½Ñ ÑлеменÑÑ <form> Ñ ÑдинаковÑм именем или иденÑиÑикаÑоÑом. ÐбÑабоÑка ajax оÑÑановлена", 1745 ERR_VIEWSTATE: "jsf.viewState: ÐаÑамеÑÑÑ Ð¿ÑиÑвоено знаÑение, не ÑвÐ
1745»ÑÑÑееÑÑ ÑлеменÑом <form>!", 1746 ERR_TRANSPORT: "ÐеÑÑÑеÑÑвÑÑÑий Ñип ÑÑанÑпоÑÑа {0}", 1747 ERR_EVT_PASS: "ÐаÑамеÑÑ event Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼, и не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ null или undefined", 1748 ERR_CONSTRUCT: "ЧаÑÑÑ Ð¾ÑвеÑа не ÑдалоÑÑ Ð¿ÑоÑиÑаÑÑ Ð¿Ñи Ñоздании даннÑÑ ÑобÑÑиÑ: {0} ", 1749 ERR_MALFORMEDXML: "ÐÑÐ²ÐµÑ ÑеÑвеÑа не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð¾Ð±ÑабоÑан, он не в ÑоÑмаÑе xml !", 1750 ERR_SOURCE_FUNC: "source не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÑÑнкÑией (возможно, Ð´Ð»Ñ source и event не бÑли Ð´Ð°Ð½Ñ Ð·Ð½Ð°ÑениÑ", 1751 ERR_EV_OR_UNKNOWN: "ÐбÑÐµÐºÑ event или unknown должен бÑÑÑ Ð²ÑÑоÑÑм паÑамеÑÑом", 1752 ERR_SOURCE_NOSTR: "source не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñипа string", 1753 ERR_SOURCE_DEF_NULL: "source должно бÑÑÑ Ð¿ÑиÑвоено знаÑение или null", 1754 1755 //_Lang.js 1756 ERR_MUST_STRING: "{0}: {1} namespace должно бÑÑÑ Ñипа String", 1757 ERR_REF_OR_ID: "{0}: {1} a СÑÑлоÑнÑй Ñзел (reference node) или иденÑиÑикаÑÐ¾Ñ Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñ", 1758 ERR_PARAM_GENERIC: "{0}: паÑамеÑÑ {1} должен бÑÑÑ Ñипа {2}", 1759 ERR_PARAM_STR: "{0}: {1} паÑамеÑÑ Ð´Ð¾Ð»Ð¶ÐµÐ½ бÑÑÑ Ñипа string", 1760 ERR_PARAM_STR_RE: "{0}: {1} паÑамеÑÑ Ð´Ð¾Ð»Ð¶ÐµÐ½ бÑÑÑ Ñипа string string или regular expression", 1761 ERR_PARAM_MIXMAPS: "{0}: source b destination map Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñ", 1762 ERR_MUST_BE_PROVIDED: "{0}: {1} и {2} Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñ", 1763 ERR_MUST_BE_PROVIDED1: "{0}: {1} должно бÑÑÑ Ð¿ÑиÑвоено знаÑение", 1764 1765 ERR_REPLACE_EL: "replaceElements вÑзвана, Ñ evalNodes, не ÑвлÑÑÑимÑÑ Ð¼Ð°ÑÑивом", 1766 ERR_EMPTY_RESPONSE: "{0}: ÐÑÐ²ÐµÑ Ð½Ðµ Ð¼Ð¾Ð¶ÐµÑ Ð±Ð²ÑÑ null или пÑÑÑÑм!", 1767 ERR_ITEM_ID_NOTFOUND: "{0}: ÐÐ»ÐµÐ¼ÐµÐ½Ñ Ñ Ð¸Ð´ÐµÐ½ÑиÑикаÑоÑом {1} не найден", 1768 ERR_PPR_IDREQ: "{0}: ÐÑибка в PPR Insert, id Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼", 1769 ERR_PPR_INSERTBEFID: "{0}: ÐÑибка в PPR Insert, before id или after id Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñ", 1770 ERR_PPR_INSERTBEFID_1: "{0}: ÐÑибка в PPR Insert, before node c id {1} не найден в докÑменÑе", 1771 ERR_PPR_INSERTBEFID_2: "{0}: ÐÑибка в PPR Insert, after node Ñ id {1} не найден в докÑменÑе", 1772 1773 ERR_PPR_DELID: "{0}: ÐÑибка в Ñдалении, id не найден в xml докÑменÑе", 1774 ERR_PPR_UNKNOWNCID: "{0}: ÐеопознаннÑй Html-Component-ID: {1}", 1775 ERR_NO_VIEWROOTATTR: "{0}: Ðзменение аÑÑибÑÑов ViewRoot не пÑедÑÑмоÑÑено", 1776 ERR_NO_HEADATTR: "{0}: Ðзменение аÑÑибÑÑов Head не пÑедÑÑмоÑÑено", 1777 ERR_RED_URL: "{0}: ÐеÑенапÑавление (Redirect) без url" 1778 1779 }); 1780} 1781/* Licensed to the Apache Software Foundation (ASF) under one or more 1782 * contributor license agreements. See the NOTICE file distributed with 1783 * this work for additional information regarding copyright ownership. 1784 * The ASF licenses this file to you under the Apache License, Version 2.0 1785 * (the "License"); you may not use this file except in compliance with 1786 * the License. You may obtain a copy of the License at 1787 * 1788 * http://www.apache.org/licenses/LICENSE-2.0 1789 * 1790 * Unless required by applicable law or agreed to in writing, software 1791 * distributed under the License is distributed on an "AS IS" BASIS, 1792 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1793 * See the License for the specific language governing permissions and 1794 * limitations under the License. 1795 */ 1796if (_MF_CLS) { 1797 /** 1798 * System messages Simplified Chinese version 1799 * 1800 * @class 1801 * @name Messages_zh_CN 1802 * @extends myfaces._impl.i18n.Messages 1803 * @memberOf myfaces._impl.i18n 1804 */ 1805_MF_CLS && _MF_CLS(_PFX_I18N+"Messages_zh_CN", myfaces._impl.i18n.Messages, 1806 /** @lends myfaces._impl.i18n.Messages_zh_CN.prototype */ 1807 { 1808 1809 MSG_TEST: "æµè¯ä¿¡æ¯", 1810 1811 /*Messages*/ 1812 /** @constant */ 1813 MSG_DEV_MODE: "请注æï¼æ¤ä¿¡æ¯åªå¨é¡¹ç®åå±é¶æ®µï¼åæ²¡ææ³¨åé误çå¬å¨èåæ¾ã", 1814 /** @constant */ 1815 MSG_AFFECTED_CLASS: "åå½±åç±»å«ï¼", 1816 /** @constant */ 1817 MSG_AFFECTED_METHOD: "å影忹æ³ï¼", 1818 /** @constant */ 1819 MSG_ERROR_NAME: "é误åç§°ï¼", 1820 /** @constant */ 1821 MSG_ERROR_MESSAGE: "é误信æ¯ï¼", 1822 /** @constant */ 1823 MSG_SERVER_ERROR_NAME: "伺æå¨é误åç§°ï¼", 1824 /** @constant */ 1825 MSG_ERROR_DESC: "é误说æï¼", 1826 /** @constant */ 1827 MSG_ERROR_NO: "é误å·ç ï¼", 1828 /** @constant */ 1829 MSG_ERROR_LINENO: "é误è¡å·ï¼", 1830 1831 /*Errors and messages*/ 1832 /** @constant */ 1833 ERR_FORM: "ä¸è½å¤å®æºè¡¨åï¼è¦ä¹æ²¡æè¿æ¥å ä»¶å°è¡¨åï¼è¦ä¹æå¤ä¸ªç¸åæ è¯ç¬¦æåç§°ç表åï¼AJAXå¤ç忢è¿ä½", 1834 /** @constant */ 1835 ERR_VIEWSTATE: "jsf.viewStateï¼åæ°å¼ä¸æ¯è¡¨åç±»åï¼", 1836 /** @constant */ 1837 ERR_TRANSPORT: "ä¸åå¨{0}ä¼ è¾ç±»å", 1838 /** @constant */ 1839 ERR_EVT_PASS: "å¿ é¡»æ¾å¼äºä»¶ï¼å¯è½äºä»¶ç©ä»¶ä¸ºç©ºææªå®ä¹ï¼", 1840 /** @constant */ 1841 ERR_CONSTRUCT: "æå»ºäºä»¶æ°æ®æ¶é¨åååºä¸è½åå¾ï¼åå æ¯ï¼{0}", 1842 /** @constant */ 1843 ERR_MALFORMEDXML: "æ æ³è§£æä¼ºæå¨çååºï¼ä¼ºæå¨è¿åçååºä¸æ¯XMLï¼", 1844 /** @constant */ 1845 ERR_SOURCE_FUNC: "æ¥æºä¸è½æ¯ä¸ä¸ªå½æ°ï¼å¯è½æ¥æºåäºä»¶æ²¡æå®ä¹æè®¾å®ä¸ºç©ºï¼", 1846 /** @constant */ 1847 ERR_EV_OR_UNKNOWN: "äºä»¶ç©ä»¶æä¸æå¿ é¡»ä½ä¸ºç¬¬äºä¸ªåæ°ä¼ é", 1848 /** @constant */ 1849 ERR_SOURCE_NOSTR: "æ¥æºä¸è½æ¯å串", 1850 /** @constant */ 1851 ERR_SOURCE_DEF_NULL: "æ¥æºå¿ é¡»å®ä¹æä¸ºç©º", 1852 1853 //_Lang.js 1854 /** @constant */ 1855 ERR_MUST_STRING: "{0}ï¼{1} å称空é´å¿ é¡»æ¯å串类å", 1856 /** @constant */ 1857 ERR_REF_OR_ID: "{0}ï¼{1} å¿ é¡»æä¾åèèç¹ææ è¯ç¬¦", 1858 /** @constant */ 1859 ERR_PARAM_GENERIC: "{0}ï¼{1} åæ°å¿ é¡»æ¯ {2} ç±»å", 1860 /** @constant */ 1861 ERR_PARAM_STR: "{0}ï¼{1} åæ°å¿ é¡»æ¯å串类å", 1862 /** @constant */ 1863 ERR_PARAM_STR_RE: "{0}ï¼{1} åæ°å¿ é¡»æ¯åä¸²ç±»åææ£è§è¡¨è¾¾å¼", 1864 /** @constant */ 1865 ERR_PARAM_MIXMAPS: "{0}ï¼å¿ é¡»æä¾æ¥æºåç®æ æ å°", 1866 /** @constant */ 1867 ERR_MUST_BE_PROVIDED: "{0}ï¼å¿ é¡»æä¾ {1} å {2}", 1868 /** @constant */ 1869 ERR_MUST_BE_PROVIDED1: "{0}ï¼å¿ é¡»è®¾å® {1}", 1870 1871 /** @constant */ 1872 ERR_REPLACE_EL: "è°ç¨replaceElements彿°æ¶evalNodesåé䏿¯éµåç±»å", 1873 1874 /** @constant */ 1875 ERR_EMPTY_RESPONSE: "{0}ï¼ååºä¸è½ä¸ºç©ºçï¼", 1876 /** @constant */ 1877 ERR_ITEM_ID_NOTFOUND: "{0}ï¼æ¾ä¸å°æ {1} æ è¯ç¬¦ç项ç®", 1878 /** @constant */ 1879 ERR_PPR_IDREQ: "{0}
1879ï¼å±é¨é¡µé¢æ¸²æåµå ¥éè¯¯ï¼æ è¯ç¬¦å¿ é¡»åå¨", 1880 /** @constant */ 1881 ERR_PPR_INSERTBEFID: "{0}ï¼å±é¨é¡µé¢æ¸²æåµå ¥é误ï¼åæåæ è¯ç¬¦å¿ é¡»åå¨", 1882 /** @constant */ 1883 ERR_PPR_INSERTBEFID_1: "{0}ï¼å±é¨é¡µé¢æ¸²æåµå ¥é误ï¼åèç¹çæ è¯ç¬¦ {1} ä¸å¨æä»¶å ", 1884 /** @constant */ 1885 ERR_PPR_INSERTBEFID_2: "{0}ï¼å±é¨é¡µé¢æ¸²æåµå ¥é误ï¼åèç¹çæ è¯ç¬¦ {1} ä¸å¨æä»¶å ", 1886 1887 /** @constant */ 1888 ERR_PPR_DELID: "{0}ï¼å é¤éè¯¯ï¼æ è¯ç¬¦ä¸å¨XMLæ è®°ä¸", 1889 /** @constant */ 1890 ERR_PPR_UNKNOWNCID: "{0}ï¼ä¸æçHTMLç»ä»¶æ è¯ç¬¦ï¼{1}", 1891 1892 /** @constant */ 1893 ERR_NO_VIEWROOTATTR: "{0}ï¼ä¸æ¯æ´æ¹åViewRoot屿§", 1894 /** @constant */ 1895 ERR_NO_HEADATTR: "{0}ï¼ä¸æ¯æ´æ¹åHeadç屿§", 1896 /** @constant */ 1897 ERR_RED_URL: "{0}ï¼æ²¡æé导åç½å", 1898 1899 /** @constant */ 1900 ERR_REQ_FAILED_UNKNOWN: "请æ±å¤±è´¥ï¼ç¶æä¸æ", 1901 1902 /** @constant */ 1903 ERR_REQU_FAILED: "请æ±å¤±è´¥ï¼ç¶ææ¯ {0} ååå æ¯ {1}", 1904 1905 /** @constant */ 1906 UNKNOWN: "䏿" 1907 }); 1908} 1909 1910/* Licensed to the Apache Software Foundation (ASF) under one or more 1911 * contributor license agreements. See the NOTICE file distributed with 1912 * this work for additional information regarding copyright ownership. 1913 * The ASF licenses this file to you under the Apache License, Version 2.0 1914 * (the "License"); you may not use this file except in compliance with 1915 * the License. You may obtain a copy of the License at 1916 * 1917 * http://www.apache.org/licenses/LICENSE-2.0 1918 * 1919 * Unless required by applicable law or agreed to in writing, software 1920 * distributed under the License is distributed on an "AS IS" BASIS, 1921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1922 * See the License for the specific language governing permissions and 1923 * limitations under the License. 1924 */ 1925 1926/**
1927 * System messages Traditional Chinese (Hong Kong) version 1928 * 1929 * @class 1930 * @name Messages_zh_HK 1931 * @extends myfaces._impl.i18n.Messages 1932 * @memberOf myfaces._impl.i18n 1933 */ 1934_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_zh_HK", myfaces._impl.i18n.Messages, 1935 /** @lends myfaces._impl.i18n.Messages_zh_HK.prototype */ 1936 { 1937 1938 MSG_TEST: "測試信æ¯", 1939 1940 /*Messages*/ 1941 /** @constant */ 1942 MSG_DEV_MODE: "è«æ³¨æï¼æ¤ä¿¡æ¯åªå¨é ç®ç¼å±é段ï¼åæ²æè¨»åé¯èª¤ç£è½å¨èç¼æ¾ã", 1943 /** @constant */ 1944 MSG_AFFECTED_CLASS: "åå½±é¿é¡å¥ï¼", 1945 /** @constant */ 1946 MSG_AFFECTED_METHOD: "åå½±é¿æ¹æ³ï¼", 1947 /** @constant */ 1948 MSG_ERROR_NAME: "é¯èª¤å稱ï¼", 1949 /** @constant */ 1950 MSG_ERROR_MESSAGE: "é¯èª¤ä¿¡æ¯ï¼", 1951 /** @constant */ 1952 MSG_SERVER_ERROR_NAME: "伺æå¨é¯èª¤å稱ï¼", 1953 /** @constant */ 1954 MSG_ERROR_DESC: "é¯èª¤èªªæï¼", 1955 /** @constant */ 1956 MSG_ERROR_NO: "é¯èª¤è碼ï¼", 1957 /** @constant */ 1958 MSG_ERROR_LINENO: "é¯èª¤è¡èï¼", 1959 1960 /*Errors and messages*/ 1961 /** @constant */ 1962 ERR_FORM: "ä¸è½å¤å®æºè¡¨å®ï¼è¦éº¼æ²æé£æ¥å ä»¶å°è¡¨å®ï¼è¦éº¼æå¤åç¸åæ¨è符æå稱ç表å®ï¼AJAXèç忢éä½", 1963 /** @constant */ 1964 ERR_VIEWSTATE: "jsf.viewStateï¼åæ¸å¼ä¸æ¯è¡¨å®é¡åï¼", 1965 /** @constant */ 1966 ERR_TRANSPORT: "ä¸åå¨{0}å³è¼¸é¡å", 1967 /** @constant */ 1968 ERR_EVT_PASS: "å¿ é æ¾æ£äºä»¶ï¼å¯è½äºä»¶ç©ä»¶çºç©ºææªå®ç¾©ï¼", 1969 /** @constant */ 1970 ERR_CONSTRUCT: "æ§å»ºäºä»¶æ¸ææé¨ååæä¸è½åå¾ï¼åå æ¯ï¼{0}", 1971 /** @constant */ 1972 ERR_MALFORMEDXML: "ç¡æ³è§£æä¼ºæå¨çåæï¼ä¼ºæå¨è¿åçåæä¸æ¯XMLï¼", 1973 /** @constant */ 1974 ERR_SOURCE_FUNC: "便ºä¸è½æ¯ä¸å彿¸ï¼å¯è½ä¾æºåäºä»¶æ²æå®ç¾©æè¨å®çºç©ºï¼", 1975 /** @constant */ 1976 ERR_EV_OR_UNKNOWN: "äºä»¶ç©ä»¶æä¸æå¿ é ä½çºç¬¬äºå忏å³é", 1977 /** @constant */ 1978 ERR_SOURCE_NOSTR: "便ºä¸è½æ¯å串", 1979 /** @constant */ 1980 ERR_SOURCE_DEF_NULL: "便ºå¿ é å®ç¾©æçºç©º", 1981 1982 //_Lang.js 1983 /** @constant */ 1984 ERR_MUST_STRING: "{0}ï¼{1} å稱空éå¿ é æ¯å串é¡å", 1985 /** @constant */ 1986 ERR_REF_OR_ID: "{0}ï¼{1} å¿ é æä¾åèç¯é»ææ¨è符", 1987 /** @constant */ 1988 ERR_PARAM_GENERIC: "{0}ï¼{1} åæ¸å¿ é æ¯ {2} é¡å", 1989 /** @constant */ 1990 ERR_PARAM_STR: "{0}ï¼{1} åæ¸å¿ é æ¯å串é¡å", 1991 /** @constant */ 1992 ERR_PARAM_STR_RE: "{0}ï¼{1} åæ¸å¿ é æ¯å串é¡åææ£è¦è¡¨éå¼", 1993 /** @constant */ 1994 ERR_PARAM_MIXMAPS: "{0}ï¼å¿ é æä¾ä¾æºåç®æ¨æ å°", 1995 /** @constant */ 1996 ERR_MUST_BE_PROVIDED: "{0}ï¼å¿ é æä¾ {1} å {2}", 1997 /** @constant */ 1998 ERR_MUST_BE_PROVIDED1: "{0}ï¼å¿ é è¨å® {1}", 1999 2000 /** @constant */ 2001 ERR_REPLACE_EL: "調ç¨replaceElements彿¸æevalNodesè®é䏿¯é£åé¡å", 2002 2003 /** @constant */ 2004 ERR_EMPTY_RESPONSE: "{0}ï¼åæä¸è½çºç©ºçï¼", 2005 /** @constant */ 2006 ERR_ITEM_ID_NOTFOUND: "{0}ï¼æ¾ä¸å°æ {1} æ¨è符çé ç®", 2007 /** @constant */ 2008 ERR_PPR_IDREQ: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼æ¨èç¬¦å¿ é åå¨", 2009 /** @constant */ 2010 ERR_PPR_INSERTBEFID: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼åæå¾æ¨èç¬¦å¿ é åå¨", 2011 /** @constant */ 2012 ERR_PPR_INSERTBEFID_1: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼åç¯é»çæ¨è符 {1} ä¸å¨æä»¶å §", 2013 /** @constant */ 2014 ERR_PPR_INSERTBEFID_2: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼å¾ç¯é»çæ¨è符 {1} ä¸å¨æä»¶å §", 2015 2016 /** @constant */ 2017 ERR_PPR_DELID: "{0}ï¼åªé¤é¯èª¤ï¼æ¨è符ä¸å¨XMLæ¨è¨ä¸", 2018 /** @constant */ 2019 ERR_PPR_UNKNOWNCID: "{0}ï¼ä¸æçHTMLçµä»¶æ¨è符ï¼{1}", 2020 2021 /** @constant */ 2022 ERR_NO_VIEWROOTATTR: "{0}ï¼ä¸æ¯æ´æ¹è®ViewRoot屬æ§", 2023 /** @constant */ 2024 ERR_NO_HEADATTR: "{0}ï¼ä¸æ¯æ´æ¹è®Headç屬æ§", 2025 /** @constant */ 2026 ERR_RED_URL: "{0}ï¼æ²æéå°åç¶²å", 2027 2028 /** @constant */ 2029 ERR_REQ_FAILED_UNKNOWN: "è«æ±å¤±æï¼çæ 䏿", 2030 2031 /** @constant */ 2032 ERR_REQU_FAILED: "è«æ±å¤±æï¼çæ æ¯ {0} ååå æ¯ {1}", 2033 2034 /** @constant */ 2035 UNKNOWN: "䏿" 2036 }); 2037 2038 2039/* Licensed to the Apache Software Foundation (ASF) under one or more 2040 * contributor license agreements. See the NOTICE file distributed with 2041 * this work for additional information regarding copyright ownership. 2042 * The ASF licenses this file to you under the Apache License, Version 2.0 2043 * (the "License");
2043 you may not use this file except in compliance with 2044 * the License. You may obtain a copy of the License at 2045 * 2046 * http://www.apache.org/licenses/LICENSE-2.0 2047 * 2048 * Unless required by applicable law or agreed to in writing, software 2049 * distributed under the License is distributed on an "AS IS" BASIS, 2050 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2051 * See the License for the specific language governing permissions and 2052 * limitations under the License. 2053 */ 2054if (_MF_CLS) { 2055 /** 2056 * System messages Traditional Chinese (Taiwan) version 2057 * 2058 * @class 2059 * @name Messages_zh_TW 2060 * @extends myfaces._impl.i18n.Messages 2061 * @memberOf myfaces._impl.i18n 2062 */ 2063_MF_CLS && _MF_CLS(_PFX_I18N + "Messages_zh_TW", myfaces._impl.i18n.Messages, 2064 /** @lends myfaces._impl.i18n.Messages_zh_TW.prototype */ 2065 { 2066 2067 MSG_TEST: "測試信æ¯", 2068 2069 /*Messages*/ 2070 /** @constant */ 2071 MSG_DEV_MODE: "è«æ³¨æï¼æ¤ä¿¡æ¯åªå¨é ç®ç¼å±é段ï¼åæ²æè¨»åé¯èª¤ç£è½å¨èç¼æ¾ã", 2072 /** @constant */ 2073 MSG_AFFECTED_CLASS: "åå½±é¿é¡å¥ï¼", 2074 /** @constant */ 2075 MSG_AFFECTED_METHOD: "åå½±é¿æ¹æ³ï¼", 2076 /** @constant */ 2077 MSG_ERROR_NAME: "é¯èª¤å稱ï¼", 2078 /** @constant */ 2079 MSG_ERROR_MESSAGE: "é¯èª¤ä¿¡æ¯ï¼", 2080 /** @constant */ 2081 MSG_SERVER_ERROR_NAME: "伺æå¨é¯èª¤å稱ï¼", 2082 /** @constant */ 2083 MSG_ERROR_DESC: "é¯èª¤èªªæï¼", 2084 /** @constant */ 2085 MSG_ERROR_NO: "é¯èª¤è碼ï¼", 2086 /** @constant */ 2087 MSG_ERROR_LINENO: "é¯èª¤è¡èï¼", 2088 2089 /*Errors and messages*/ 2090 /** @constant */ 2091 ERR_FORM: "ä¸è½å¤å®æºè¡¨å®ï¼è¦éº¼æ²æé£æ¥å ä»¶å°è¡¨å®ï¼è¦éº¼æå¤åç¸åæ¨è符æå稱ç表å®ï¼AJAXèç忢éä½", 2092 /** @constant */ 2093 ERR_VIEWSTATE: "jsf.viewStateï¼åæ¸å¼ä¸æ¯è¡¨å®é¡åï¼", 2094 /** @constant */ 2095 ERR_TRANSPORT: "ä¸åå¨{0}å³è¼¸é¡å", 2096 /** @constant */ 2097 ERR_EVT_PASS: "å¿ é æ¾æ£äºä»¶ï¼å¯è½äºä»¶ç©ä»¶çºç©ºææªå®ç¾©ï¼", 2098 /** @constant */ 2099 ERR_CONSTRUCT: "æ§å»ºäºä»¶æ¸ææé¨ååæä¸è½åå¾ï¼åå æ¯ï¼{0}", 2100 /** @constant */ 2101 ERR_MALFORMEDXML: "ç¡æ³è§£æä¼ºæå¨çåæï¼ä¼ºæå¨è¿åçåæä¸æ¯XMLï¼", 2102 /** @constant */ 2103 ERR_SOURCE_FUNC: "便ºä¸è½æ¯ä¸å彿¸ï¼å¯è½ä¾æºåäºä»¶æ²æå®ç¾©æè¨å®çºç©ºï¼", 2104 /** @constant */ 2105 ERR_EV_OR_UNKNOWN: "äºä»¶ç©ä»¶æä¸æå¿ é ä½çºç¬¬äºå忏å³é", 2106 /** @constant */ 2107 ERR_SOURCE_NOSTR: "便ºä¸è½æ¯å串", 2108 /** @constant */ 2109 ERR_SOURCE_DEF_NULL: "便ºå¿ é å®ç¾©æçºç©º", 2110 2111 //_Lang.js 2112 /** @constant */ 2113 ERR_MUST_STRING: "{0}ï¼{1} å稱空éå¿ é æ¯å串é¡å", 2114 /** @constant */ 2115 ERR_REF_OR_ID: "{0}ï¼{1} å¿ é æä¾åèç¯é»ææ¨è符", 2116 /** @constant */ 2117 ERR_PARAM_GENERIC: "{0}ï¼{1} åæ¸å¿ é æ¯ {2} é¡å", 2118 /** @constant */ 2119 ERR_PARAM_STR: "{0}ï¼{1} åæ¸å¿ é æ¯å串é¡å", 2120 /** @constant */ 2121 ERR_PARAM_STR_RE: "{0}ï¼{1} åæ¸å¿ é æ¯å串é¡åææ£è¦è¡¨éå¼", 2122 /** @constant */ 2123 ERR_PARAM_MIXMAPS: "{0}ï¼å¿ é æä¾ä¾æºåç®æ¨æ å°", 2124 /** @constant */ 2125 ERR_MUST_BE_PROVIDED: "{0}ï¼å¿ é æä¾ {1} å {2}", 2126 /** @constant */ 2127 ERR_MUST_BE_PROVIDED1: "{0}ï¼å¿ é è¨å® {1}", 2128 2129 /** @constant */ 2130 ERR_REPLACE_EL: "調ç¨replaceElements彿¸æevalNodesè®é䏿¯é£åé¡å", 2131 2132 /** @constant */ 2133 ERR_EMPTY_RESPONSE: "{0}ï¼åæä¸è½çºç©ºçï¼", 2134 /** @constant */ 2135 ERR_ITEM_ID_NOTFOUND: "{0}ï¼æ¾ä¸å°æ {1} æ¨è符çé ç®", 2136 /** @constant */ 2137 ERR_PPR_IDREQ: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼æ¨èç¬¦å¿ é åå¨", 2138 /** @constant */ 2139 ERR_PPR_INSERTBEFID: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼åæå¾æ¨èç¬¦å¿ é åå¨", 2140 /** @constant */ 2141 ERR_PPR_INSERTBEFID_1: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼åç¯é»çæ¨è符 {1} ä¸å¨æä»¶å §", 2142 /** @constant */ 2143 ERR_PPR_INSERTBEFID_2: "{0}ï¼å±é¨é 颿¸²æåµå ¥é¯èª¤ï¼å¾ç¯é»çæ¨è符 {1} ä¸å¨æä»¶å §", 2144 2145 /** @constant */ 2146 ERR_PPR_DELID: "{0}ï¼åªé¤é¯èª¤ï¼æ¨è符ä¸å¨XMLæ¨è¨ä¸", 2147 /** @constant */ 2148 ERR_PPR_UNKNOWNCID: "{0}ï¼ä¸æçHTMLçµä»¶æ¨è符ï¼{1}", 2149 2150 /** @constant */ 2151 ERR_NO_VIEWROOTATTR: "{0}ï¼ä¸æ¯æ´æ¹è®ViewRoot屬æ§", 2152 /** @constant */ 2153 ERR_NO_HEADATTR: "{0}ï¼ä¸æ¯æ´æ¹è®Headç屬æ§", 2154 /** @constant */ 2155 ERR_RED_URL: "{0}ï¼æ²æéå°åç¶²å", 2156 2157 /** @constant */ 2158 ERR_REQ_FAILED_UNKNOWN: "è«æ±å¤±æï¼çæ 䏿", 2159 2160 /** @constant */ 2161 ERR_REQU_FAILED: "è«æ±å¤±æï¼çæ æ¯ {0} ååå æ¯ {1}", 2162 2163 /** @constant */ 2164 UNKNOWN: "䏿" 2165 }); 2166} 2167 2168/* Licensed to the Apache Software Foundation (ASF) under one or more 2169 * contributor license agreements. See the NOTICE file distributed with 2170 * this work for additional information regarding copyright ownership. 2171 * The ASF licenses this file to you under the Apache License, Version 2.0 2172 * (the "License");
2172 you may not use this file except in compliance with 2173 * the License. You may obtain a copy of the License at 2174 * 2175 * http://www.apache.org/licenses/LICENSE-2.0 2176 * 2177 * Unless required by applicable law or agreed to in writing, software 2178 * distributed under the License is distributed on an "AS IS" BASIS, 2179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2180 * See the License for the specific language governing permissions and 2181 * limitations under the License. 2182 */ 2183/* 2184 theoretically we could save some code 2185 by 2186 defining the parent object as 2187 var parent = new Object(); 2188 parent.prototype = new myfaces._impl.core._Runtime(); 2189 extendClass(function () { 2190 }, parent , { 2191 But for now we are not doing it the little bit of saved 2192 space is not worth the loss of readability 2193 */ 2194/** 2195 * @memberOf myfaces._impl 2196 * @namespace 2197 * @name _util 2198 */ 2199/** 2200 * @class 2201 * @name _Lang 2202 * @memberOf myfaces._impl._util 2203 * @extends myfaces._impl.core._Runtime 2204 * @namespace 2205 * @description Object singleton for Language related methods, this object singleton 2206 * decorates the namespace myfaces._impl.core._Runtime and adds a bunch of new methods to 2207 * what _Runtime provided 2208 * */ 2209_MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.prototype */ { 2210 _processedExceptions:{}, 2211 _installedLocale:null, 2212 _RT:myfaces._impl.core._Runtime, 2213 /** 2214 * returns a given localized message upon a given key 2215 * basic java log like templating functionality is included 2216 * 2217 * @param {String} key the key for the message 2218 * @param {String} defaultMessage optional default message if none was found 2219 * 2220 * Additionally you can pass additional arguments, which are used 2221 * in the same way java log templates use the params 2222 * 2223 * @param key 2224 */ 2225 getMessage:function (key, defaultMessage /*,vararg templateParams*/) { 2226 if (!this._installedLocale) { 2227 //we first try to install language and variant, if that one fails 2228 //we try to install the language only, and if that one fails 2229 //we install the base messages 2230 this.initLocale(); 2231 } 2232 var msg = this._installedLocale[key] || defaultMessage || key + " - undefined message"; 2233 //we now make a simple templating replace of {0}, {1} etc... with their corresponding 2234 //arguments 2235 for (var cnt = 2; cnt < arguments.length; cnt++) { 2236 msg = msg.replace(new RegExp(["\\{", cnt - 2, "\\}"].join(""), "g"), new String(arguments[cnt])); 2237 } 2238 return msg; 2239 }, 2240 /** 2241 * (re)inits the currently installed 2242 * messages so that after loading the main scripts 2243 * a new locale can be installed optionally 2244 * to our i18n subsystem 2245 * 2246 * @param newLocale locale override 2247 */ 2248 initLocale:function (newLocale) { 2249 if (newLocale) { 2250 this._installedLocale = new newLocale(); 2251 return; 2252 } 2253 var language_Variant = this._RT.getLanguage(this._RT.getGlobalConfig("locale")), 2254 langStr = language_Variant ? language_Variant.language : "", 2255 variantStr = language_Variant ? [language_Variant.language, "_", language_Variant.variant || ""].join("") : "", 2256 i18nRoot = myfaces._impl.i18n, i18nHolder = i18nRoot["Messages_" + variantStr] || i18nRoot["Messages_" + langStr] || i18nRoot["Messages"]; 2257 this._installedLocale = new i18nHolder(); 2258 }, 2259 assertType:function (probe, theType) { 2260 return this._RT.assertType(probe, theType); 2261 }, 2262 exists:function (nms, theType) { 2263 return this._RT.exists(nms, theType); 2264 }, 2265 fetchNamespace:function (namespace) { 2266 this._assertStr(namespace, "fetchNamespace", "namespace"); 2267 return this._RT.fetchNamespace(namespace); 2268 }, 2269 reserveNamespace:function (namespace) { 2270 this._assertStr(namespace, "reserveNamespace", "namespace"); 2271 return this._RT.reserveNamespace(namespace); 2272 }, 2273 globalEval:function (code) { 2274 this._assertStr(code, "globalEval", "code"); 2275 return this._RT.globalEval(code); 2276 }, 2277 /** 2278 * determines the correct event depending 2279 * on the browsers state 2280 * 2281 * @param evt incoming event object (note not all browsers 2282 * have this) 2283 * 2284 * @return an event object no matter what is incoming 2285 */ 2286 getEvent:function (evt) { 2287 evt = (!evt) ? window.event || {} : evt; 2288 return evt; 2289 }, 2290 /** 2291 * cross port from the dojo lib
2292 * browser save event resolution 2293 * @param evt the event object 2294 * (with a fallback for ie events if none is present) 2295 */ 2296 getEventTarget:function (evt) { 2297 //ie6 and 7 fallback 2298 evt = this.getEvent(evt); 2299 /** 2300 * evt source is defined in the jsf events 2301 * seems like some component authors use our code 2302 * so we add it here see also 2303 * https://issues.apache.org/jira/browse/MYFACES-2458 2304 * not entirely a bug but makes sense to add this 2305 * behavior. I dont use it that way but nevertheless it 2306 * does not break anything so why not 2307 * */ 2308 var t = evt.srcElement || evt.target || evt.source || null; 2309 while ((t) && (t.nodeType != 1)) { 2310 t = t.parentNode; 2311 } 2312 return t; 2313 }, 2314 2315 /** 2316 * equalsIgnoreCase, case insensitive comparison of two strings 2317 * 2318 * @param source 2319 * @param destination 2320 */ 2321 equalsIgnoreCase:function (source, destination) { 2322 //either both are not set or null 2323 if (!source && !destination) { 2324 return true; 2325 } 2326 //source or dest is set while the other is not 2327 if (!source || !destination) return false; 2328 //in any other case we do a strong string comparison 2329 return source.toLowerCase() === destination.toLowerCase(); 2330 }, 2331 2332 /** 2333 * Save document.getElementById (this code was ported over from dojo) 2334 * the idea is that either a string or domNode can be passed 2335 * @param {Object} reference the reference which has to be byIded 2336 */ 2337 byId:function (/*object*/ reference) { 2338 if (!reference) { 2339 throw this.makeException(new Error(), null, null, this._nameSpace, "byId", this.getMessage("ERR_REF_OR_ID", null, "_Lang.byId", "reference")); 2340 } 2341 return (this.isString(reference)) ? document.getElementById(reference) : reference; 2342 }, 2343 2344 /** 2345 * String to array function performs a string to array transformation 2346 * @param {String} it the string which has to be changed into an array 2347 * @param {RegExp} splitter our splitter reglar expression 2348 * @return an array of the splitted string 2349 */ 2350 strToArray:function (/*string*/ it, /*regexp*/ splitter) { 2351 // summary: 2352 // Return true if it is a String 2353 this._assertStr(it, "strToArray", "it"); 2354 if (!splitter) { 2355 throw this.makeException(new Error(), null, null, this._nameSpace, "strToArray", this.getMessage("ERR_PARAM_STR_RE", null, "myfaces._impl._util._Lang.strToArray", "splitter")); 2356 } 2357 var retArr = it.split(splitter); 2358 var len = retArr.length; 2359 for (var cnt = 0; cnt < len; cnt++) { 2360 retArr[cnt] = this.trim(retArr[cnt]); 2361 } 2362 return retArr; 2363 }, 2364 _assertStr:function (it, functionName, paramName) { 2365 if (!this.isString(it)) { 2366 throw this.makeException(new Error(), null, null, this._nameSpace, arguments.caller.toString(), this.getMessage("ERR_PARAM_STR", null, "myfaces._impl._util._Lang." + functionName, paramName)); 2367 } 2368 }, 2369 /** 2370 * hyperfast trim 2371 * http://blog.stevenlevithan.com/archives/faster-trim-javascript 2372 * crossported from dojo 2373 */ 2374 trim:function (/*string*/ str) { 2375 this._assertStr(str, "trim", "str"); 2376 str = str.replace(/^\s\s*/, ''); 2377 var ws = /\s/, i = str.length; 2378 2379 while (ws.test(str.charAt(--i))) { 2380 //do nothing 2381 } 2382 return str.slice(0, i + 1); 2383 }, 2384 /** 2385 * Backported from dojo 2386 * a failsafe string determination method 2387 * (since in javascript String != "" typeof alone fails!) 2388 * @param it {|Object|} the object to be checked for being a string 2389 * @return true in case of being a string false otherwise 2390 */ 2391 isString:function (/*anything*/ it) { 2392 // summary: 2393 // Return true if it is a String 2394 return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean 2395 }, 2396 /** 2397 * hitch backported from dojo 2398 * hitch allows to assign a function to a dedicated scope 2399 * this is helpful in situations when function reassignments 2400 * can happen 2401 * (notably happens often in lazy xhr code) 2402 * 2403 * @param {Function} scope of the function to be executed in 2404 * @param {Function} method to be executed, the method must be of type function 2405 * 2406 * @return whatever the executed method returns 2407 */ 2408 hitch:function (scope, method) { 2409 return !scope ? method : function () { 2410 return method.apply(scope, arguments || []); 2411 }; // Function 2412 }, 2413 /** 2414 * Helper function to merge two maps 2415 * into one 2416 * @param {Object} dest the destination map 2417 * @param {Object} src the source map 2418 * @param {boolean} overwrite if set to true the destination is overwritten if the keys exist in both maps 2419 **/ 2420 mixMaps:function (dest, src, overwrite, blockFilter, whitelistFilter) { 2421 if (!dest || !src) { 2422 throw this.makeException(new Error(), null, null, this._nameSpace, "mixMaps", this.getMessage("ERR_PARAM_MIXMAPS", null, "_Lang.mixMaps")); 2423 } 2424 var _undef = "undefined"; 2425 for (var key in src) { 2426 if (!src.hasOwnProperty(key)) continue; 2427 if (blockFilter && blockFilter[key]) { 2428 continue; 2429 } 2430 if (whitelistFilter && !whitelistFilter[key]) { 2431 continue; 2432 } 2433 if (!overwrite) { 2434 /** 2435 *we use exists instead of booleans because we cannot rely 2436 *on all values being non boolean, we would need an elvis 2437 *operator in javascript to shorten this :-( 2438 */ 2439 dest[key] = (_undef != typeof dest[key]) ? dest[key] : src[key]; 2440 } else { 2441 dest[key] = (_undef != typeof src[key]) ? src[key] : dest[key]; 2442 } 2443 } 2444 return dest; 2445 }, 2446 /** 2447 * checks if an array contains an element 2448 * @param {Array} arr array 2449 * @param {String} str string to check for 2450 */ 2451 contains:function (arr, str) { 2452 if (!arr || !str) { 2453 throw this.makeException(new Error(), null, null, this._nameSpace, "contains", this.getMessage("ERR_MUST_BE_PROVIDED", null, "_Lang.contains", "arr {array}", "str {string}")); 2454 } 2455 return this.arrIndexOf(arr, str) != -1; 2456 }, 2457 arrToMap:function (arr, offset) { 2458 var ret = new Array(arr.length); 2459 var len = arr.length; 2460 offset = (offset) ? offset : 0; 2461 for (var cnt = 0; cnt < len; cnt++) { 2462 ret[arr[cnt]] = cnt + offset; 2463 } 2464 return ret; 2465 }, 2466 objToArray:function (obj, offset, pack) { 2467 if (!obj) { 2468 return null; 2469 } 2470 //since offset is numeric we cannot use the shortcut due to 0 being false 2471 //special condition array delivered no offset no pack 2472 if (obj instanceof Array && !offset && !pack) return obj; 2473 var finalOffset = ('undefined' != typeof offset || null != offset) ? offset : 0; 2474 var finalPack = pack || []; 2475 try { 2476 return finalPack.concat(Array.prototype.slice.call(obj, finalOffset)); 2477 } catch (e) { 2478 //ie8 (again as only browser) delivers for css 3 selectors a non convert
2478ible object 2479 //we have to do it the hard way 2480 //ie8 seems generally a little bit strange in its behavior some 2481 //objects break the function is everything methodology of javascript 2482 //and do not implement apply call, or are pseudo arrays which cannot 2483 //be sliced 2484 for (var cnt = finalOffset; cnt < obj.length; cnt++) { 2485 finalPack.push(obj[cnt]); 2486 } 2487 return finalPack; 2488 } 2489 }, 2490 /** 2491 * foreach implementation utilizing the 2492 * ECMAScript wherever possible 2493 * with added functionality 2494 * 2495 * @param arr the array to filter 2496 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2497 * function (element<,key, array>) 2498 * <p /> 2499 * optional params 2500 * <p /> 2501 * <ul> 2502 * <li>param startPos (optional) the starting position </li> 2503 * <li>param scope (optional) the scope to apply the closure to </li> 2504 * </ul> 2505 */ 2506 arrForEach:function (arr, func /*startPos, scope*/) { 2507 if (!arr || !arr.length) return; 2508 var startPos = Number(arguments[2]) || 0; 2509 var thisObj = arguments[3]; 2510 //check for an existing foreach mapping on array prototypes 2511 //IE9 still does not pass array objects as result for dom ops 2512 arr = this.objToArray(arr); 2513 (startPos) ? arr.slice(startPos).forEach(func, thisObj) : arr.forEach(func, thisObj); 2514 }, 2515 /** 2516 * foreach implementation utilizing the 2517 * ECMAScript wherever possible 2518 * with added functionality 2519 * 2520 * @param arr the array to filter 2521 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2522 * function (element<,key, array>) 2523 * <p /> 2524 * additional params 2525 * <ul> 2526 * <li> startPos (optional) the starting position</li> 2527 * <li> scope (optional) the scope to apply the closure to</li> 2528 * </ul> 2529 */ 2530 arrFilter:function (arr, func /*startPos, scope*/) { 2531 if (!arr || !arr.length) return []; 2532 arr = this.objToArray(arr); 2533 return ((startPos) ? arr.slice(startPos).filter(func, thisObj) : arr.filter(func, thisObj)); 2534 }, 2535 /** 2536 * adds a EcmaScript optimized indexOf to our mix, 2537 * checks for the presence of an indexOf functionality 2538 * and applies it, otherwise uses a fallback to the hold 2539 * loop method to determine the index 2540 * 2541 * @param arr the array 2542 * @param element the index to search for 2543 */ 2544 arrIndexOf:function (arr, element /*fromIndex*/) { 2545 if (!arr || !arr.length) return -1; 2546 var pos = Number(arguments[2]) || 0; 2547 arr = this.objToArray(arr); 2548 return arr.indexOf(element, pos); 2549 }, 2550 /** 2551 * helper to automatically apply a delivered arguments map or array 2552 * to its destination which has a field "_"<key> and a full field 2553 * 2554 * @param dest the destination object 2555 * @param args the arguments array or map 2556 * @param argNames the argument names to be transferred 2557 */ 2558 applyArgs:function (dest, args, argNames) { 2559 var UDEF = 'undefined'; 2560 if (argNames) { 2561 for (var cnt = 0; cnt < args.length; cnt++) { 2562 //dest can be null or 0 hence no shortcut 2563 if (UDEF != typeof dest["_" + argNames[cnt]]) { 2564 dest["_" + argNames[cnt]] = args[cnt]; 2565 } 2566 if (UDEF != typeof dest[ argNames[cnt]]) { 2567 dest[argNames[cnt]] = args[cnt]; 2568 } 2569 } 2570 } else { 2571 for (var key in args) { 2572 if (!args.hasOwnProperty(key)) continue; 2573 if (UDEF != typeof dest["_" + key]) { 2574 dest["_" + key] = args[key]; 2575 } 2576 if (UDEF != typeof dest[key]) { 2577 dest[key] = args[key]; 2578 } 2579 } 2580 } 2581 }, 2582 2583 /** 2584 * transforms a key value pair into a string 2585 * @param key the key 2586 * @param val the value 2587 * @param delimiter the delimiter 2588 */ 2589 keyValToStr:function (key, val, delimiter) { 2590 var ret = [], pushRet = this.hitch(ret, ret.push); 2591 pushRet(key); 2592 pushRet(val); 2593 delimiter = delimiter || "\n"; 2594 pushRet(delimiter); 2595 return ret.join(""); 2596 }, 2597 parseXML:function (txt) { 2598 try { 2599 var parser = new DOMParser(); 2600 return parser.parseFromString(txt, "text/xml"); 2601 } catch (e) { 2602 //undefined internal parser error 2603 return null; 2604 } 2605 }, 2606 serializeXML:function (xmlNode, escape) { 2607 if (!escape) { 2608 if (xmlNode.data) return xmlNode.data; //CDATA block has raw data 2609 if (xmlNode.textContent) return xmlNode.textContent; //textNode has textContent 2610 } 2611 return (new XMLSerializer()).serializeToString(xmlNode); 2612 }, 2613 serializeChilds:function (xmlNode) { 2614 var buffer = []; 2615 if (!xmlNode.childNodes) return ""; 2616 for (var cnt = 0; cnt < xmlNode.childNodes.length; cnt++) { 2617 buffer.push(this.serializeXML(xmlNode.childNodes[cnt])); 2618 } 2619 return buffer.join(""); 2620 }, 2621 isXMLParseError:function (xmlContent) {
2622 //no xml content 2623 if (xmlContent == null) return true; 2624 var findParseError = function (node) { 2625 if (!node || !node.childNodes) return false; 2626 for (var cnt = 0; cnt < node.childNodes.length; cnt++) { 2627 var childNode = node.childNodes[cnt]; 2628 if (childNode.tagName && childNode.tagName == "parsererror") return true; 2629 } 2630 return false; 2631 }; 2632 return !xmlContent || 2633 (this.exists(xmlContent, "parseError.errorCode") && xmlContent.parseError.errorCode != 0) || 2634 findParseError(xmlContent); 2635 }, 2636 /** 2637 * fetches the error message from the xml content 2638 * in a browser independent way 2639 * 2640 * @param xmlContent 2641 * @return a map with the following structure {errorMessage: the error Message, sourceText: the text with the error} 2642 */ 2643 fetchXMLErrorMessage:function (text, xmlContent) { 2644 var _t = this; 2645 var findParseError = function (node) { 2646 if (!node || !node.childNodes) return false; 2647 for (var cnt = 0; cnt < node.childNodes.length; cnt++) { 2648 var childNode = node.childNodes[cnt]; 2649 if (childNode.tagName && childNode.tagName == "parsererror") { 2650 var errorMessage = _t.serializeXML(childNode.childNodes[0]); 2651 //we now have to determine the row and column position 2652 var lastLine = errorMessage.split("\n"); 2653 lastLine = lastLine[lastLine.length-1]; 2654 var positions = lastLine.match(/[^0-9]*([0-9]+)[^0-9]*([0-9]+)[^0-9]*/); 2655 2656 var ret = { 2657 errorMessage: errorMessage, 2658 sourceText: _t.serializeXML(childNode.childNodes[1].childNodes[0]) 2659 } 2660 if(positions) { 2661 ret.line = Math.max(0, parseInt(positions[1])-1); 2662 ret.linePos = Math.max(0, parseInt(positions[2])-1); 2663 } 2664 return ret; 2665 } 2666 } 2667 return null; 2668 }; 2669 var ret = null; 2670 if (!xmlContent) { 2671 //chrome does not deliver any further data 2672 ret = (this.trim(text || "").length > 0)? {errorMessage:"Illegal response",sourceText:""} : {errorMessage:"Empty Response",sourceText:""}; 2673 } else if (this.exists(xmlContent, "parseError.errorCode") && xmlContent.parseError.errorCode != 0) { 2674 ret = { 2675 errorMessage:xmlContent.parseError.reason, 2676 line:Math.max(0, parseInt(xmlContent.parseError.line)-1), 2677 linePos:Math.max(0,parseInt(xmlContent.parseError.linepos) -1), 2678 sourceText:xmlContent.parseError.srcText 2679 }; 2680 } else { 2681 ret = findParseError(xmlContent); 2682 } 2683 //we have a line number we now can format the source accordingly 2684 if(ret && 'undefined' != typeof ret.line) { 2685 var source = ret.sourceText ||""; 2686 source = source.split("\n"); 2687 if(source.length-1 < ret.line) return ret; 2688 source = source[ret.line]; 2689 var secondLine = []; 2690 var lineLen = (ret.linePos - 2); 2691 for(var cnt = 0; cnt < lineLen; cnt++) { 2692 secondLine.push(" "); 2693 } 2694 secondLine.push("^^"); 2695 ret.sourceText = source; 2696 ret.visualError = secondLine; 2697 } 2698 return ret; 2699 }, 2700 2701 /** 2702 * creates a neutral form data wrapper over an existing form Data element 2703 * the wrapper delegates following methods, append 2704 * and adds makeFinal as finalizing method which returns the final 2705 * send representation of the element 2706 * 2707 * @param formData an array 2708 */ 2709 createFormDataDecorator:function (formData) { 2710 //we simulate the dom level 2 form element here 2711 var _newCls = null; 2712 var bufInstance = null; 2713 if (!this.FormDataDecoratorArray) { 2714 this.FormDataDecoratorArray = function (theFormData) { 2715 this._valBuf = theFormData; 2716 this._idx = {}; 2717 }; 2718 _newCls = this.FormDataDecoratorArray; 2719 _newCls.prototype.append = function (key, val) { 2720 this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)].join("=")); 2721 this._idx[key] = true; 2722 }; 2723 _newCls.prototype.hasKey = function (key) { 2724 return !!this._idx[key]; 2725 }; 2726 _newCls.prototype.makeFinal = function () { 2727 return this._valBuf.join("&"); 2728 }; 2729 } 2730 if (!this.FormDataDecoratorString) { 2731 this.FormDataDecoratorString = function (theFormData) { 2732 this._preprocessedData = theFormData; 2733 this._valBuf = []; 2734 this._idx = {}; 2735 }; 2736 _newCls = this.FormDataDecoratorString; 2737 _newCls.prototype.append = function (key, val) { 2738 this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)].join("=")); 2739 this._idx[key] = true; 2740 }; 2741 //for now we check only for keys which are added subsequently otherwise we do not perform any checks 2742 _newCls.prototype.hasKey = function (key) { 2743 return !!this._idx[key]; 2744 }; 2745 _newCls.prototype.makeFinal = function () { 2746 if (this._preprocessedData != "") { 2747 return this._preprocessedData + "&" + this._valBuf.join("&") 2748 } else { 2749 return this._valBuf.join("&"); 2750 } 2751 }; 2752 } 2753 if (!this.FormDataDecoratorOther) { 2754 this.FormDataDecoratorOther = function (theFormData) { 2755 this._valBuf = theFormData; 2756 this._idx = {}; 2757 }; 2758 _newCls = this.FormDataDecoratorOther;
2759 _newCls.prototype.append = function (key, val) { 2760 this._valBuf.append(key, val); 2761 this._idx[key] = true; 2762 }; 2763 _newCls.prototype.hasKey = function (key) { 2764 return !!this._idx[key]; 2765 }; 2766 _newCls.prototype.makeFinal = function () { 2767 return this._valBuf; 2768 }; 2769 } 2770 if (formData instanceof Array) { 2771 bufInstance = new this.FormDataDecoratorArray(formData); 2772 } else if (this.isString(formData)) { 2773 bufInstance = new this.FormDataDecoratorString(formData); 2774 } else { 2775 bufInstance = new this.FormDataDecoratorOther(formData); 2776 } 2777 return bufInstance; 2778 }, 2779 /** 2780 * define a property mechanism which is browser neutral 2781 * we cannot use the existing setter and getter mechanisms 2782 * for now because old browsers do not support them 2783 * in the long run we probably can switch over 2784 * or make a code split between legacy and new 2785 * 2786 * 2787 * @param obj 2788 * @param name 2789 * @param value 2790 */ 2791 attr:function (obj, name, value) { 2792 var findAccessor = function (theObj, theName) { 2793 return (theObj["_" + theName]) ? "_" + theName : ( (theObj[theName]) ? theName : null) 2794 }; 2795 var applyAttr = function (theObj, theName, value, isFunc) { 2796 if (value) { 2797 if (isFunc) { 2798 theObj[theName](value); 2799 } else { 2800 theObj[theName] = value; 2801 } 2802 return null; 2803 } 2804 return (isFunc) ? theObj[theName]() : theObj[theName]; 2805 }; 2806 try { 2807 var finalAttr = findAccessor(obj, name); 2808 //simple attibute no setter and getter overrides 2809 if (finalAttr) { 2810 return applyAttr(obj, finalAttr, value); 2811 } 2812 //lets check for setter and getter overrides 2813 var found = false; 2814 var prefix = (value) ? "set" : "get"; 2815 finalAttr = [prefix, name.substr(0, 1).toUpperCase(), name.substr(1)].join(""); 2816 finalAttr = findAccessor(obj, finalAttr); 2817 if (finalAttr) { 2818 return applyAttr(obj, finalAttr, value, true); 2819 } 2820 2821 throw this.makeException(new Error(), null, null, this._nameSpace, "contains", "property " + name + " not found"); 2822 } finally { 2823 findAccessor = null; 2824 applyAttr = null; 2825 } 2826 }, 2827 2828 /** 2829 * creates an exeption with additional internal parameters 2830 * for extra information 2831 * 2832 * @param {String} title the exception title 2833 * @param {String} name the exception name 2834 * @param {String} callerCls the caller class 2835 * @param {String} callFunc the caller function 2836 * @param {String} message the message for the exception 2837 */ 2838 makeException:function (error, title, name, callerCls, callFunc, message) { 2839 error.name = name || "clientError"; 2840 error.title = title || ""; 2841 error.message = message || ""; 2842 error._mfInternal = {}; 2843 error._mfInternal.name = name || "clientError"; 2844 error._mfInternal.title = title || "clientError"; 2845 error._mfInternal.caller = callerCls || this._nameSpace; 2846 error._mfInternal.callFunc = callFunc || ("" + arguments.caller.toString()); 2847 return error; 2848 } 2849}); 2850 2851/* Licensed to the Apache Software Foundation (ASF) under one or more 2852 * contributor license agreements. See the NOTICE file distributed with 2853 * this work for additional information regarding copyright ownership. 2854 * The ASF licenses this file to you under the Apache License, Version 2.0 2855 * (the "License"); you may not use this file except in compliance with 2856 * the License. You may obtain a copy of the License at 2857 * 2858 * http://www.apache.org/licenses/LICENSE-2.0 2859 * 2860 * Unless required by applicable law or agreed to in writing, software 2861 * distributed under the License is distributed on an "AS IS" BASIS, 2862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2863 * See the License for the specific language governing permissions and 2864 * limitations under the License. 2865 */ 2866 2867 2868/* 2869 theoretically we could save some code 2870 by 2871 defining the parent object as 2872 var parent = new Object(); 2873 parent.prototype = new myfaces._impl.core._Runtime(); 2874 extendClass(function () { 2875 }, parent , { 2876 But for now we are not doing it the little bit of saved 2877 space is not worth the loss of readability 2878 */ 2879 2880//html5 ecmascript 3 compliant browser, no quirks mode needed 2881if(!Array.prototype.forEach && _MF_SINGLTN) { 2882/** 2883 * @memberOf myfaces._impl 2884 * @namespace 2885 * @name _util 2886 */ 2887 2888/** 2889 * @class 2890 * @name _Lang 2891 * @memberOf myfaces._impl._util 2892 * @extends myfaces._impl.core._Runtime 2893 * @namespace 2894 * @description Object singleton for Language related methods, this object singleton 2895 * decorates the namespace myfaces._impl.core._Runtime and adds a bunch of new methods to 2896 * what _Runtime provided 2897 * <p>This class provides the proper fallbacks for ie8- and Firefox 3.6-</p> 2898 * */ 2899_MF_SINGLTN(_PFX_UTIL+"_LangQuirks", myfaces._impl._util._Lang, { 2900 2901 constructor_: function() { 2902 this._callSuper("constructor_"); 2903 var _RT = this._RT; 2904 var _T = this; 2905 //we only apply lazy if the jsf part is loaded already 2906 //otherwise we are at the correct position 2907 if(myfaces._impl.core.Impl) { 2908 _RT.iterateClasses(function(proto) { 2909 if(proto._Lang) proto._Lang = _T; 2910 }); 2911 } 2912 2913 myfaces._impl._util._Lang = _T; 2914 }, 2915 2916 /** 2917 * foreach implementation utilizing the 2918 * ECMAScript wherever possible 2919 * with added functionality 2920 * 2921 * @param arr the array to filter 2922 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2923 * function (element<,key, array>) 2924 * <p /> 2925 * optional params 2926 * <p /> 2927 * <ul> 2928 * <li>param startPos (optional) the starting position </li> 2929 * <li>param scope (optional) the scope to apply the closure to </li> 2930 * </ul> 2931 */ 2932 arrForEach: function(arr, func /*startPos, scope*/) { 2933 if (!arr || !arr.length) return; 2934 try { 2935 var startPos = Number(arguments[2]) || 0; 2936 var thisObj = arguments[3]; 2937 2938 //check for an existing foreach mapping on array prototypes 2939 //IE9 still does not pass array objects as result for dom ops 2940 if (Array.prototype.forEach && arr.forEach) {
2941 (startPos) ? arr.slice(startPos).forEach(func, thisObj) : arr.forEach(func, thisObj); 2942 } else { 2943 startPos = (startPos < 0) ? Math.ceil(startPos) : Math.floor(startPos); 2944 if (typeof func != "function") { 2945 throw new TypeError(); 2946 } 2947 for (var cnt = 0; cnt < arr.length; cnt++) { 2948 if (thisObj) { 2949 func.call(thisObj, arr[cnt], cnt, arr); 2950 } else { 2951 func(arr[cnt], cnt, arr); 2952 } 2953 } 2954 } 2955 } finally { 2956 func = null; 2957 } 2958 }, 2959 2960 /** 2961 * foreach implementation utilizing the 2962 * ECMAScript wherever possible 2963 * with added functionality 2964 * 2965 * @param arr the array to filter 2966 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2967 * function (element<,key, array>) 2968 * <p /> 2969 * additional params 2970 * <ul> 2971 * <li> startPos (optional) the starting position</li> 2972 * <li> scope (optional) the scope to apply the closure to</li> 2973 * </ul> 2974 */ 2975 arrFilter: function(arr, func /*startPos, scope*/) { 2976 if (!arr || !arr.length) return []; 2977 try { 2978 var startPos = Number(arguments[2]) || 0; 2979 var thisObj = arguments[3]; 2980 2981 //check for an existing foreach mapping on array prototypes 2982 if (Array.prototype.filter) { 2983 return ((startPos) ? arr.slice(startPos).filter(func, thisObj) : arr.filter(func, thisObj)); 2984 } else { 2985 if (typeof func != "function") { 2986 throw new TypeError(); 2987 } 2988 var ret = []; 2989 startPos = (startPos < 0) ? Math.ceil(startPos) : Math.floor(startPos); 2990 2991 for (var cnt = startPos; cnt < arr.length; cnt++) { 2992 var elem = null; 2993 if (thisObj) { 2994 elem = arr[cnt]; 2995 if (func.call(thisObj, elem, cnt, arr)) ret.push(elem); 2996 } else { 2997 elem = arr[cnt]; 2998 if (func(arr[cnt], cnt, arr)) ret.push(elem); 2999 } 3000 } 3001 } 3002 } finally { 3003 func = null; 3004 } 3005 }, 3006 3007 /** 3008 * adds a EcmaScript optimized indexOf to our mix, 3009 * checks for the presence of an indexOf functionality 3010 * and applies it, otherwise uses a fallback to the hold 3011 * loop method to determine the index 3012 * 3013 * @param arr the array 3014 * @param element the index to search for 3015 */ 3016 arrIndexOf: function(arr, element /*fromIndex*/) { 3017 if (!arr || !arr.length) return -1; 3018 var pos = Number(arguments[2]) || 0; 3019 3020 if (Array.prototype.indexOf) { 3021 return arr.indexOf(element, pos); 3022 } 3023 //var cnt = this._space; 3024 var len = arr.length; 3025 pos = (pos < 0) ? Math.ceil(pos) : Math.floor(pos); 3026 3027 //if negative then it is taken from as offset from the length of the array 3028 if (pos < 0) { 3029 pos += len; 3030 } 3031 while (pos < len && arr[pos] !== element) { 3032 pos++; 3033 } 3034 return (pos < len) ? pos : -1; 3035 }, 3036 3037 parseXML: function(txt) { 3038 try { 3039 var xmlDoc = null; 3040 if (window.DOMParser) { 3041 xmlDoc = this._callSuper("parseXML", txt); 3042 } 3043 else // Internet Explorer 3044 { 3045 xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 3046 xmlDoc.async = "false"; 3047 xmlDoc.loadXML(txt); 3048 } 3049 return xmlDoc; 3050 } catch (e) { 3051 //undefined internal parser error 3052 return null; 3053 } 3054 }, 3055 3056 serializeXML: function(xmlNode, escape) { 3057 if (xmlNode.xml) return xmlNode.xml; //IE 3058 return this._callSuper("serializeXML", xmlNode, escape); 3059 }, 3060 3061 /** 3062 * Concatenates an array to a string 3063 * @param {Array} arr the array to be concatenated 3064 * @param {String} delimiter the concatenation delimiter if none is set \n is used 3065 * 3066 * @return the concatenated array, one special behavior to enable j4fry compatibility has been added 3067 * if no delimiter is used the [entryNumber]+entry is generated for a single entry 3068 * TODO check if this is still needed it is somewhat outside of the scope of the function 3069 * and functionality wise dirty 3070 */ 3071 arrToString : function(/*String or array*/ arr, /*string*/ delimiter) { 3072 if (!arr) { 3073 throw this._Lang.makeException(new Error(), null, null, this._nameSpace,"arrToString", this.getMessage("ERR_MUST_BE_PROVIDED1",null, "arr {array}")); 3074 } 3075 if (this.isString(arr)) { 3076 return arr; 3077 } 3078 3079 delimiter = delimiter || "\n"; 3080 return arr.join(delimiter); 3081 } 3082}); 3083 3084} 3085 3086/* Licensed to the Apache Software Foundation (ASF) under one or more 3087 * contributor license agreements. See the NOTICE file distributed with 3088 * this work for additional information regarding copyright ownership. 3089 * The ASF licenses this file to you under the Apache License, Version 2.0 3090 * (the "License");
3090 you may not use this file except in compliance with 3091 * the License. You may obtain a copy of the License at 3092 * 3093 * http://www.apache.org/licenses/LICENSE-2.0 3094 * 3095 * Unless required by applicable law or agreed to in writing, software 3096 * distributed under the License is distributed on an "AS IS" BASIS, 3097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3098 * See the License for the specific language governing permissions and 3099 * limitations under the License. 3100 */ 3101/** 3102 Base class which provides several helper functions over all objects 3103 */ 3104_MF_CLS(_PFX_CORE+"Object", Object, { 3105 3106 3107 3108 constructor_: function() { 3109 this._resettableContent = {}; 3110 //to make those singleton references 3111 //overridable in the instance we have 3112 //to load them into the prototype instead 3113 //of the instance 3114 var proto = this._mfClazz.prototype; 3115 var impl = myfaces._impl; 3116 if(!proto._RT) { 3117 proto._RT = impl.core._Runtime; 3118 proto._Lang = impl._util._Lang; 3119 proto._Dom = impl._util._Dom; 3120 } 3121 }, 3122 3123 /*optional functionality can be provided 3124 * for ie6 but is turned off by default*/ 3125 _initDefaultFinalizableFields: function() { 3126 var isIE = this._RT.browser.isIE; 3127 if(!isIE || isIE > 7) return; 3128 for (var key in this) { 3129 //per default we reset everything which is not preinitalized 3130 if (null == this[key] && key != "_resettableContent" && key.indexOf("_mf") != 0 && key.indexOf("_") == 0) { 3131 this._resettableContent[key] = true; 3132 } 3133 } 3134 }, 3135 3136 /** 3137 * ie6 cleanup 3138 * This method disposes all properties manually in case of ie6 3139 * hence reduces the chance of running into a gc problem tremendously 3140 * on other browsers this method does nothing 3141 */ 3142 _finalize: function() { 3143 try { 3144 if (this._isGCed || !this._RT.browser.isIE || !this._resettableContent) { 3145 //no ie, no broken garbage collector 3146 return; 3147 } 3148 3149 for (var key in this._resettableContent) { 3150 if (this._RT.exists(this[key], "_finalize")) { 3151 this[key]._finalize(); 3152 } 3153 delete this[key]; 3154 } 3155 } finally { 3156 this._isGCed = true; 3157 } 3158 }, 3159 3160 attr: function(name, value) { 3161 return this._Lang.attr(this, name, value); 3162 }, 3163 3164 getImpl: function() { 3165 this._Impl = this._Impl || this._RT.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 3166 return this._Impl; 3167 }, 3168 3169 applyArgs: function(args) { 3170 this._Lang.applyArgs(this, args); 3171 }, 3172 3173 updateSingletons: function(key) { 3174 var _T = this; 3175 _T._RT.iterateSingletons(function(namespace) { 3176 if(namespace[key]) namespace[key] = _T; 3177 }); 3178 } 3179 3180}); 3181 3182(function() { 3183 /*some mobile browsers do not have a window object*/ 3184 var target = window ||document; 3185 var _RT = myfaces._impl.core._Runtime; 3186 _RT._MF_OBJECT = target._MF_OBJECT; 3187 3188 target._MF_OBJECT = myfaces._impl.core.Object; 3189})(); 3190 3191/* Licensed to the Apache Software Foundation (ASF) under one or more 3192 * contributor license agreements. See the NOTICE file distributed with 3193 * this work for additional information regarding copyright ownership. 3194 * The ASF licenses this file to you under the Apache License, Version 2.0 3195 * (the "License"); you may not use this file except in compliance with 3196 * the License. You may obtain a copy of the License at 3197 * 3198 * http://www.apache.org/licenses/LICENSE-2.0 3199 * 3200 * Unless required by applicable law or agreed to in writing, software 3201 * distributed under the License is distributed on an "AS IS" BASIS, 3202 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3203 * See the License for the specific language governing permissions and 3204 * limitations under the License. 3205 */ 3206 3207/** 3208 * @class 3209 * @name _Queue 3210 * @memberOf myfaces._impl._util 3211 * @description Queue implementation used by our runtime system 3212 * improved version of
3213 * @see <a href="http://safalra.com/web-design/javascript/queues/Queue.js">http://safalra.com/web-design/javascript/queues/Queue.js</a> 3214 */ 3215_MF_CLS(_PFX_UTIL+"_Queue", _MF_OBJECT, 3216 /** 3217 * @lends myfaces._impl._util._Queue.prototype 3218 */ 3219{ 3220 //faster queue by http://safalra.com/web-design/javascript/queues/Queue.js 3221 //license public domain 3222 //The trick is to simply reduce the number of slice and slice ops to a bare minimum. 3223 3224 _q : null, 3225 _space : 0, 3226 _size: -1, 3227 3228 /** 3229 * Standard constructor 3230 */ 3231 constructor_: function() { 3232 this._callSuper("constructor_"); 3233 this._q = []; 3234 }, 3235 3236 /** 3237 * @return the length of the queue as integer 3238 */ 3239 length: function() { 3240 // return the number of elements in the queue 3241 return this._q.length - this._space; 3242 3243 }, 3244 3245 /** 3246 * @return true if the current queue is empty false otherwise 3247 */ 3248 isEmpty: function() { 3249 // return true if the queue is empty, and false otherwise 3250 return (this._q.length == 0); 3251 }, 3252 3253 /** 3254 * Sets the current queue to a new size, all overflow elements at the end are stripped 3255 * automatically 3256 * 3257 * @param {int} newSize as numeric value 3258 */ 3259 setQueueSize: function(newSize) { 3260 this._size = newSize; 3261 this._readjust(); 3262 }, 3263 3264 /** 3265 * adds a listener to the queue 3266 * 3267 * @param element the listener to be added 3268 */ 3269 enqueue : function(/*function*/element) { 3270 this._q.push(element); 3271 //qeuesize is bigger than the limit we drop one element so that we are 3272 //back in line 3273 3274 this._readjust(); 3275 }, 3276 3277 _readjust: function() { 3278 3279 var size = this._size; 3280 while (size && size > -1 && this.length() > size) { 3281 this.dequeue(); 3282 } 3283 }, 3284 3285 /** 3286 * removes a listener form the queue 3287 * 3288 * @param element the listener to be removed 3289 */ 3290 remove : function(/*function*/element) { 3291 /*find element in queue*/ 3292 var index = this.indexOf(element); 3293 /*found*/ 3294 if (index != -1) { 3295 this._q.splice(index, 1); 3296 } 3297 }, 3298 3299 /** 3300 * dequeues the last element in the queue 3301 * @return {Object} element which is dequeued 3302 */ 3303 dequeue: function() { 3304 // initialise the element to return to be undefined 3305 var element = null; 3306 3307 // check whether the queue is empty 3308 var qLen = this._q.length; 3309 var queue = this._q; 3310 3311 if (qLen) { 3312 3313 // fetch the oldest element in the queue 3314 element = queue[this._space]; 3315 3316 // update the amount of space and check whether a shift should occur 3317 //added here a max limit of 30 3318 //now bit shift left is a tad faster than multiplication on most vms and does the same 3319 //unless we run into a bit skipping which is impossible in our usecases here 3320 if ((++this._space) << 1 >= qLen) { 3321 3322 // set the queue equal to the non-empty portion of the queue 3323 this._q = queue.slice(this._space); 3324 3325 // reset the amount of space at the front of the queue 3326 this._space = 0; 3327 3328 } 3329 3330 } 3331 3332 // return the removed element 3333 return element; 3334 }, 3335 3336 /** 3337 * simple foreach 3338 * 3339 * @param closure a closure which processes the element 3340 * @code 3341 * queue.each(function(element) { 3342 * //do something with the element 3343 * }); 3344 */ 3345 each: function(closure) { 3346 this._Lang.arrForEach(this._q, closure, this._space); 3347 }, 3348 3349 /** 3350 * Simple filter 3351 * 3352 * @param closure a closure which returns true or false depending 3353 * whether the filter has triggered 3354 *
3355 * @return an array of filtered queue entries 3356 */ 3357 arrFilter: function(closure) { 3358 return this._Lang.arrFilter(this._q, closure, this._space); 3359 }, 3360 3361 /** 3362 * @param element 3363 * @return the current index of the element in the queue or -1 if it is not found 3364 */ 3365 indexOf: function(element) { 3366 return this._Lang.arrIndexOf(this._q, element); 3367 }, 3368 3369 /** 3370 * resets the queue to initial empty state 3371 */ 3372 cleanup: function() { 3373 this._q = []; 3374 this._space = 0; 3375 } 3376}); 3377 3378 3379/* 3380 * Licensed to the Apache Software Foundation (ASF) under one or more 3381 * contributor license agreements. See the NOTICE file distributed with 3382 * this work for additional information regarding copyright ownership. 3383 * The ASF licenses this file to you under the Apache License, Version 2.0 3384 * (the "License"); you may not use this file except in compliance with 3385 * the License. You may obtain a copy of the License at 3386 * 3387 * http://www.apache.org/licenses/LICENSE-2.0 3388 * 3389 * Unless required by applicable law or agreed to in writing, software 3390 * distributed under the License is distributed on an "AS IS" BASIS, 3391 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3392 * See the License for the specific language governing permissions and 3393 * limitations under the License. 3394 */ 3395/* 3396 * a classical listener queue pattern 3397 */ 3398 3399 3400 3401/** 3402 * @class 3403 * @name _ListenerQueue 3404 * @extends myfaces._impl._util._Queue 3405 * @memberOf myfaces._impl._util 3406 * @description Implementation of the listener queue for jsf.js 3407 * <p>It is based upon our high performance queue and adds dedicated 3408 * methods for listener based closures to the mix </p> 3409 * */ 3410_MF_CLS(_PFX_UTIL+"_ListenerQueue", myfaces._impl._util._Queue, 3411/** 3412 * @lends myfaces._impl._util._ListenerQueue.prototype 3413 */ 3414{ 3415 /** 3416 * listener type safety assertion function 3417 * 3418 * @param {function} listener must be of type function otherwise an error is raised 3419 */ 3420 _assertListener : function( listener) { 3421 if ("function" != typeof (listener)) {
3422 var msg = myfaces._impl._util._Lang.getMessage("ERR_PARAM_GENERIC",null,"_ListenerQueue", arguments.caller.toString(),"function" ); 3423 throw this._Lang.makeException(new Error(), null, null, this._nameSpace,arguments.caller.toString(), msg); 3424 } 3425 }, 3426 3427 /** 3428 * adds a listener to the queue 3429 * 3430 * @param {function} listener the listener to be added 3431 */ 3432 enqueue : function(listener) { 3433 this._assertListener(listener); 3434 this._callSuper("enqueue", listener); 3435 }, 3436 3437 /** 3438 * removes a listener form the queue 3439 * 3440 * @param {function} listener the listener to be removed 3441 */ 3442 remove : function(listener) { 3443 this._assertListener(listener); 3444 this._callSuper("remove", listener); 3445 }, 3446 3447 /** 3448 * generic broadcast with a number of arguments being passed down 3449 * @param {Object} argument the arguments passed down which are broadcast 3450 */ 3451 broadcastEvent : function(argument) { 3452 var _args = myfaces._impl._util._Lang.objToArray(arguments); 3453 3454 var broadCastFunc = function(element) { 3455 element.apply(null, _args); 3456 }; 3457 try { 3458 this.each(broadCastFunc); 3459 } finally { 3460 broadCastFunc = null; 3461 } 3462 } 3463}); 3464/* Licensed to the Apache Software Foundation (ASF) under one or more 3465 * contributor license agreements. See the NOTICE file distributed with 3466 * this work for additional information regarding copyright ownership. 3467 * The ASF licenses this file to you under the Apache License, Version 2.0 3468 * (the "License"); you may not use this file except in compliance with 3469 * the License. You may obtain a copy of the License at 3470 * 3471 * http://www.apache.org/licenses/LICENSE-2.0 3472 * 3473 * Unless required by applicable law or agreed to in writing, software 3474 * distributed under the License is distributed on an "AS IS" BASIS,© 3475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3476 * See the License for the specific language governing permissions and 3477 * limitations under the License. 3478 */ 3479 3480/** 3481 * @class 3482 * @name _Dom 3483 * @memberOf myfaces._impl._util 3484 * @extends myfaces._impl.core._Runtime 3485 * @description Object singleton collection of dom helper routines 3486 * (which in later incarnations will 3487 * get browser specific speed optimizations) 3488 * 3489 * Since we have to be as tight as possible 3490 * we will focus with our dom routines to only 3491 * the parts which our impl uses. 3492 * A jquery like query API would be nice 3493 * but this would increase up our codebase significantly 3494 * 3495 * <p>This class provides the proper fallbacks for ie8- and Firefox 3.6-</p> 3496 */ 3497_MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prototype */ { 3498 3499 /*table elements which are used in various parts */ 3500 TABLE_ELEMS: { 3501 "thead": 1, 3502 "tbody": 1, 3503 "tr": 1, 3504 "th": 1, 3505 "td": 1, 3506 "tfoot" : 1 3507 }, 3508 3509 _Lang: myfaces._impl._util._Lang, 3510 _RT: myfaces._impl.core._Runtime, 3511 _dummyPlaceHolder:null, 3512 3513 /** 3514 * standard constructor 3515 */ 3516 constructor_: function() { 3517 }, 3518 3519 runCss: function(item/*, xmlData*/) { 3520 3521 var UDEF = "undefined", 3522 _RT = this._RT, 3523 _Lang = this._Lang, 3524 applyStyle = function(item, style) { 3525 var newSS = document.createElement("style"); 3526 3527 newSS.setAttribute("rel", item.getAttribute("rel") || "stylesheet"); 3528 newSS.setAttribute("type", item.getAttribute("type") || "text/css"); 3529 document.getElementsByTagName("head")[0].appendChild(newSS); 3530 //ie merrily again goes its own way 3531 if (window.attachEvent && !_RT.isOpera && UDEF != typeof newSS.styleSheet && UDEF != newSS.styleSheet.cssText) newSS.styleSheet.cssText = style; 3532 else newSS.appendChild(document.createTextNode(style)); 3533 }, 3534 3535 execCss = function(item) { 3536 var equalsIgnoreCase = _Lang.equalsIgnoreCase; 3537 var tagName = item.tagName; 3538 if (tagName && equalsIgnoreCase(tagName, "link") && equalsIgnoreCase(item.getAttribute("type"), "text/css")) { 3539 applyStyle(item, "@import url('" + item.getAttribute("href") + "');"); 3540 } else if (tagName && equalsIgnoreCase(tagName, "style") && equalsIgnoreCase(item.getAttribute("type"), "text/css")) { 3541 var innerText = []; 3542 //compliant browsers know child nodes 3543 var childNodes = item.childNodes; 3544 if (childNodes) { 3545 var len = childNodes.length; 3546 for (var cnt = 0; cnt < len; cnt++) { 3547 innerText.push(childNodes[cnt].innerHTML || childNodes[cnt].data); 3548 } 3549 //non compliant ones innerHTML 3550 } else if (item.innerHTML) { 3551 innerText.push(item.innerHTML); 3552 } 3553 3554 applyStyle(item, innerText.join("")); 3555 } 3556 }; 3557 3558 try { 3559 var scriptElements = this.findByTagNames(item, {"link":1,"style":1}, true); 3560 if (scriptElements == null) return; 3561 for (var cnt = 0; cnt < scriptElements.length; cnt++) { 3562 execCss(scriptElements[cnt]); 3563 } 3564 3565 } finally { 3566 //the usual ie6 fix code 3567 //the IE6 garbage collector is broken 3568 //nulling closures helps somewhat to reduce 3569 //mem leaks, which are impossible to avoid 3570 //at this browser 3571 execCss = null; 3572 applyStyle = null; 3573 } 3574 }, 3575 3576 3577 /** 3578 * Run through the given Html item and execute the inline scripts 3579 * (IE doesn't do this by itself) 3580 * @param {Node} item 3581 */ 3582 runScripts: function(item, xmlData) { 3583 var _Lang = this._Lang, 3584 _RT = this._RT, 3585 finalScripts = [], 3586 execScrpt = function(item) { 3587 var tagName = item.tagName; 3588 var type = item.type || ""; 3589 //script type javascript has to be handled by eval, other types 3590 //must be handled by the browser 3591 if (tagName && _Lang.equalsIgnoreCase(tagName, "script") && 3592 (type === "" || 3593 _Lang.equalsIgnoreCase(type,"text/javascript") || 3594 _Lang.equalsIgnoreCase(type,"javascript") || 3595 _Lang.equalsIgnoreCase(type,"text/ecmascript") || 3596 _Lang.equalsIgnoreCase(type,"ecmascript"))) { 3597 3598 var src = item.getAttribute('src'); 3599 if ('undefined' != typeof src 3600 && null != src 3601 && src.length > 0 3602 ) { 3603 //we have to move this into an inner if because chrome otherwise chokes 3604 //due to changing the and order instead of relying on left to right 3605 //if jsf.js is already registered we do not replace it anymore 3606 if ((src.indexOf("ln=scripts") == -1 && src.indexOf("ln=javax.faces") == -1) || (src.indexOf("/jsf.js") == -1 3607 && src.indexOf("/jsf-uncompressed.js") == -1)) { 3608 if (finalScripts.length) { 3609 //script source means we have to eval the existing 3610 //scripts before running the include 3611 _RT.globalEval(finalScripts.join("\n")); 3612 3613 finalScripts = []; 3614 } 3615 _RT.loadScriptEval(src, item.getAttribute('type'), false, "UTF-8", false); 3616 } 3617 3618 } else { 3619 // embedded script auto eval 3620 var test = (!xmlData) ? item.text : _Lang.serializeChilds(item); 3621 var go = true; 3622 while (go) { 3623 go = false;
3624 if (test.substring(0, 1) == " ") { 3625 test = test.substring(1); 3626 go = true; 3627 } 3628 if (test.substring(0, 4) == "<!--") { 3629 test = test.substring(4); 3630 go = true; 3631 } 3632 if (test.substring(0, 11) == "//<![CDATA[") { 3633 test = test.substring(11); 3634 go = true; 3635 } 3636 } 3637 // we have to run the script under a global context 3638 //we store the script for less calls to eval 3639 finalScripts.push(test); 3640 3641 } 3642 } 3643 }; 3644 try { 3645 var scriptElements = this.findByTagName(item, "script", true); 3646 if (scriptElements == null) return; 3647 for (var cnt = 0; cnt < scriptElements.length; cnt++) { 3648 execScrpt(scriptElements[cnt]); 3649 } 3650 if (finalScripts.length) { 3651 _RT.globalEval(finalScripts.join("\n")); 3652 } 3653 } catch (e) { 3654 //we are now in accordance with the rest of the system of showing errors only in development mode 3655 //the default error output is alert we always can override it with 3656 //window.myfaces = window.myfaces ||Â {}; 3657 //myfaces.config = myfaces.config ||Â {}; 3658 //myfaces.config.defaultErrorOutput = console.error; 3659 if(jsf.getProjectStage() === "Development") { 3660 var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert); 3661 defaultErrorOutput("Error in evaluated javascript:"+ (e.message || e.description || e)); 3662 } 3663 } finally { 3664 //the usual ie6 fix code 3665 //the IE6 garbage collector is broken 3666 //nulling closures helps somewhat to reduce 3667 //mem leaks, which are impossible to avoid 3668 //at this browser 3669 execScrpt = null; 3670 } 3671 }, 3672 3673 3674 /** 3675 * determines to fetch a node 3676 * from its id or name, the name case 3677 * only works if the element is unique in its name 3678 * @param {String} elem 3679 */ 3680 byIdOrName: function(elem) { 3681 if (!elem) return null; 3682 if (!this._Lang.isString(elem)) return elem; 3683 3684 var ret = this.byId(elem); 3685 if (ret) return ret; 3686 //we try the unique name fallback 3687 var items = document.getElementsByName(elem); 3688 return ((items.length == 1) ? items[0] : null); 3689 }, 3690 3691 /** 3692 * node id or name, determines the valid form identifier of a node 3693 * depending on its uniqueness 3694 * 3695 * Usually the id is chosen for an elem, but if the id does not 3696 * exist we try a name fallback. If the passed element has a unique 3697 * name we can use that one as subsequent identifier. 3698 * 3699 * 3700 * @param {String} elem 3701 */ 3702 nodeIdOrName: function(elem) { 3703 if (elem) { 3704 //just to make sure that the pas 3705 3706 elem = this.byId(elem); 3707 if (!elem) return null; 3708 //detached element handling, we also store the element name 3709 //to get a fallback option in case the identifier is not determinable 3710 // anymore, in case of a framework induced detachment the element.name should 3711 // be shared if the identifier is not determinable anymore 3712 //the downside of this method is the element name must be unique 3713 //which in case of jsf it is 3714 var elementId = elem.id || elem.name; 3715 if ((elem.id == null || elem.id == '') && elem.name) { 3716 elementId = elem.name; 3717 3718 //last check for uniqueness 3719 if (document.getElementsByName(elementId).length > 1) { 3720 //no unique element name so we need to perform 3721 //a return null to let the caller deal with this issue 3722 return null; 3723 } 3724 } 3725 return elementId; 3726 } 3727 return null; 3728 }, 3729 3730 deleteItems: function(items) { 3731 if (! items || ! items.length) return; 3732 for (var cnt = 0; cnt < items.length; cnt++) { 3733 this.deleteItem(items[cnt]); 3734 } 3735 }, 3736 3737 /** 3738 * Simple delete on an existing item 3739 */ 3740 deleteItem: function(itemIdToReplace) { 3741 var item = this.byId(itemIdToReplace); 3742 if (!item) { 3743 throw this._Lang.makeException(new Error(),null, null, this._nameSpace, "deleteItem", "_Dom.deleteItem Unknown Html-Component-ID: " + itemIdToReplace); 3744 } 3745 3746 this._removeNode(item, false); 3747 }, 3748 3749 /** 3750 * creates a node upon a given node name 3751 * @param nodeName {String} the node name to be created 3752 * @param attrs {Array} a set of attributes to be set 3753 */ 3754 createElement: function(nodeName, attrs) { 3755 var ret = document.createElement(nodeName); 3756 if (attrs) { 3757 for (var key in attrs) { 3758 if(!attrs.hasOwnProperty(key)) continue; 3759 this.setAttribute(ret, key, attrs[key]); 3760 } 3761 } 3762 return ret; 3763 }, 3764 3765 /** 3766 * Checks whether the browser is dom compliant. 3767 * Dom compliant means that it performs the basic dom operations safely 3768 * without leaking and also is able to perform a native setAttribute 3769 * operation without freaking out 3770 * 3771 * 3772 * Not dom compliant browsers are all microsoft browsers in quirks mode 3773 * and ie6 and ie7 to some degree in standards mode 3774 * and pretty much every browser who cannot create ranges 3775 * (older mobile browsers etc...) 3776 * 3777 * We dont do a full browser detection here because it probably is safer 3778 * to test for existing features to make an assumption about the 3779 * browsers capabilities 3780 */ 3781 isDomCompliant: function() { 3782 return true; 3783 }, 3784 3785 /** 3786 * proper insert before which takes tables into consideration as well as 3787 * browser deficiencies 3788 * @param item the node to insert before 3789 * @param markup the markup to be inserted 3790 */ 3791 insertBefore: function(item, markup) { 3792 this._assertStdParams(item, markup, "insertBefore"); 3793 3794 markup = this._Lang.trim(markup); 3795 if (markup === "") return null; 3796 3797 var evalNodes = this._buildEvalNodes(item, markup), 3798 currentRef = item, 3799 parentNode = item.parentNode, 3800 ret = []; 3801 for (var cnt = evalNodes.length - 1; cnt >= 0; cnt--) { 3802 currentRef = parentNode.insertBefore(evalNodes[cnt], currentRef);
3803 ret.push(currentRef); 3804 } 3805 ret = ret.reverse(); 3806 this._eval(ret); 3807 return ret; 3808 }, 3809 3810 /** 3811 * proper insert before which takes tables into consideration as well as 3812 * browser deficiencies 3813 * @param item the node to insert before 3814 * @param markup the markup to be inserted 3815 */ 3816 insertAfter: function(item, markup) { 3817 this._assertStdParams(item, markup, "insertAfter"); 3818 markup = this._Lang.trim(markup); 3819 if (markup === "") return null; 3820 3821 var evalNodes = this._buildEvalNodes(item, markup), 3822 currentRef = item, 3823 parentNode = item.parentNode, 3824 ret = []; 3825 3826 for (var cnt = 0; cnt < evalNodes.length; cnt++) { 3827 if (currentRef.nextSibling) { 3828 //Winmobile 6 has problems with this strategy, but it is not really fixable 3829 currentRef = parentNode.insertBefore(evalNodes[cnt], currentRef.nextSibling); 3830 } else { 3831 currentRef = parentNode.appendChild(evalNodes[cnt]); 3832 } 3833 ret.push(currentRef); 3834 } 3835 this._eval(ret); 3836 return ret; 3837 }, 3838 3839 propertyToAttribute: function(name) { 3840 if (name === 'className') { 3841 return 'class'; 3842 } else if (name === 'xmllang') { 3843 return 'xml:lang'; 3844 } else { 3845 return name.toLowerCase(); 3846 } 3847 }, 3848 3849 isFunctionNative: function(func) { 3850 return /^\s*function[^{]+{\s*\[native code\]\s*}\s*$/.test(String(func)); 3851 }, 3852 3853 detectAttributes: function(element) { 3854 //test if 'hasAttribute' method is present and its native code is intact 3855 //for example, Prototype can add its own implementation if missing 3856 if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) { 3857 return function(name) { 3858 return element.hasAttribute(name); 3859 } 3860 } else { 3861 try { 3862 //when accessing .getAttribute method without arguments does not throw an error then the method is not available 3863 element.getAttribute; 3864 3865 var html = element.outerHTML; 3866 var startTag = html.match(/^<[^>]*>/)[0]; 3867 return function(name) { 3868 return startTag.indexOf(name + '=') > -1; 3869 } 3870 } catch (ex) { 3871 return function(name) { 3872 return element.getAttribute(name); 3873 } 3874 } 3875 } 3876 }, 3877 3878 /** 3879 * copy all attributes from one element to another - except id 3880 * @param target element to copy attributes to 3881 * @param source element to copy attributes from 3882 * @ignore 3883 */ 3884 cloneAttributes: function(target, source) { 3885 3886 // enumerate core element attributes - without 'dir' as special case 3887 var coreElementProperties = ['className', 'title', 'lang', 'xmllang']; 3888 // enumerate additional input element attributes 3889 var inputElementProperties = [ 3890 'name', 'value', 'size', 'maxLength', 'src', 'alt', 'useMap', 'tabIndex', 'accessKey', 'accept', 'type' 3891 ]; 3892 // enumerate additional boolean input attributes 3893 var inputElementBooleanProperties = [ 3894 'checked', 'disabled', 'readOnly' 3895 ]; 3896 3897 // Enumerate all the names of the event listeners 3898 var listenerNames = 3899 [ 'onclick', 'ondblclick', 'onmousedown', 'onmousemove', 'onmouseout', 3900 'onmouseover', 'onmouseup', 'onkeydown', 'onkeypress', 'onkeyup', 3901 'onhelp', 'onblur', 'onfocus', 'onchange', 'onload', 'onunload', 'onabort', 3902 'onreset', 'onselect', 'onsubmit' 3903 ]; 3904 3905 var sourceAttributeDetector = this.detectAttributes(source); 3906 var targetAttributeDetector = this.detectAttributes(target); 3907 3908 var isInputElement = target.nodeName.toLowerCase() === 'input'; 3909 var propertyNames = isInputElement ? coreElementProperties.concat(inputElementProperties) : coreElementProperties; 3910 var isXML = !source.ownerDocument.contentType || source.ownerDocument.contentType == 'text/xml'; 3911 for (var iIndex = 0, iLength = propertyNames.length; iIndex < iLength; iIndex++) { 3912 var propertyName = propertyNames[iIndex]; 3913 var attributeName = this.propertyToAttribute(propertyName); 3914 if (sourceAttributeDetector(attributeName)) { 3915 3916 //With IE 7 (quirks or standard mode) and IE 8/9 (quirks mode only), 3917 //you cannot get the attribute using 'class'. You must use 'className' 3918 //which is the same value you use to get the indexed property. The only 3919 //reliable way to detect this (without trying to evaluate the browser 3920 //mode and version) is to compare the two return values using 'className' 3921 //to see if they exactly the same. If they are, then use the property 3922 //name when using getAttribute. 3923 if( attributeName == 'class'){ 3924 if( this._RT.browser.isIE && (source.getAttribute(propertyName) === source[propertyName]) ){ 3925 attributeName = propertyName; 3926 } 3927 } 3928 3929 var newValue = isXML ? source.getAttribute(attributeName) : source[propertyName]; 3930 var oldValue = target[propertyName]; 3931 if (oldValue != newValue) { 3932 target[propertyName] = newValue; 3933 } 3934 } else { 3935 target.removeAttribute(attributeName); 3936 if (attributeName == "value") { 3937 target[propertyName] = ''; 3938 } 3939 } 3940 } 3941 3942 var booleanPropertyNames = isInputElement ? inputElementBooleanProperties : []; 3943 for (var jIndex = 0, jLength = booleanPropertyNames.length; jIndex < jLength; jIndex++) { 3944 var booleanPropertyName = booleanPropertyNames[jIndex]; 3945 var newBooleanValue = source[booleanPropertyName]; 3946 var oldBooleanValue = target[booleanPropertyName]; 3947 if (oldBooleanValue != newBooleanValue) { 3948 target[booleanPropertyName] = newBooleanValue; 3949 } 3950 } 3951 3952 //'style' attribute special case 3953 if (sourceAttributeDetector('style')) { 3954 var newStyle; 3955 var oldStyle; 3956 if (this._RT.browser.isIE) { 3957 newStyle = source.style.cssText; 3958 oldStyle = target.style.cssText; 3959 if (newStyle != oldStyle) { 3960 target.style.cssText = newStyle; 3961 } 3962 } else { 3963 newStyle = source.getAttribute('style'); 3964 oldStyle = target.getAttribute('style'); 3965 if (newStyle != oldStyle) { 3966 target.setAttribute('style', newStyle); 3967 } 3968 } 3969 } else if (targetAttributeDetector('style')){ 3970 target.removeAttribute('style'); 3971 } 3972 3973 // Special case for 'dir' attribute 3974 if (!this._RT.browser.isIE && source.dir != target.dir) { 3975 if (sourceAttributeDetector('dir')) { 3976 target.dir = source.dir; 3977 } else if (targetAttributeDetector('dir')) { 3978 target.dir = ''; 3979 } 3980 } 3981 3982 for (var lIndex = 0, lLength = listenerNames.length; lIndex < lLength; lIndex++) { 3983 var name = listenerNames[lIndex]; 3984 target[name] = source[name] ? source[name] : null; 3985 if (source[name]) { 3986 source[name] = null; 3987 } 3988 } 3989 3990 //clone HTML5 data-* attributes 3991 try{ 3992 var targetDataset = target.dataset; 3993 var sourceDataset = source.dataset; 3994 if (targetDataset || sourceDataset) { 3995 //cleanup the dataset 3996 for (var tp in targetDataset) { 3997 delete targetDataset[tp]; 3998 } 3999 //copy dataset's properties 4000 for (var sp in sourceDataset) { 4001 targetDataset[sp] = sourceDataset[sp]; 4002 } 4003 } 4004 } catch (ex) { 4005 //most probably dataset properties are not supported 4006 } 4007 }, 4008 //from 4009 // http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ 4010 getCaretPosition:function (ctrl) { 4011 var caretPos = 0; 4012 4013 try { 4014 4015 // other browsers make it simpler by simply having a selection start element 4016 if (ctrl.selectionStart || ctrl.selectionStart == '0') 4017 caretPos = ctrl.selectionStart; 4018 // ie 5 quirks mode as second option because 4019 // this option is flakey in conjunction with text areas 4020 // TODO move this into the quirks class 4021 else if (document.selection) { 4022 ctrl.focus(); 4023 var selection = document.selection.createRange(); 4024 //the selection now is start zero 4025 selection.moveStart('character', -ctrl.value.length); 4026 //the caretposition is the selection start 4027 caretPos = selection.text.length; 4028 } 4029 } catch (e) { 4030 //now this is ugly, but not supported input types throw errors for selectionStart 4031 //this way we are future proof by having not to define every selection enabled 4032 //input in an if (which will be a lot in the near future with html5) 4033 } 4034 return caretPos; 4035 }, 4036 4037 setCaretPosition:function (ctrl, pos) { 4038 4039 if (ctrl.createTextRange) { 4040 var range = ctrl.createTextRange(); 4041 range.collapse(true); 4042 range.moveEnd('character', pos); 4043 range.moveStart('character', pos); 4044 range.select(); 4045 } 4046 //IE quirks mode again, TODO move this into the quirks class 4047 else if (ctrl.setSelectionRange) { 4048 ctrl.focus();
4049 //the selection range is our caret position 4050 ctrl.setSelectionRange(pos, pos); 4051 } 4052 }, 4053 4054 /** 4055 * outerHTML replacement which works cross browserlike 4056 * but still is speed optimized 4057 * 4058 * @param item the item to be replaced 4059 * @param markup the markup for the replacement 4060 * @param preserveFocus, tries to preserve the focus within the outerhtml operation 4061 * if set to true a focus preservation algorithm based on document.activeElement is 4062 * used to preserve the focus at the exactly same location as it was 4063 * 4064 */ 4065 outerHTML : function(item, markup, preserveFocus) { 4066 this._assertStdParams(item, markup, "outerHTML"); 4067 // we can work on a single element in a cross browser fashion 4068 // regarding the focus thanks to the 4069 // icefaces team for providing the code 4070 if (item.nodeName.toLowerCase() === 'input') { 4071 var replacingInput = this._buildEvalNodes(item, markup)[0]; 4072 this.cloneAttributes(item, replacingInput); 4073 return item; 4074 } else { 4075 markup = this._Lang.trim(markup); 4076 if (markup !== "") { 4077 var ret = null; 4078 4079 var focusElementId = null; 4080 var caretPosition = 0; 4081 if (preserveFocus && 'undefined' != typeof document.activeElement) { 4082 focusElementId = (document.activeElement) ? document.activeElement.id : null; 4083 caretPosition = this.getCaretPosition(document.activeElement); 4084 } 4085 // we try to determine the browsers compatibility 4086 // level to standards dom level 2 via various methods 4087 if (this.isDomCompliant()) { 4088 ret = this._outerHTMLCompliant(item, markup); 4089 } else { 4090 //call into abstract method 4091 ret = this._outerHTMLNonCompliant(item, markup); 4092 } 4093 if (focusElementId) { 4094 var newFocusElement = this.byId(focusElementId); 4095 if (newFocusElement && newFocusElement.nodeName.toLowerCase() === 'input') { 4096 //just in case the replacement element is not focusable anymore 4097 if ("undefined" != typeof newFocusElement.focus) { 4098 newFocusElement.focus(); 4099 } 4100 } 4101 if (newFocusElement && caretPosition) { 4102 //zero caret position is set automatically on focus 4103 this.setCaretPosition(newFocusElement, caretPosition); 4104 } 4105 } 4106 4107 // and remove the old item 4108 //first we have to save the node newly insert for easier access in our eval part 4109 this._eval(ret); 4110 return ret; 4111 } 4112 // and remove the old item, in case of an empty newtag and do nothing else 4113 this._removeNode(item, false); 4114 return null; 4115 } 4116 }, 4117 4118 isFunctionNative: function(func) { 4119 return /^\s*function[^{]+{\s*\[native code\]\s*}\s*$/.test(String(func)); 4120 }, 4121 4122 detectAttributes: function(element) { 4123 //test if 'hasAttribute' method is present and its native code is intact 4124 //for example, Prototype can add its own implementation if missing 4125 if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) { 4126 return function(name) { 4127 return element.hasAttribute(name); 4128 } 4129 } else { 4130 try { 4131 //when accessing .getAttribute method without arguments does not throw an error then the method is not available 4132 element.getAttribute; 4133 4134 var html = element.outerHTML; 4135 var startTag = html.match(/^<[^>]*>/)[0]; 4136 return function(name) { 4137 return startTag.indexOf(name + '=') > -1; 4138 } 4139 } catch (ex) { 4140 return function(name) { 4141 return element.getAttribute(name); 4142 } 4143 } 4144 } 4145 }, 4146 4147 /** 4148 * detaches a set of nodes from their parent elements 4149 * in a browser independend manner 4150 * @param {Object} items the items which need to be detached 4151 * @return {Array} an array of nodes with the detached dom nodes 4152 */ 4153 detach: function(items) { 4154 var ret = []; 4155 if ('undefined' != typeof items.nodeType) { 4156 if (items.parentNode) {
4157 ret.push(items.parentNode.removeChild(items)); 4158 } else { 4159 ret.push(items); 4160 } 4161 return ret; 4162 } 4163 //all ies treat node lists not as arrays so we have to take 4164 //an intermediate step 4165 var nodeArr = this._Lang.objToArray(items); 4166 for (var cnt = 0; cnt < nodeArr.length; cnt++) { 4167 ret.push(nodeArr[cnt].parentNode.removeChild(nodeArr[cnt])); 4168 } 4169 return ret; 4170 }, 4171 4172 _outerHTMLCompliant: function(item, markup) { 4173 //table element replacements like thead, tbody etc... have to be treated differently 4174 var evalNodes = this._buildEvalNodes(item, markup); 4175 4176 if (evalNodes.length == 1) { 4177 var ret = evalNodes[0]; 4178 item.parentNode.replaceChild(ret, item); 4179 return ret; 4180 } else { 4181 return this.replaceElements(item, evalNodes); 4182 } 4183 }, 4184 4185 /** 4186 * checks if the provided element is a subelement of a table element 4187 * @param item 4188 */ 4189 _isTableElement: function(item) { 4190 return !!this.TABLE_ELEMS[(item.nodeName || item.tagName).toLowerCase()]; 4191 }, 4192 4193 /** 4194 * non ie browsers do not have problems with embedded scripts or any other construct 4195 * we simply can use an innerHTML in a placeholder 4196 * 4197 * @param markup the markup to be used 4198 */ 4199 _buildNodesCompliant: function(markup) { 4200 var dummyPlaceHolder = this.getDummyPlaceHolder(); //document.createElement("div"); 4201 dummyPlaceHolder.innerHTML = markup; 4202 return this._Lang.objToArray(dummyPlaceHolder.childNodes); 4203 }, 4204 4205 4206 4207 4208 /** 4209 * builds up a correct dom subtree 4210 * if the markup is part of table nodes 4211 * The usecase for this is to allow subtable rendering 4212 * like single rows thead or tbody 4213 * 4214 * @param item 4215 * @param markup 4216 */ 4217 _buildTableNodes: function(item, markup) { 4218 var itemNodeName = (item.nodeName || item.tagName).toLowerCase(); 4219 4220 var tmpNodeName = itemNodeName; 4221 var depth = 0; 4222 while (tmpNodeName != "table") { 4223 item = item.parentNode; 4224 tmpNodeName = (item.nodeName || item.tagName).toLowerCase(); 4225 depth++; 4226 } 4227 4228 var dummyPlaceHolder = this.getDummyPlaceHolder(); 4229 if (itemNodeName == "td") { 4230 dummyPlaceHolder.innerHTML = "<table><tbody><tr>" + markup + "</tr></tbody></table>"; 4231 } else { 4232 dummyPlaceHolder.innerHTML = "<table>" + markup + "</table>"; 4233 } 4234 4235 for (var cnt = 0; cnt < depth; cnt++) { 4236 dummyPlaceHolder = dummyPlaceHolder.childNodes[0]; 4237 } 4238 4239 return this.detach(dummyPlaceHolder.childNodes); 4240 }, 4241 4242 _removeChildNodes: function(node /*, breakEventsOpen */) { 4243 if (!node) return; 4244 node.innerHTML = ""; 4245 }, 4246 4247 4248 4249 _removeNode: function(node /*, breakEventsOpen*/) { 4250 if (!node) return; 4251 var parentNode = node.parentNode; 4252 if (parentNode) //if the node has a parent 4253 parentNode.removeChild(node); 4254 }, 4255 4256 4257 /** 4258 * build up the nodes from html markup in a browser independend way 4259 * so that it also works with table nodes 4260 * 4261 * @param item the parent item upon the nodes need to be processed upon after building 4262 * @param markup the markup to be built up 4263 */ 4264 _buildEvalNodes: function(item, markup) { 4265 var evalNodes = null; 4266 if (this._isTableElement(item)) { 4267 evalNodes = this._buildTableNodes(item, markup); 4268 } else { 4269 var nonIEQuirks = (!this._RT.browser.isIE || this._RT.browser.isIE > 8); 4270 //ie8 has a special problem it still has the swallow scripts and other 4271 //elements bug, but it is mostly dom compliant so we have to give it a special 4272 //treatment, IE9 finally fixes that issue finally after 10 years 4273 evalNodes = (this.isDomCompliant() && nonIEQuirks) ? 4274 this._buildNodesCompliant(markup) : 4275 //ie8 or quirks mode browsers 4276 this._buildNodesNonCompliant(markup); 4277 } 4278 return evalNodes; 4279 }, 4280 4281 /** 4282 * we have lots of methods with just an item and a markup as params 4283 * this method builds an assertion for those methods to reduce code 4284 * 4285 * @param item the item to be tested 4286 * @param markup the markup 4287 * @param caller caller function 4288 * @param {optional} params array of assertion param names 4289 */ 4290 _assertStdParams: function(item, markup, caller, params) { 4291 //internal error 4292 if (!caller) { 4293 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "_assertStdParams", "Caller must be set for assertion"); 4294 } 4295 var _Lang = this._Lang, 4296 ERR_PROV = "ERR_MUST_BE_PROVIDED1", 4297 DOM = "myfaces._impl._util._Dom.", 4298 finalParams = params || ["item", "markup"]; 4299 4300 if (!item || !markup) { 4301 _Lang.makeException(new Error(), null, null,DOM, ""+caller, _Lang.getMe
4301ssage(ERR_PROV, null, DOM +"."+ caller, (!item) ? finalParams[0] : finalParams[1])); 4302 //throw Error(_Lang.getMessage(ERR_PROV, null, DOM + caller, (!item) ? params[0] : params[1])); 4303 } 4304 }, 4305 4306 /** 4307 * internal eval handler used by various functions 4308 * @param _nodeArr 4309 */ 4310 _eval: function(_nodeArr) { 4311 if (this.isManualScriptEval()) { 4312 var isArr = _nodeArr instanceof Array; 4313 if (isArr && _nodeArr.length) { 4314 for (var cnt = 0; cnt < _nodeArr.length; cnt++) { 4315 this.runScripts(_nodeArr[cnt]); 4316 } 4317 } else if (!isArr) { 4318 this.runScripts(_nodeArr); 4319 } 4320 } 4321 }, 4322 4323 /** 4324 * for performance reasons we work with replaceElement and replaceElements here 4325 * after measuring performance it has shown that passing down an array instead 4326 * of a single node makes replaceElement twice as slow, however 4327 * a single node case is the 95% case 4328 * 4329 * @param item 4330 * @param evalNode 4331 */ 4332 replaceElement: function(item, evalNode) { 4333 //browsers with defect garbage collection 4334 item.parentNode.insertBefore(evalNode, item); 4335 this._removeNode(item, false); 4336 }, 4337 4338 4339 /** 4340 * replaces an element with another element or a set of elements 4341 * 4342 * @param item the item to be replaced 4343 * 4344 * @param evalNodes the elements 4345 */ 4346 replaceElements: function (item, evalNodes) { 4347 var evalNodesDefined = evalNodes && 'undefined' != typeof evalNodes.length; 4348 if (!evalNodesDefined) { 4349 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "replaceElements", this._Lang.getMessage("ERR_REPLACE_EL")); 4350 } 4351 4352 var parentNode = item.parentNode, 4353 4354 sibling = item.nextSibling, 4355 resultArr = this._Lang.objToArray(evalNodes); 4356 4357 for (var cnt = 0; cnt < resultArr.length; cnt++) { 4358 if (cnt == 0) { 4359 this.replaceElement(item, resultArr[cnt]); 4360 } else { 4361 if (sibling) { 4362 parentNode.insertBefore(resultArr[cnt], sibling); 4363 } else { 4364 parentNode.appendChild(resultArr[cnt]); 4365 } 4366 } 4367 } 4368 return resultArr; 4369 }, 4370 4371 /** 4372 * optimized search for an array of tag names 4373 * deep scan will always be performed. 4374 * @param fragment the fragment which should be searched for 4375 * @param tagNames an map indx of tag names which have to be found 4376 * 4377 */ 4378 findByTagNames: function(fragment, tagNames) { 4379 this._assertStdParams(fragment, tagNames, "findByTagNames", ["fragment", "tagNames"]); 4380 4381 var nodeType = fragment.nodeType; 4382 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4383 4384 //we can use the shortcut 4385 if (fragment.querySelectorAll) { 4386 var query = []; 4387 for (var key in tagNames) { 4388 if(!tagNames.hasOwnProperty(key)) continue; 4389 query.push(key); 4390 } 4391 var res = []; 4392 if (fragment.tagName && tagNames[fragment.tagName.toLowerCase()]) { 4393 res.push(fragment); 4394 } 4395 return res.concat(this._Lang.objToArray(fragment.querySelectorAll(query.join(", ")))); 4396 } 4397 4398 //now the filter function checks case insensitively for the tag names needed 4399 var filter = function(node) { 4400 return node.tagName && tagNames[node.tagName.toLowerCase()]; 4401 }; 4402 4403 //now we run an optimized find all on it 4404 try { 4405 return this.findAll(fragment, filter, true); 4406 } finally { 4407 //the usual IE6 is broken, fix code 4408 filter = null; 4409 } 4410 }, 4411 4412 /** 4413 * determines the number of nodes according to their tagType 4414 * 4415 * @param {Node} fragment (Node or fragment) the fragment to be investigated 4416 * @param {String} tagName the tag name (lowercase) 4417 * (the normal usecase is false, which means if the element is found only its 4418 * adjacent elements will be scanned, due to the recursive descension 4419 * this should work out with elements with different nesting depths but not being 4420 * parent and child to each other 4421 * 4422 * @return the child elements as array or null if nothing is found 4423 * 4424 */ 4425 findByTagName : function(fragment, tagName) { 4426 this._assertStdParams(fragment, tagName, "findByTagName", ["fragment", "tagName"]); 4427 var _Lang = this._Lang, 4428 nodeType = fragment.nodeType; 4429 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4430 4431 //remapping to save a few bytes 4432 4433 var ret = _Lang.objToArray(fragment.getElementsByTagName(tagName)); 4434 if (fragment.tagName && _Lang.equalsIgnoreCase(fragment.tagName, tagName)) ret.unshift(fragment); 4435 return ret; 4436 }, 4437 4438 findByName : function(fragment, name) { 4439 this._assertStdParams(fragment, name, "findByName", ["fragment", "name"]); 4440 4441 var nodeType = fragment.nodeType; 4442 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4443 4444 var ret = this._Lang.objToArray(fragment.getElementsByName(name)); 4445 if (fragment.name == name) ret.unshift(fragment); 4446 return ret; 4447 }, 4448 4449 /** 4450 * a filtered findAll for subdom treewalking 4451 * (which uses browser optimizations wherever possible) 4452 * 4453 * @param {|Node|} rootNode the rootNode so start the scan 4454 * @param filter filter closure with the syntax {boolean} filter({Node} node) 4455 * @param deepScan if set to true or not set at all a deep scan is performed (for form scans it does not make much sense to deeply scan) 4456 */ 4457 findAll : function(rootNode, filter, deepScan) { 4458 this._Lang.assertType(filter, "function"); 4459 deepScan = !!deepScan; 4460 4461 if (document.createTreeWalker && NodeFilter) { 4462 return this._iteratorSearchAll(rootNode, filter, deepScan); 4463 } else { 4464 //will not be called in dom level3 compliant browsers 4465 return this._recursionSearchAll(rootNode, filter, deepScan); 4466 } 4467 }, 4468 4469 /** 4470 * the faster dom iterator based search, works on all newer browsers 4471 * except ie8 which already have implemented the dom iterator functions 4472 * of html 5 (which is pretty all standard compliant browsers) 4473 * 4474 * The advantage of this method is a faster tree iteration compared 4475 * to the normal recursive tree walking. 4476 * 4477 * @param rootNode the root node to be iterated over 4478 * @param filter the iteration filter 4479 * @param deepScan if set to true a deep scan is performed 4480 */ 4481 _iteratorSearchAll: function(rootNode, filter, deepScan) { 4482 var retVal = []; 4483 //Works on firefox and webkit, opera and ie have to use the slower fallback mechanis 4484 //we have a tree walker in place this allows for an optimized deep scan 4485 if (filter(rootNode)) { 4486 4487 retVal.push(rootNode); 4488 if (!deepScan) { 4489 return retVal; 4490 } 4491 } 4492 //we use the reject mechanism to prevent a deep scan reject means any 4493 //child elements will be omitted from the scan 4494 var FILTER_ACCEPT = NodeFilter.FILTER_ACCEPT, 4495 FILTER_SKIP = NodeFilter.FILTER_SKIP, 4496 FILTER_REJECT = NodeFilter.FILTER_REJECT; 4497 4498 var walkerFilter = function (node) { 4499 var retCode = (filter(node)) ? FILTER_ACCEPT : FILTER_SKIP; 4500 retCode = (!deepScan && retCode == FILTER_ACCEPT) ? FILTER_REJECT : retCode; 4501 if (retCode == FILTER_ACCEPT || retCode == FILTER_REJECT) { 4502 retVal.push(node); 4503 } 4504 return retCode; 4505 }; 4506 4507 var treeWalker = document.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT, walkerFilter, false); 4508 //noinspection StatementWithEmptyBodyJS 4509 while (treeWalker.nextNode()); 4510 return retVal; 4511 }, 4512 4513 /** 4514 * bugfixing for ie6 which does not cope properly with setAttribute 4515 */ 4516 setAttribute : function(node, attr, val) { 4517 this._assertStdParams(node, attr, "setAttribute", ["fragment", "name"]); 4518 if (!node.setAttribute) { 4519 return; 4520 } 4521 4522 if (attr === 'disabled') { 4523 node.disabled = val === 'disabled' || val === 'true'; 4524 } else if (attr === 'checked') { 4525 node.checked = val === 'checked' || val === 'on' || val === 'true'; 4526 } else if (attr == 'readonly') { 4527 node.readOnly = val === 'readonly' || val === 'true'; 4528 } else { 4529 node.setAttribute(attr, val); 4530 } 4531 }, 4532 4533 /** 4534 * fuzzy form detection which tries to determine the form 4535 * an item has been detached. 4536 * 4537 * The problem is some Javascript libraries simply try to 4538 * detach controls by reusing the names 4539 * of the detached input controls. Most of the times, 4540 * the name is unique in a jsf scenario, due to the inherent form mapping. 4541 * One way or the other, we will try to fix that by 4542 * identifying the proper form over the name 4543 * 4544 * We do it in several ways, in case of no form null is returned 4545 * in case of multiple forms we check all elements with a given name (which we determine 4546 * out of a name or id of the detached element) and then iterate over them 4547 * to find whether they are in a form or not. 4548 * 4549 * If only one element within a form and a given identifier found then we can pull out 4550 * and move on 4551 * 4552 * We cannot do much further because in case of two identical named elements 4553 * all checks must fail and the first elements form is served. 4554 * 4555 * Note, this method is only triggered in case of the issuer or an ajax request 4556 * is a detached element, otherwise already existing code has served the correct form. 4557 * 4558 * This method was added because of 4559 * https://issues.apache.org/jira/browse/MYFACES-2599 4560 * to support the integration of existing ajax libraries which do heavy dom manipulation on the 4561 * controls side (Dojos Dijit library for instance). 4562 * 4563 * @param {Node} elem - element as source, can be detached, undefined or null 4564 * 4565 * @return either null or a form node if it could be determined 4566 * 4567 * TODO move this into extended and replace it with a simpler algorithm 4568 */ 4569 fuzzyFormDetection : function(elem) { 4570 var forms = document.forms, _Lang = this._Lang; 4571 4572 if (!forms || !forms.length) { 4573 return null; 4574 } 4575 4576 // This will not work well on portlet case, because we cannot be sure 4577 // the returned form is right one. 4578 //we can cover that case by simply adding one of our config params 4579 //the default is the weaker, but more correct portlet code 4580 //you can override it with myfaces_config.no_portlet_env = true globally 4581 else if (1 == forms.length && this._RT.getGlobalConfig("no_portlet_env", false)) { 4582 return forms[0]; 4583 } 4584 4585 //before going into the more complicated stuff we try the simple approach 4586 var finalElem = this.byId(elem); 4587 var fetchForm = _Lang.hitch(this, function(elem) { 4588 //element of type form then we are already 4589 //at form level for the issuing element 4590 //https://issues.apache.org/jira/browse/MYFACES-2793 4591 4592 return (_Lang.equalsIgnoreCase(elem.tagName, "form")) ? elem : 4593 ( this.html5FormDetection(elem) || this.getParent(elem, "form")); 4594 }); 4595 4596 if (finalElem) { 4597 var elemForm = fetchForm(finalElem); 4598 if (elemForm) return elemForm; 4599 } 4600 4601 /** 4602 * name check 4603 */ 4604 var foundElements = []; 4605 var name = (_Lang.isString(elem)) ? elem : elem.name; 4606 //id detection did not work 4607 if (!name) return null; 4608 /** 4609 * the lesser chance is the elements which have the same name 4610 * (which is the more likely case in case of a brute dom replacement) 4611 */ 4612 var nameElems = document.getElementsByName(name); 4613 if (nameElems) { 4614 for (var cnt = 0;
4614 cnt < nameElems.length && foundElements.length < 2; cnt++) { 4615 // we already have covered the identifier case hence we only can deal with names, 4616 var foundForm = fetchForm(nameElems[cnt]); 4617 if (foundForm) { 4618 foundElements.push(foundForm); 4619 } 4620 } 4621 } 4622 4623 return (1 == foundElements.length ) ? foundElements[0] : null; 4624 }, 4625 4626 html5FormDetection: function(/*item*/) { 4627 return null; 4628 }, 4629 4630 4631 /** 4632 * gets a parent of an item with a given tagname 4633 * @param {Node} item - child element 4634 * @param {String} tagName - TagName of parent element 4635 */ 4636 getParent : function(item, tagName) { 4637 4638 if (!item) { 4639 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "getParent", 4640 this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}")); 4641 } 4642 4643 var _Lang = this._Lang; 4644 var searchClosure = function(parentItem) { 4645 return parentItem && parentItem.tagName 4646 && _Lang.equalsIgnoreCase(parentItem.tagName, tagName); 4647 }; 4648 try { 4649 return this.getFilteredParent(item, searchClosure); 4650 } finally { 4651 searchClosure = null; 4652 _Lang = null; 4653 } 4654 }, 4655 4656 /** 4657 * A parent walker which uses 4658 * a filter closure for filtering 4659 * 4660 * @param {Node} item the root item to ascend from 4661 * @param {function} filter the filter closure 4662 */ 4663 getFilteredParent : function(item, filter) { 4664 this._assertStdParams(item, filter, "getFilteredParent", ["item", "filter"]); 4665 4666 //search parent tag parentName 4667 var parentItem = (item.parentNode) ? item.parentNode : null; 4668 4669 while (parentItem && !filter(parentItem)) { 4670 parentItem = parentItem.parentNode; 4671 } 4672 return (parentItem) ? parentItem : null; 4673 }, 4674 4675 /** 4676 * cross ported from dojo 4677 * fetches an attribute from a node 4678 * 4679 * @param {String} node the node 4680 * @param {String} attr the attribute 4681 * @return the attributes value or null 4682 */ 4683 getAttribute : function(/* HTMLElement */node, /* string */attr) { 4684 return node.getAttribute(attr); 4685 }, 4686 4687 /** 4688 * checks whether the given node has an attribute attached 4689 * 4690 * @param {String|Object} node the node to search for 4691 * @param {String} attr the attribute to search for 4692 * @true if the attribute was found 4693 */ 4694 hasAttribute : function(/* HTMLElement */node, /* string */attr) { 4695 // summary 4696 // Determines whether or not the specified node carries a value for the attribute in question. 4697 return this.getAttribute(node, attr) ? true : false; // boolean 4698 }, 4699 4700 /** 4701 * concatenation routine which concats all childnodes of a node which 4702 * contains a set of CDATA blocks to one big string 4703 * @param {Node} node the node to concat its blocks for 4704 */ 4705 concatCDATABlocks : function(/*Node*/ node) { 4706 var cDataBlock = []; 4707 // response may contain several blocks 4708 for (var i = 0; i < node.childNodes.length; i++) { 4709 cDataBlock.push(node.childNodes[i].data); 4710 } 4711 return cDataBlock.join(''); 4712 }, 4713 4714 //all modern browsers evaluate the scripts 4715 //manually this is a w3d recommendation 4716 isManualScriptEval: function() { 4717 return true; 4718 }, 4719 4720 /** 4721 * jsf2.2 4722 * checks if there is a fileupload element within 4723 * the executes list 4724 * 4725 * @param executes the executes list 4726 * @return {Boolean} true if there is a fileupload element 4727 */ 4728 isMultipartCandidate:function (executes) { 4729 if (this._Lang.isString(executes)) { 4730 executes = this._Lang.strToArray(executes, /\s+/); 4731 } 4732 4733 for (var cnt = 0, len = executes.length; cnt < len ; cnt ++) { 4734 var element = this.byId(executes[cnt]); 4735 var inputs = this.findByTagName(element, "input", true); 4736 for (var cnt2 = 0, len2 = inputs.length; cnt2 < len2 ; cnt2++) { 4737 if (this.getAttribute(inputs[cnt2], "type") == "file") return true; 4738 } 4739 } 4740 return false;
4741 }, 4742 4743 insertFirst: function(newNode) { 4744 var body = document.body; 4745 if (body.childNodes.length > 0) { 4746 body.insertBefore(newNode, body.firstChild); 4747 } else { 4748 body.appendChild(newNode); 4749 } 4750 }, 4751 4752 byId: function(id) { 4753 return this._Lang.byId(id); 4754 }, 4755 4756 getDummyPlaceHolder: function() { 4757 this._dummyPlaceHolder = this._dummyPlaceHolder ||this.createElement("div"); 4758 return this._dummyPlaceHolder; 4759 }, 4760 4761 getNamedElementFromForm: function(form, elementId) { 4762 return form[elementId]; 4763 } 4764}); 4765 4766 4767 4768/* Licensed to the Apache Software Foundation (ASF) under one or more 4769 * contributor license agreements. See the NOTICE file distributed with 4770 * this work for additional information regarding copyright ownership. 4771 * The ASF licenses this file to you under the Apache License, Version 2.0 4772 * (the "License"); you may not use this file except in compliance with 4773 * the License. You may obtain a copy of the License at 4774 * 4775 * http://www.apache.org/licenses/LICENSE-2.0 4776 * 4777 * Unless required by applicable law or agreed to in writing, software 4778 * distributed under the License is distributed on an "AS IS" BASIS, 4779 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4780 * See the License for the specific language governing permissions and 4781 * limitations under the License. 4782 */ 4783if (_MF_SINGLTN) { 4784 _MF_SINGLTN(_PFX_UTIL + "_DomExperimental", myfaces._impl._util._Dom, /** @lends myfaces._impl._util._Dom.prototype */ { 4785 constructor_:function () { 4786 this._callSuper("constructor_"); 4787 myfaces._impl._util._Dom = this; 4788 }, 4789 4790 html5FormDetection:function (item) { 4791 var browser = this._RT.browser; 4792 //ie shortcut, not really needed but speeds things up 4793 if (browser.isIEMobile && browser.isIEMobile <= 8) { 4794 return null; 4795 } 4796 var elemForm = this.getAttribute(item, "form"); 4797 return (elemForm) ? this.byId(elemForm) : null; 4798 }, 4799 4800 getNamedElementFromForm: function(form, elementId) { 4801 return form[elementId]; 4802 } 4803 }); 4804} 4805 4806/* Licensed to the Apache Software Foundation (ASF) under one or more 4807 * contributor license agreements. See the NOTICE file distributed with 4808 * this work for additional information regarding copyright ownership. 4809 * The ASF licenses this file to you under the Apache License, Version 2.0 4810 * (the "License"); you may not use this file except in compliance with 4811 * the License. You may obtain a copy of the License at 4812 * 4813 * http://www.apache.org/licenses/LICENSE-2.0 4814 * 4815 * Unless required by applicable law or agreed to in writing, software 4816 * distributed under the License is distributed on an "AS IS" BASIS, 4817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4818 * See the License for the specific language governing permissions and 4819 * limitations under the License. 4820 */ 4821if (_MF_SINGLTN) { 4822 /*** 4823 Dom.js version for non html5 browsers 4824 */ 4825 _MF_SINGLTN(_PFX_UTIL + "DomQuirks", myfaces._impl._util._Dom, /** @lends myfaces._impl._util._DomQuirks.prototype */ { 4826 4827 IE_QUIRKS_EVENTS:{ 4828 "onabort":true, 4829 "onload":true, 4830 "onunload":true, 4831 "onchange":true, 4832 "onsubmit":true, 4833 "onreset":true, 4834 "onselect":true, 4835 "onblur":true, 4836 "onfocus":true, 4837 "onkeydown":true, 4838 "onkeypress":true, 4839 "onkeyup":true, 4840 "onclick":true, 4841 "ondblclick":true, 4842 "onmousedown":true, 4843 "onmousemove":true, 4844 "onmouseout":true, 4845 "onmouseover":true, 4846 "onmouseup":true 4847 }, 4848 4849 constructor_:function () { 4850 4851 var b = myfaces._impl.core._Runtime.browser; 4852 4853 if (b.isIEMobile && b.isIE <= 6) { 4854 //winmobile hates add onLoad, and checks on the construct 4855 //it does not eval scripts anyway 4856 myfaces.config = myfaces.config || {}; 4857 myfaces.config._autoeval = false;
4858 return; 4859 } else { 4860 //for whatever reason autoeval is set here on Firefox 3.5 only 4861 // could be a firebug problem, by setting setters 4862 //and getters no assignment was revealed. 4863 if ('undefined' != typeof myfaces.config && 'undefined' != typeof myfaces.config._autoeval) { 4864 delete myfaces.config._autoeval; 4865 } 4866 } 4867 this._callSuper("constructor_"); 4868 myfaces._impl._util._Dom = this; 4869 4870 var _Lang = this._Lang; 4871 //by w3c spec the script eval is turned off it is only 4872 //on on legacy browsers 4873 var scriptEval = _Lang.hitch(this, this.isManualScriptEval); 4874 4875 if (window) { 4876 this._RT.addOnLoad(window, scriptEval); 4877 } 4878 //safety fallback if the window onload handler is overwritten and not chained 4879 if (document.body) { 4880 this._RT.addOnLoad(document.body, scriptEval); 4881 } 4882 4883 //we register ourselves into the existing classes lazily 4884 var _T = this; 4885 if (myfaces._impl.core.Impl) { 4886 this._RT.iterateClasses(function (proto) { 4887 if (proto._Dom) proto._Dom = _T; 4888 }); 4889 } 4890 }, 4891 4892 /** 4893 * Checks whether the browser is dom compliant. 4894 * Dom compliant means that it performs the basic dom operations safely 4895 * without leaking and also is able to perform a native setAttribute 4896 * operation without freaking out 4897 * 4898 * 4899 * Not dom compliant browsers are all microsoft browsers in quirks mode 4900 * and ie6 and ie7 to some degree in standards mode 4901 * and pretty much every browser who cannot create ranges 4902 * (older mobile browsers etc...) 4903 * 4904 * We dont do a full browser detection here because it probably is safer 4905 * to test for existing features to make an assumption about the 4906 * browsers capabilities 4907 */ 4908 isDomCompliant:function () { 4909 if ('undefined' == typeof this._isCompliantBrowser) { 4910 this._isCompliantBrowser = !!((window.Range 4911 && typeof Range.prototype.createContextualFragment == 'function') 4912 //createContextualFragment hints to a no quirks browser but we need more fallbacks 4913 || document.querySelectoryAll //query selector all hints to html5 capabilities 4914 || document.createTreeWalker); //treewalker is either firefox 3.5+ or ie9 standards mode 4915 } 4916 return this._isCompliantBrowser; 4917 }, 4918 4919 /** 4920 * now to the evil browsers 4921 * of what we are dealing with is various bugs 4922 * first a simple replaceElement leaks memory 4923 * secondly embedded scripts can be swallowed upon 4924 * innerHTML, we probably could also use direct outerHTML 4925 * but then we would run into the script swallow bug 4926 * 4927 * the entire mess is called IE6 and IE7 4928 * 4929 * @param item 4930 * @param markup 4931 */ 4932 _outerHTMLNonCompliant:function (item, markup) { 4933 4934 var b = this._RT.browser; 4935 4936 try { 4937 //check for a subtable rendering case 4938 4939 var evalNodes = this._buildEvalNodes(item, markup); 4940 4941 if (evalNodes.length == 1) { 4942 var ret = evalNodes[0]; 4943 this.replaceElement(item, evalNodes[0]); 4944 return ret; 4945 } else { 4946 return this.replaceElements(item, evalNodes); 4947 } 4948 4949 } finally { 4950 4951 var dummyPlaceHolder = this.getDummyPlaceHolder(); 4952 //now that Microsoft has finally given 4953 //ie a working gc in 8 we can skip the costly operation 4954 if (b.isIE && b.isIE < 8) { 4955 this._removeChildNodes(dummyPlaceHolder, false); 4956 } 4957 dummyPlaceHolder.innerHTML = ""; 4958 } 4959 4960 }, 4961 4962 replaceElement:function (item, evalNode) { 4963 4964 var _Browser = this._RT.browser; 4965 if (!_Browser.isIE || _Browser.isIE >= 8) { 4966 //standards conform no leaking browser 4967 item.parentNode.replaceChild(evalNode, item); 4968 } else { 4969 this._callSuper("replaceElement", item, evalNode); 4970 } 4971 }, 4972 4973 /** 4974 * builds the ie nodes properly in a placeholder 4975 * and bypasses a non script insert bug that way 4976 * @param markup the marku code 4977 */ 4978 _buildNodesNonCompliant:function (markup) { 4979 4980 //now to the non w3c compliant browsers 4981 //http://blogs.perl.org/users/clinton_gormley/2010/02/forcing-ie-to-accept-script-tags-in-innerhtml.html 4982 //we have to cope with deficiencies between ie and its simulations in this case 4983 var probe = this.getDummyPlaceHolder();//document.createElement("div"); 4984 4985 probe.innerHTML = "<table><tbody><tr><td><div></div></td></tr></tbody></table>"; 4986 4987 //we have customers using html unit, this has a bug in the table resolution 4988 //hence we determine the depth dynamically 4989 var depth = this._determineDepth(probe); 4990 4991 this._removeChildNodes(probe, false); 4992 probe.innerHTML = ""; 4993 4994 var dummyPlaceHolder = this.getDummyPlaceHolder();//document.createElement("div"); 4995 4996 //fortunately a table element also works which is less critical than form elements regarding 4997 //the inner content 4998 dummyPlaceHolder.innerHTML = "<table><tbody><tr><td>" + markup + "</td></tr></tbody></table>"; 4999 var evalNodes = dummyPlaceHolder; 5000 5001 for (var cnt = 0; cnt < depth; cnt++) { 5002 evalNodes = evalNodes.childNodes[0]; 5003 } 5004 var ret = (evalNodes.parentNode) ? this.detach(evalNodes.parentNode.childNodes) : null; 5005 5006 if ('undefined' == typeof evalNodes || null == evalNodes) { 5007 //fallback for htmlunit which should be good enough 5008 //to run the tests, maybe we have to wrap it as well 5009 dummyPlaceHolder.innerHTML = "<div>" + markup + "</div>"; 5010 //note this is triggered only in htmlunit no other browser 5011 //so we are save here 5012 //TODO Fix this (probaby ret is needed here, check the history) 5013 evalNodes = this.detach(dummyPlaceHolder.childNodes[0].childNodes); 5014 } 5015 5016 this._removeChildNodes(dummyPlaceHolder, false); 5017 //ie fix any version, ie does not return true javascript arrays so we have to perform 5018 //a cross conversion 5019 return ret; 5020 5021 }, 5022 5023 _determineDepth:function (probe) { 5024 var depth = 0; 5025 var newProbe = probe; 5026 for (; newProbe && 5027 newProbe.childNodes && 5028 newProbe.childNodes.length && 5029 newProbe.nodeType == 1; depth++) { 5030 newProbe = newProbe.childNodes[0]; 5031 } 5032 return depth; 5033 }, 5034 5035 //now to another nasty issue: 5036 //for ie we have to walk recursively over all nodes:
5037 //http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx 5038 //http://weblogs.java.net/blog/driscoll/archive/2009/11/13/ie-memory-management-and-you 5039 //http://home.orange.nl/jsrosman/ 5040 //http://www.quirksmode.org/blog/archives/2005/10/memory_leaks_li.html 5041 //http://www.josh-davis.org/node/7 5042 _removeNode:function (node, breakEventsOpen) { 5043 if (!node) return; 5044 var b = this._RT.browser; 5045 if (this.isDomCompliant()) { 5046 //recursive descension only needed for old ie versions 5047 //all newer browsers cleanup the garbage just fine without it 5048 //thank you 5049 if ('undefined' != typeof node.parentNode && null != node.parentNode) //if the node has a parent 5050 node.parentNode.removeChild(node); 5051 return; 5052 } 5053 5054 //now to the browsers with non working garbage collection 5055 this._removeChildNodes(node, breakEventsOpen); 5056 5057 try { 5058 //outer HTML setting is only possible in earlier IE versions all modern browsers throw an exception here 5059 //again to speed things up we precheck first 5060 if (!this._isTableElement(node)) { 5061 //we do not do a table structure innnerhtml on table elements except td 5062 //htmlunit rightfully complains that we should not do it 5063 node.innerHTML = ""; 5064 } 5065 if (b.isIE && 'undefined' != typeof node.outerHTML) {//ie8+ check done earlier we skip it here 5066 node.outerHTML = ''; 5067 } else { 5068 node = this.detach(node)[0]; 5069 } 5070 if (!b.isIEMobile) { 5071 delete node; 5072 } 5073 } catch (e) { 5074 //on some elements we might not have covered by our table check on the outerHTML 5075 // can fail we skip those in favor of stability 5076 try { 5077 // both innerHTML and outerHTML fails when <tr> is the node, but in that case 5078 // we need to force node removal, otherwise it will be on the tree (IE 7 IE 6) 5079 this.detach(node); 5080 if (!b.isIEMobile) { 5081 delete node; 5082 } 5083 } catch (e1) { 5084 } 5085 } 5086 }, 5087 5088 /** 5089 * recursive delete child nodes 5090 * node, this method only makes sense in the context of IE6 + 7 hence 5091 * it is not exposed to the public API, modern browsers 5092 * can garbage collect the nodes just fine by doing the standard removeNode method 5093 * from the dom API! 5094 * 5095 * @param node the node from which the childnodes have to be deletd 5096 * @param breakEventsOpen if set to true a standard events breaking is performed 5097 */ 5098 _removeChildNodes:function (node, breakEventsOpen) { 5099 if (!node) return; 5100 5101 //node types which cannot be cleared up by normal means 5102 var disallowedNodes = this.TABLE_ELEMS; 5103 5104 //for now we do not enable it due to speed reasons 5105 //normally the framework has to do some event detection 5106 //which we cannot do yet, I will dig for options 5107 //to enable it in a speedly manner 5108 //ie7 fixes this area anyway 5109 //this.breakEvents(node); 5110 5111 var b = this._RT.browser; 5112 if (breakEventsOpen) { 5113 this.breakEvents(node); 5114 } 5115 5116 for (var cnt = node.childNodes.length - 1; cnt >= 0; cnt -= 1) { 5117 var childNode = node.childNodes[cnt]; 5118 //we cannot use our generic recursive tree walking due to the needed head recursion 5119 //to clean it up bottom up, the tail recursion we were using in the search either would use more time 5120 //because we had to walk and then clean bottom up, so we are going for a direct head recusion here 5121 if ('undefined' != typeof childNode.childNodes && node.childNodes.length) 5122 this._removeChildNodes(childNode); 5123 try { 5124 var nodeName = (childNode.nodeName || childNode.tagName) ? (childNode.nodeName || childNode.tagName).toLowerCase() : null; 5125 //ie chokes on clearing out table inner elements, this is also covered by our empty 5126 //catch block, but to speed things up it makes more sense to precheck that 5127 if (!disallowedNodes[nodeName]) { 5128 //outer HTML setting is only possible in earlier IE versions all modern browsers throw an exception here 5129 //again to speed things up we precheck first 5130 if (!this._isTableElement(childNode)) { //table elements cannot be deleted 5131 childNode.innerHTML = ""; 5132 } 5133 if (b.isIE && b.isIE < 8 && 'undefined' != typeof childNode.outerHTML) { 5134 childNode.outerHTML = ''; 5135 } else { 5136 node.removeChild(childNode); 5137 } 5138 if (!b.isIEMobile) { 5139 delete childNode; 5140 } 5141 } 5142 } catch (e) { 5143 //on some elements the outerHTML can fail we skip those in favor 5144 //of stability 5145 5146 } 5147 } 5148 }, 5149 /** 5150 * cross ported from dojo 5151 * fetches an attribute from a node 5152 * 5153 * @param {String}
5153 node the node 5154 * @param {String} attr the attribute 5155 * @return the attributes value or null 5156 */ 5157 getAttribute:function (/* HTMLElement */node, /* string */attr) { 5158 // summary 5159 // Returns the value of attribute attr from node. 5160 node = this.byId(node); 5161 // FIXME: need to add support for attr-specific accessors 5162 if ((!node) || (!node.getAttribute)) { 5163 // if(attr !== 'nwType'){ 5164 // alert("getAttr of '" + attr + "' with bad node"); 5165 // } 5166 return null; 5167 } 5168 var ta = typeof attr == 'string' ? attr : new String(attr); 5169 5170 // first try the approach most likely to succeed 5171 var v = node.getAttribute(ta.toUpperCase()); 5172 if ((v) && (typeof v == 'string') && (v != "")) { 5173 return v; // string 5174 } 5175 5176 // try returning the attributes value, if we couldn't get it as a string 5177 if (v && v.value) { 5178 return v.value; // string 5179 } 5180 5181 // this should work on Opera 7, but it's a little on the crashy side 5182 if ((node.getAttributeNode) && (node.getAttributeNode(ta))) { 5183 return (node.getAttributeNode(ta)).value; // string 5184 } else if (node.getAttribute(ta)) { 5185 return node.getAttribute(ta); // string 5186 } else if (node.getAttribute(ta.toLowerCase())) { 5187 return node.getAttribute(ta.toLowerCase()); // string 5188 } 5189 return null; // string 5190 }, 5191 5192 /** 5193 * bugfixing for ie6 which does not cope properly with setAttribute 5194 */ 5195 setAttribute:function (node, attr, val) { 5196 5197 this._assertStdParams(node, attr, "setAttribute"); 5198 5199 //quirks mode and ie7 mode has the attributes problems ie8 standards mode behaves like 5200 //a good citizen 5201 var _Browser = this._RT.browser; 5202 //in case of ie > ie7 we have to check for a quirks mode setting 5203 if (!_Browser.isIE || _Browser.isIE > 7 && this.isDomCompliant()) { 5204 this._callSuper("setAttribute", node, attr, val); 5205 return; 5206 } 5207 5208 /* 5209 Now to the broken browsers IE6+.... ie7 and ie8 quirks mode 5210 5211 we deal mainly with three problems here 5212 class and for are not handled correctly 5213 styles are arrays and cannot be set directly 5214 and javascript events cannot be set via setAttribute as well! 5215 5216 or in original words of quirksmode.org ... this is a mess! 5217 5218 Btw. thank you Microsoft for providing all necessary tools for free 5219 for being able to debug this entire mess in the ie rendering engine out 5220 (which is the Microsoft ie vms, developers toolbar, Visual Web Developer 2008 express 5221 and the ie8 8 developers toolset!) 5222 5223 also thank you http://www.quirksmode.org/ 5224 dojotoolkit.org and //http://delete.me.uk/2004/09/ieproto.html 5225 for additional information on this mess! 5226 5227 The lowest common denominator tested within this code 5228 is IE6, older browsers for now are legacy! 5229 */ 5230 attr = attr.toLowerCase(); 5231 5232 if (attr === "class") { 5233 //setAttribute does not work for winmobile browsers 5234 //firect calls work 5235 node.className = val; 5236 } else if (attr === "name") { 5237 //the ie debugger fails to assign the name via setAttr 5238 //in quirks mode 5239 node[attr] = val; 5240 } else if (attr === "for") { 5241 if (!_Browser.isIEMobile || _Browser.isIEMobile >= 7) { 5242 node.setAttribute("htmlFor", val); 5243 } else { 5244 node.htmlFor = val; 5245 } 5246 } else if (attr === "style") { 5247 node.style.cssText = val; 5248 } else { 5249 //check if the attribute is an event, since this applies only 5250 //to quirks mode of ie anyway we can live with the standard html4/xhtml 5251 //ie supported events 5252 if (this.IE_QUIRKS_EVENTS[attr]) { 5253 if (this._Lang.isString(attr)) { 5254 var c = document.body.appendChild(document.createElement('span')); 5255 try { 5256 c.innerHTML = '<span ' + attr + '="' + val + '"/>'; 5257 node[attr] = c.firstChild[attr]; 5258 } finally { 5259 document.body.removeChild(c); 5260 } 5261 } 5262 } else { 5263 //unknown cases we try to catch them via standard setAttributes 5264 if (!_Browser.isIEMobile || _Browser.isIEMobile >= 7) { 5265 node.setAttribute(attr, val); 5266 } else { 5267 node[attr] = val; 5268 } 5269 } 5270 } 5271 }, 5272 5273 getDummyPlaceHolder:function () { 5274 this._callSuper("getDummyPlaceHolder"); 5275 5276 //ieMobile in its 6.1-- incarnation cannot handle innerHTML detached objects so we have 5277 //to attach the dummy placeholder, we try to avoid it for 5278 //better browsers so that we do not have unecessary dom operations 5279 if (this._RT.browser.isIEMobile && created) { 5280 this.insertFirst(this._dummyPlaceHolder); 5281 5282 this.setAttribute(this._dummyPlaceHolder, "style", "display: none"); 5283 5284 } 5285 5286 return this._dummyPlaceHolder; 5287 }, 5288 5289 /** 5290 * classical recursive way which definitely will work on all browsers 5291 * including the IE6 5292 * 5293 * @param rootNode the root node 5294 * @param filter the filter to be applied to 5295 * @param deepScan if set to true a deep scan is performed 5296 */ 5297 _recursionSearchAll:function (rootNode, filter, deepScan) { 5298 var ret = []; 5299 //fix the value to prevent undefined errors 5300 5301 if (filter(rootNode)) {
5302 ret.push(rootNode); 5303 if (!deepScan) return ret; 5304 } 5305 5306 // 5307 if (!rootNode.childNodes) { 5308 return ret; 5309 } 5310 5311 //subfragment usecases 5312 5313 var retLen = ret.length; 5314 var childLen = rootNode.childNodes.length; 5315 for (var cnt = 0; (deepScan || retLen == 0) && cnt < childLen; cnt++) { 5316 ret = ret.concat(this._recursionSearchAll(rootNode.childNodes[cnt], filter, deepScan)); 5317 } 5318 return ret; 5319 }, 5320 5321 /** 5322 * break the standard events from an existing dom node 5323 * (note this method is not yet used, but can be used 5324 * by framework authors to get rid of ie circular event references) 5325 * 5326 * another way probably would be to check all attributes of a node 5327 * for a function and if one is present break it by nulling it 5328 * I have to do some further investigation on this. 5329 * 5330 * The final fix is to move away from ie6 at all which is the root cause of 5331 * this. 5332 * 5333 * @param node the node which has to be broken off its events 5334 */ 5335 breakEvents:function (node) { 5336 if (!node) return; 5337 var evtArr = this.IE_QUIRKS_EVENTS; 5338 for (var key in evtArr) { 5339 if (!evtArr.hasOwnProperty(key)) continue; 5340 if (key != "onunload" && node[key]) { 5341 node[key] = null; 5342 } 5343 } 5344 }, 5345 5346 isManualScriptEval:function () { 5347 5348 if (!this._Lang.exists(myfaces, "config._autoeval")) { 5349 5350 //now we rely on the document being processed if called for the first time 5351 var evalDiv = document.createElement("div"); 5352 this._Lang.reserveNamespace("myfaces.config._autoeval"); 5353 //null not swallowed 5354 myfaces.config._autoeval = false; 5355 5356 var markup = "<script type='text/javascript'> myfaces.config._autoeval = true; </script>"; 5357 //now we rely on the same replacement mechanisms as outerhtml because 5358 //some browsers have different behavior of embedded scripts in the contextualfragment 5359 //or innerhtml case (opera for instance), this way we make sure the 5360 //eval detection is covered correctly 5361 this.setAttribute(evalDiv, "style", "display:none"); 5362 5363 //it is less critical in some browsers (old ie versions) 5364 //to append as first element than as last 5365 //it should not make any difference layoutwise since we are on display none anyway. 5366 this.insertFirst(evalDiv); 5367 5368 //we remap it into a real boolean value 5369 if (this.isDomCompliant()) { 5370 this._outerHTMLCompliant(evalDiv, markup); 5371 } else { 5372 //will not be called placeholder for quirks class 5373 this._outerHTMLNonCompliant(evalDiv, markup); 5374 } 5375 5376 5377 } 5378 5379 return !myfaces.config._autoeval; 5380 }, 5381 5382 getNamedElementFromForm:function (form, elementName) { 5383 var browser = this._RT.browser; 5384 if(browser.isIE && browser.isIE < 8) { 5385 if(!form.elements) return null; 5386 for(var cnt = 0, l = form.elements.length; cnt < l; cnt ++) { 5387 var element = form.elements[cnt]; 5388 if(element.name == elementName) { 5389 return element; 5390 } 5391 } 5392 return null; 5393 } else { 5394 return form[elementName]; 5395 } 5396 } 5397 5398 }); 5399 5400} 5401 5402/* Licensed to the Apache Software Foundation (ASF) under one or more 5403 * contributor license agreements. See the NOTICE file distributed with 5404 * this work for additional information regarding copyright ownership. 5405 * The ASF licenses this file to you under the Apache License, Version 2.0 5406 * (the "License"); you may not use this file except in compliance with 5407 * the License. You may obtain a copy of the License at 5408 * 5409 * http://www.apache.org/licenses/LICENSE-2.0 5410 * 5411 * Unless required by applicable law or agreed to in writing, softw
5411are 5412 * distributed under the License is distributed on an "AS IS" BASIS, 5413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5414 * See the License for the specific language governing permissions and 5415 * limitations under the License. 5416 */ 5417 5418/** 5419 * @class 5420 * @name _HtmlStripper 5421 * @memberOf myfaces._impl._util 5422 * @extends myfaces._impl.core._Runtime 5423 * @description 5424 * Fallback routine if the browser embedded xml parser fails on the document 5425 * This fallback is not failsafe but should give enough cover to handle all cases 5426 */ 5427 5428/** @namespace myfaces._impl._util._HtmlStripper */ 5429_MF_CLS(_PFX_UTIL + "_HtmlStripper", _MF_OBJECT, /** @lends myfaces._impl._util._HtmlStripper.prototype */ { 5430 5431 /** 5432 * main parse routine parses the document for a given tag name 5433 * 5434 * 5435 * @param theString the markup string to be parsed 5436 * @param tagNameStart the tag name to be parsed for 5437 */ 5438 parse : function(theString, tagNameStart) { 5439 5440 var BEGIN_TAG = "html", 5441 _tagStart = -1, 5442 _tagEnd = -1, 5443 _contentStart = -1, 5444 _contentEnd = -1, 5445 _tokenPos = 0, 5446 _tokenForward = 1, 5447 tagNameStart = (!tagNameStart) ? BEGIN_TAG : tagNameStart; 5448 5449 var proposedTagStartPos = theString.indexOf("<" + tagNameStart); 5450 var _T = this; 5451 5452 //we use closures instead of private methods to improve the compressability 5453 5454 var isValidPositionCombination = function(pos1, pos2, pos3, pos4) { 5455 return pos1 <= pos2 && pos3 <= pos4; 5456 }; 5457 5458 /** 5459 * trace for a forward comment 5460 * 5461 * @param theStr the string to be checked 5462 * @param tagPos the tag position from which the check onwards has to be perfomed 5463 * @return true in case a comment is found 5464 */ 5465 var checkForwardForComment = function(theStr, tagPos) { 5466 var toCheck = theStr.substring(tagPos), 5467 indexOf = _T._Lang.hitch(toCheck, toCheck.indexOf), 5468 firstBeginComment = indexOf("<!--"), 5469 firstEndComment = indexOf("-->"), 5470 5471 firstBeginCDATA = indexOf("<[CDATA["), 5472 firstEndCDATA = indexOf("]]>"); 5473 5474 if (isValidPositionCombination(firstBeginComment, firstEndComment, firstBeginCDATA, firstEndCDATA)) { 5475 return true; 5476 } 5477 5478 return firstBeginComment <= firstEndComment && firstBeginCDATA <= firstEndCDATA; 5479 }; 5480 5481 /** 5482 * check backwards for a comment 5483 * 5484 * @param theStr the check string 5485 * @param tagPos the tag position from which the check should be performed 5486 * @return true in case a comment is found 5487 */ 5488 var checkBackForComment = function(theStr, tagPos) { 5489 var toCheck = theStr.substring(tagPos), 5490 indexOf = _T._Lang.hitch(toCheck, toCheck.indexOf), 5491 lastBeginComment = indexOf("<!--"), 5492 lastEndComment = indexOf("-->"), 5493 lastBeginCDATA = indexOf("<[CDATA["), 5494 lastEndCDATA = indexOf("]]>"); 5495 5496 if (isValidPositionCombination(lastBeginComment, lastEndComment, lastBeginCDATA, lastEndCDATA)) { 5497 //TODO we have to handle the embedded cases, for now we leave them out 5498 return true; 5499 } 5500 }; 5501 5502 //no need for ll parsing a handful of indexofs instead of slower regepx suffices 5503 var theSubStr = this._Lang.hitch(theString, theString.substring); 5504 while (_contentStart == -1 && proposedTagStartPos != -1) { 5505 if (checkBackForComment(theString, proposedTagStartPos)) { 5506 _tagStart = proposedTagStartPos; 5507 _contentStart = proposedTagStartPos + theSubStr(proposedTagStartPos).indexOf(">") + 1; 5508 } 5509 proposedTagStartPos = theSubStr(proposedTagStartPos + tagNameStart.length + 2).indexOf("<" + tagNameStart); 5510 } 5511 5512 var proposedEndTagPos = theString.lastIndexOf("</" + tagNameStart); 5513 while (_contentEnd == -1 && proposedEndTagPos > 0) { 5514 if (checkForwardForComment(theString, proposedEndTagPos)) { 5515 _tagEnd = proposedEndTagPos; 5516 _contentEnd = proposedEndTagPos; 5517 } 5518 proposedTagStartPos = theSubStr(proposedTagStartPos - tagNameStart.length - 2).lastIndexOf("</" + tagNameStart); 5519 } 5520 if (_contentStart != -1 && _contentEnd != -1) { 5521 return theSubStr(_contentStart, _contentEnd); 5522 } 5523 return null; 5524 } 5525}); 5526 5527 5528 5529 5530/* Licensed to the Apache Software Foundation (ASF) under one or more 5531 * contributor license agreements. See the NOTICE file distributed with 5532 * this work for additional information regarding copyright ownership. 5533 * The ASF licenses this file to you under the Apache License, Version 2.0 5534 * (the "License");
5534 you may not use this file except in compliance with 5535 * the License. You may obtain a copy of the License at 5536 * 5537 * http://www.apache.org/licenses/LICENSE-2.0 5538 * 5539 * Unless required by applicable law or agreed to in writing, software 5540 * distributed under the License is distributed on an "AS IS" BASIS, 5541 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5542 * See the License for the specific language governing permissions and 5543 * limitations under the License. 5544 */ 5545 5546 5547/** 5548 * legacy code to enable various aspects 5549 * of myfaces, used to be rendered inline 5550 * for jsf 2.0 we can externalized it into its own custom resource 5551 */ 5552 5553(!window.myfaces) ? window.myfaces = {} : null; 5554if (!myfaces.oam) { 5555 myfaces.oam = new function() { 5556 5557 /** 5558 * sets a hidden input field 5559 * @param formname the formName 5560 * @param name the hidden field 5561 * @param value the value to be rendered 5562 */ 5563 this.setHiddenInput = function(formname, name, value) { 5564 var form = document.forms[formname]; 5565 if (typeof form == 'undefined') { 5566 form = document.getElementById(formname); 5567 } 5568 5569 if (typeof form.elements[name] != 'undefined' && (form.elements[name].nodeName == 'INPUT' || form.elements[name].nodeName == 'input')) { 5570 form.elements[name].value = value; 5571 } 5572 else { 5573 var newInput = document.createElement('input'); 5574 newInput.setAttribute('type', 'hidden'); 5575 newInput.setAttribute('id', name); 5576 newInput.setAttribute('name', name); 5577 newInput.setAttribute('value', value); 5578 form.appendChild(newInput); 5579 } 5580 }; 5581 5582 /** 5583 * clears a hidden input field 5584 * 5585 * @param formname formName for the input 5586 * @param name the name of the input field 5587 * @param value the value to be cleared 5588 */ 5589 this.clearHiddenInput = function(formname, name, value) { 5590 var form = document.forms[formname]; 5591 5592 if (typeof form == 'undefined') { 5593 form = document.getElementById(formname); 5594 } 5595 5596 var hInput = form.elements[name]; 5597 if (typeof hInput != 'undefined') { 5598 form.removeChild(hInput); 5599 } 5600 }; 5601 5602 /** 5603 * does special form submit remapping 5604 * remaps the issuing command link into something 5605 * the decode of the command link on the server can understand 5606 * 5607 * @param formName 5608 * @param linkId 5609 * @param target 5610 * @param params 5611 */ 5612 this.submitForm = function(formName, linkId, target, params) { 5613 5614 var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_'); 5615 if (typeof window[clearFn] == 'function') { 5616 window[clearFn](formName); 5617 } 5618 5619 var form = document.forms[formName]; 5620 if (typeof form == 'undefined') { 5621 form = document.getElementById(formName); 5622 } 5623 5624 //autoscroll code 5625 if (myfaces.core.config.autoScroll && typeof window.getScrolling != 'undefined') { 5626 myfaces.oam.setHiddenInput(formName, 'autoScroll', getScrolling()); 5627 } 5628 5629 if (myfaces.core.config.ieAutoSave) { 5630 var agentString = navigator.userAgent.toLowerCase(); 5631 var version = navigator.appVersion; 5632 if (agentString.indexOf('msie') != -1) { 5633 if (!(agentString.indexOf('ppc') != -1 && agentString.indexOf('windows ce') != -1 && version >= 4.0)) { 5634 window.external.AutoCompleteSaveForm(form); 5635 } 5636 } 5637 } 5638 5639 var oldTarget = form.target; 5640 if (target != null) { 5641 form.target = target; 5642 } 5643 if ((typeof params != 'undefined') && params != null) { 5644 for (var i = 0, param; (param = params[i]); i++) { 5645 myfaces.oam.setHiddenInput(formName, param[0], param[1]); 5646 } 5647 5648 } 5649 5650 myfaces.oam.setHiddenInput(formName, formName + ':' + '_idcl', linkId); 5651 5652 if (form.onsubmit) { 5653 var result = form.onsubmit(); 5654 if ((typeof result == 'undefined') || result) { 5655 try { 5656 form.submit(); 5657 } 5658 catch(e) { 5659 } 5660 } 5661 5662 } 5663 else { 5664 try { 5665 form.submit(); 5666 } 5667 catch(e) { 5668 } 5669 } 5670 5671 form.target = oldTarget; 5672 if ((typeof params != 'undefined') && params != null) { 5673 5674 for (var i = 0, param; (param = params[i]); i++) { 5675 myfaces.oam.clearHiddenInput(formName, param[0], param[1]); 5676 } 5677 5678 } 5679 5680 myfaces.oam.clearHiddenInput(formName, formName + ':' + '_idcl', linkId); 5681 return false;
5682 }; 5683 } 5684} 5685 5686//reserve a cofig namespace for impl related stuff 5687(!myfaces.core) ? myfaces.core = {} : null; 5688(!myfaces.core.config) ? myfaces.core.config = {} : null; 5689 5690 5691/* Licensed to the Apache Software Foundation (ASF) under one or more 5692 * contributor license agreements. See the NOTICE file distributed with 5693 * this work for additional information regarding copyright ownership. 5694 * The ASF licenses this file to you under the Apache License, Version 2.0 5695 * (the "License"); you may not use this file except in compliance with 5696 * the License. You may obtain a copy of the License at 5697 * 5698 * http://www.apache.org/licenses/LICENSE-2.0 5699 * 5700 * Unless required by applicable law or agreed to in writing, software 5701 * distributed under the License is distributed on an "AS IS" BASIS, 5702 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5703 * See the License for the specific language governing permissions and 5704 * limitations under the License. 5705 */ 5706/** 5707 * @class 5708 * @name _AjaxUtils 5709 * @memberOf myfaces._impl.xhrCore 5710 * @description 5711 * 5712 * A set of helper routines which are utilized within our Ajax subsystem and nowhere else 5713 * 5714 * TODO move this into a singleton, the current structure is 5715 * still a j4fry legacy we need to get rid of it in the long run 5716 */ 5717_MF_SINGLTN(_PFX_XHR+"_AjaxUtils", _MF_OBJECT, 5718/** @lends myfaces._impl.xhrCore._AjaxUtils.prototype */ 5719{ 5720 5721 5722 /** 5723 * determines fields to submit 5724 * @param {Object} targetBuf - the target form buffer receiving the data 5725 * @param {Node} parentItem - form element item is nested in 5726 * @param {Array} partialIds - ids fo PPS 5727 */ 5728 encodeSubmittableFields : function(targetBuf, 5729 parentItem, partialIds) { 5730 if (!parentItem) throw "NO_PARITEM"; 5731 if (partialIds ) { 5732 this.encodePartialSubmit(parentItem, false, partialIds, targetBuf); 5733 } else { 5734 // add all nodes 5735 var eLen = parentItem.elements.length; 5736 for (var e = 0; e < eLen; e++) { 5737 this.encodeElement(parentItem.elements[e], targetBuf); 5738 } // end of for (formElements) 5739 } 5740 5741 }, 5742 5743 /** 5744 * appends the issuing item if not given already 5745 * @param item 5746 * @param targetBuf 5747 */ 5748 appendIssuingItem: function (item, targetBuf) { 5749 // if triggered by a Button send it along 5750 if (item && item.type && item.type.toLowerCase() == "submit") { 5751 targetBuf.append(item.name, item.value); 5752 } 5753 }, 5754 5755 5756 /** 5757 * encodes a single input element for submission 5758 * 5759 * @param {Node} element - to be encoded 5760 * @param {} targetBuf - a target array buffer receiving the encoded strings 5761 */ 5762 encodeElement : function(element, targetBuf) { 5763 5764 //browser behavior no element name no encoding (normal submit fails in that case) 5765 //https://issues.apache.org/jira/browse/MYFACES-2847 5766 if (!element.name) { 5767 return; 5768 } 5769 5770 var _RT = this._RT; 5771 var name = element.name; 5772 var tagName = element.tagName.toLowerCase(); 5773 var elemType = element.type; 5774 if (elemType != null) { 5775 elemType = elemType.toLowerCase(); 5776 } 5777 5778 // routine for all elements 5779 // rules: 5780 // - process only inputs, textareas and selects 5781 // - elements muest have attribute "name" 5782 // - elements must not be disabled 5783 if (((tagName == "input" || tagName == "textarea" || tagName == "select") && 5784 (name != null && name != "")) && !element.disabled) { 5785 5786 // routine for select elements 5787 // rules: 5788 // - if select-one and value-Attribute exist => "name=value" 5789 // (also if value empty => "name=") 5790 // - if select-one and value-Attribute don't exist => 5791 // "name=DisplayValue" 5792 // - if select multi and multple selected => "name=value1&name=value2" 5793 // - if select and selectedIndex=-1 don't submit 5794 if (tagName == "select") { 5795 // selectedIndex must be >= 0 sein to be submittet 5796 if (element.selectedIndex >= 0) { 5797 var uLen = element.options.length; 5798 for (var u = 0; u < uLen; u++) { 5799 // find all selected options 5800 //var subBuf = []; 5801 if (element.options[u].selected) { 5802 var elementOption = element.options[u]; 5803 targetBuf.append(name, (elementOption.getAttribute("value") != null) ? 5804 elementOption.value : elementOption.text); 5805 } 5806 } 5807 } 5808 } 5809 5810 // routine for remaining elements 5811 // rules: 5812 // - don't submit no selects (processed above), buttons, reset buttons, submit buttons, 5813 // - submit checkboxes and radio inputs only if checked 5814 if ((tagName != "select" && elemType != "button" 5815 && elemType != "reset" && elemType != "submit" && elemType != "image") 5816 && ((elemType != "checkbox" && elemType != "radio") || element.checked)) { 5817 if ('undefined' != typeof element.files && element.files != null && _RT.getXHRLvl() >= 2 && element.files.length) { 5818 //xhr level2 5819 targetBuf.append(name, element.files[0]); 5820 } else { 5821 targetBuf.append(name, element.value); 5822 } 5823 } 5824 5825 } 5826 } 5827}); 5828/* Licensed to the Apache Software Foundation (ASF) under one or more 5829 * contributor license agreements. See the NOTICE file distributed with 5830 * this work for additional information regarding copyright ownership. 5831 * The ASF licenses this file to you under the Apache License, Version 2.0 5832 * (the "License");
5832 you may not use this file except in compliance with 5833 * the License. You may obtain a copy of the License at 5834 * 5835 * http://www.apache.org/licenses/LICENSE-2.0 5836 * 5837 * Unless required by applicable law or agreed to in writing, software 5838 * distributed under the License is distributed on an "AS IS" BASIS, 5839 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5840 * See the License for the specific language governing permissions and 5841 * limitations under the License. 5842 */ 5843/** @namespace myfaces._impl.xhrCore._AjaxRequestQueue */ 5844_MF_CLS(_PFX_XHR + "_AjaxRequestQueue", myfaces._impl._util._Queue, /** @lends myfaces._impl.xhrCore._AjaxRequestQueue.prototype */ { 5845 5846 /** 5847 * a pointer towards the currently processed 5848 * request in our queue 5849 */ 5850 _curReq : null, 5851 5852 /** 5853 * delay request, then call enqueue 5854 * @param {Object} request (myfaces._impl.xhrCore._AjaxRequest) request to send 5855 */ 5856 enqueue : function(request) { 5857 5858 if (this._curReq == null) { 5859 console.log("[.ajax] direct send: %s", request._source.id); 5860 5861 this._curReq = request; 5862 this._curReq.send(); 5863 } else { 5864 console.log("[.ajax] enqueue: %s | current= %s", request._source.id, this._curReq._source.id); 5865 5866 this._callSuper("enqueue", request); 5867 if (request._queueSize != this._size) { 5868 this.setQueueSize(request._queueSize); 5869 } 5870 } 5871 5872 }, 5873 5874 /** 5875 * process queue, send request, if exists 5876 */ 5877 processQueue: function() { 5878 this._curReq = this.dequeue(); 5879 if (this._curReq) { 5880 this._curReq.send(); 5881 } 5882 }, 5883 5884 /** 5885 * cleanup queue 5886 */ 5887 cleanup: function() { 5888 this._curReq = null; 5889 this._callSuper("cleanup"); 5890 } 5891}); 5892 5893 5894/* Licensed to the Apache Software Foundation (ASF) under one or more 5895 * contributor license agreements. See the NOTICE file distributed with 5896 * this work for additional information regarding copyright ownership. 5897 * The ASF licenses this file to you under the Apache License, Version 2.0 5898 * (the "License"); you may not use this file except in compliance with 5899 * the License. You may obtain a copy of the License at 5900 * 5901 * http://www.apache.org/licenses/LICENSE-2.0 5902 * 5903 * Unless required by applicable law or agreed to in writing, software 5904 * distributed under the License is distributed on an "AS IS" BASIS, 5905 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5906 * See the License for the specific language governing permissions and 5907 * limitations under the License. 5908 */ 5909/** 5910 * @memberOf myfaces._impl.xhrCore 5911 * @namespace 5912 * @name engine 5913 */ 5914 5915/** 5916 * @class 5917 * @name XhrConst 5918 * @memberOf myfaces._impl.xhrCore.engine 5919 */ 5920_MF_SINGLTN(_PFX_XHR+"engine.XhrConst", Object, 5921 /** @lends myfaces._impl.xhrCore.engine.XhrConst.prototype */ 5922 { 5923 READY_STATE_UNSENT: 0, 5924 READY_STATE_OPENED: 1, 5925 READY_STATE_HEADERS_RECEIVED: 2, 5926 READY_STATE_LOADING: 3, 5927 READY_STATE_DONE: 4, 5928 5929 STATUS_OK_MINOR: 200, 5930 STATUS_OK_MAJOR: 300, 5931 5932 constructor_: function() { 5933 } 5934 }); 5935/* Licensed to the Apache Software Foundation (ASF) under one or more 5936 * contributor license agreements. See the NOTICE file distributed with 5937 * this work for additional information regarding copyright ownership. 5938 * The ASF licenses this file to you under the Apache License, Version 2.0 5939 * (the "License"); you may not use this file except in compliance with 5940 * the License. You may obtain a copy of the License at 5941 * 5942 * http://www.apache.org/licenses/LICENSE-2.0 5943 * 5944 * Unless required by applicable law or agreed to in writing, software 5945 * distributed under the License is distributed on an "AS IS" BASIS, 5946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5947 * See the License for the specific language governing permissions and 5948 * limitations under the License. 5949 */ 5950 5951/** 5952 * @class 5953 * @name FormData 5954 * @memberOf myfaces._impl.xhrCore.engine 5955 * @description 5956 * 5957 * html5 formdata object emulation for the iframe 5958 */ 5959_MF_CLS(_PFX_XHR+"engine.FormData", Object, 5960 /** @lends myfaces._impl.xhrCore.engine.FormData.prototype */ 5961 { 5962 form: null, 5963 viewstate: null, 5964 _appendedParams: {}, 5965 5966 constructor_: function(form) { 5967 this.form = form; 5968 }, 5969 5970 append: function(key, value) { 5971 this._appendedParams[key] = true; 5972 if (this.form) { 5973 this._appendHiddenValue(key, value); 5974 } 5975 }, 5976 5977 _finalize: function() { 5978 this._removeAppendedParams(); 5979 }, 5980 5981 _appendHiddenValue: function(key, value) { 5982 if ('undefined' == typeof value) { 5983 return; 5984 } 5985 var _Dom = myfaces._impl._util._Dom; 5986 var input = _Dom.createElement("input", { 5987 "type": "hidden", "name": key, "style": "display:none", "value": value 5988 }); 5989 5990 this.form.appendChild(input); 5991 }, 5992 5993 _removeAppendedParams: function() { 5994 if (!this.form) return; 5995 for (var cnt = this.form.elements.length - 1; cnt >= 0; cnt--) { 5996 var elem = this.form.elements[cnt]; 5997 if (this._appendedParams[elem.name] && elem.type == "hidden") { 5998 elem.parentNode.removeChild(elem); 5999 delete elem; 6000 } 6001 } 6002 this._appendedParams = {}; 6003 } 6004 6005 }); 6006/* Licensed to the Apache Software Foundation (ASF) under one or more 6007 * contributor license agreements. See the NOTICE file distributed with 6008 * this work for additional information regarding copyright ownership. 6009 * The ASF licenses this file to you under the Apache License, Version 2.0 6010 * (the "License");
6010 you may not use this file except in compliance with 6011 * the License. You may obtain a copy of the License at 6012 * 6013 * http://www.apache.org/licenses/LICENSE-2.0 6014 * 6015 * Unless required by applicable law or agreed to in writing, software 6016 * distributed under the License is distributed on an "AS IS" BASIS, 6017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6018 * See the License for the specific language governing permissions and 6019 * limitations under the License. 6020 */ 6021 6022/** 6023 * @class 6024 * @name BaseRequest 6025 * @memberOf myfaces._impl.xhrCore.engine 6026 * @extends myfaces._impl.core.Object 6027 * @description 6028 * Abstract Base for all classes which simulate the xhr level2 object 6029 * with a different transport 6030 * 6031 * <h3>Every class inheriting the interface must expose following methods and attributes</h3> 6032 * 6033 * <ul> 6034 * <li>open(method, url, async)</li> 6035 * <li>send(formData)</li> 6036 * <li>setRequestHeader(key, value)</li> 6037 * <li>abort()</li> 6038 * <li>onloadstart()</li> 6039 * <li>onprogress()</li> 6040 * <li>onabort()</li> 6041 * <li>onerror()</li> 6042 * <li>onload()</li> 6043 * <li>ontimeout()</li> 6044 * <li>onloadend()</li> 6045 * <li>onreadystatechange()</li> 6046 * </ul> 6047 * <h3>following attributes are supported</h3> 6048 * <ul> 6049 * <li>async</li> 6050 * <li>url</li> 6051 * <li>method</li> 6052 * <li>timeout</li> 6053 * <li>response</li> 6054 * <li>responseText</li> 6055 * <li>responseXML</li> 6056 * <li>status</li> 6057 * <li>statusText</li> 6058 * </ul> 6059 */ 6060_MF_CLS(_PFX_XHR + "engine.BaseRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.engine.BaseRequest.prototype */ { 6061 /*standard attributes*/ 6062 6063 /** 6064 * timeout attribute with a timeout for the request in miliseconds 6065 */ 6066 timeout:0, 6067 /** 6068 * readonly ready stte attribute 6069 */ 6070 readyState:0, 6071 /** 6072 * send method, allowed values POST and GET 6073 */ 6074 method:"POST", 6075 /** 6076 * the url for the call 6077 */ 6078 url:null, 6079 /** 6080 * asynchronous request, if set to true then the request happens 6081 * asynchronously, if possible. 6082 */ 6083 async:true, 6084 /** 6085 * read only response object, containing the response as json/dom representation 6086 */ 6087 response:null, 6088 /** 6089 * read only plain text representation of the response 6090 */ 6091 responseText:null, 6092 /** 6093 * xml dom readonly representation of the response 6094 */ 6095 responseXML:null, 6096 /** 6097 * readonly status code of the response 6098 */ 6099 status:null, 6100 /** 6101 * readonly status text of the response 6102 */ 6103 statusText:null, 6104 6105 constructor_:function (params) { 6106 this._callSuper("constructor_", params); 6107 this._initDefaultFinalizableFields(); 6108 6109 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6110 this._Lang.applyArgs(this, params); 6111 }, 6112 6113 //open send, abort etc... abstract 6114 /** 6115 * opens the transport element 6116 * @param {String} method transport method allowed values <i>POST</i> and <i>GET</i> 6117 * @param {String} url optional url 6118 * @param {Boolean}Â async optional param asynchronous transmission if set to true 6119 */ 6120 open:function (method, url, async) { 6121 this._implementThis(); 6122 }, 6123 /** 6124 * send method 6125 * @param {Object} formData data to be posted within the request 6126 */ 6127 send:function (formData) { 6128 this._implementThis(); 6129 }, 6130 /** 6131 * appends a key value pair to the request header if possible 6132 * @param {String}Â key the key of the request header entry 6133 * @param {String}Â value the value for the key 6134 */ 6135 setRequestHeader:function (key, value) { 6136 this._implementThis(); 6137 }, 6138 /** 6139 * aborts the transmission 6140 */ 6141 abort:function () { 6142 this._implementThis(); 6143 }, 6144 6145 //empty implementations for the callback handlers 6146 /** 6147 * callback once the transmission has started 6148 * @param evt 6149 */ 6150 onloadstart:function (evt) { 6151 }, 6152 onprogress:function (evt) { 6153 }, 6154 onabort:function (evt) { 6155 }, 6156 onerror:function (evt) { 6157 }, 6158 onload:function (evt) { 6159 }, 6160 ontimeout:function (evt) { 6161 }, 6162 onloadend:function (evt) { 6163 }, 6164 onreadystatechange:function (evt) { 6165 }, 6166 6167 _implementThis:function () { 6168 throw Error("the function needs to be implemented"); 6169 } 6170}); 6171/* Licensed to the Apache Software Foundation (ASF) under one or more 6172 * contributor license agreements. See the NOTICE file distributed with 6173 * this work for additional information regarding copyright ownership. 6174 * The ASF licenses this file to you under the Apache License, Version 2.0 6175 * (the "License");
6175 you may not use this file except in compliance with 6176 * the License. You may obtain a copy of the License at 6177 * 6178 * http://www.apache.org/licenses/LICENSE-2.0 6179 * 6180 * Unless required by applicable law or agreed to in writing, software 6181 * distributed under the License is distributed on an "AS IS" BASIS, 6182 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6183 * See the License for the specific language governing permissions and 6184 * limitations under the License. 6185 */ 6186 6187 6188/** 6189 * @class 6190 * @name Xhr1 6191 * @memberOf myfaces._impl.xhrCore.engine 6192 * @extends myfaces._impl.xhrCore.engine.BaseRequest 6193 * @description 6194 * 6195 * wrapper for an xhr level1 object with all its differences 6196 * it emulates the xhr level2 api which is way simpler than the level1 api 6197 */ 6198 6199_MF_CLS(_PFX_XHR + "engine.Xhr1", myfaces._impl.xhrCore.engine.BaseRequest, /** @lends myfaces._impl.xhrCore.engine.Xhr1.prototype */ { 6200 6201 _xhrObject: null, 6202 _timeoutTimer: null, 6203 6204 constructor_: function(params) { 6205 //the constructor is empty due to the original xhr object not having anything 6206 6207 this._callSuper("constructor_", params); 6208 this._initDefaultFinalizableFields(); 6209 6210 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6211 this._Lang.applyArgs(this, params); 6212 }, 6213 6214 // void open(DOMString method, DOMString url, boolean async); 6215 open: function(method, url, async) { 6216 6217 var xhr = this._xhrObject; 6218 xhr.onreadystatechange = this._Lang.hitch(this, this.onreadystatechange); 6219 this.method = method || this.method; 6220 this.url = url || this.url; 6221 this.async = ('undefined' != typeof async) ? async : this.async; 6222 xhr.open(this.method, this.url, this.async); 6223 }, 6224 6225 send: function(formData) { 6226 6227 var myevt = {}; 6228 6229 this._addProgressAttributes(myevt, 20, 100); 6230 this.onloadstart(myevt); 6231 this.onprogress(myevt); 6232 this._startTimeout(); 6233 this._xhrObject.send(formData); 6234 }, 6235 6236 setRequestHeader: function(key, value) { 6237 this._xhrObject.setRequestHeader(key, value); 6238 }, 6239 6240 abort: function() { 6241 6242 this._xhrObject.abort(); 6243 this.onabort({}); 6244 }, 6245 6246 _addProgressAttributes: function(evt, percent, total) { 6247 //http://www.w3.org/TR/progress-events/#progressevent 6248 evt.lengthComputable = true; 6249 evt.loaded = percent; 6250 evt.total = total; 6251 6252 }, 6253 6254 onreadystatechange: function(evt) { 6255 var myevt = evt || {}; 6256 //we have to simulate the attributes as well 6257 var xhr = this._xhrObject; 6258 var XHRConst = this._XHRConst; 6259 try { 6260 this.readyState = xhr.readyState; 6261 this.status = ""+xhr.status; 6262 } catch(e) { 6263 //IE 6 has an internal error 6264 } 6265 6266 switch (this.readyState) { 6267 6268 case XHRConst.READY_STATE_OPENED: 6269 this._addProgressAttributes(myevt, 10, 100); 6270 6271 this.onprogress(myevt); 6272 break; 6273 6274 case XHRConst.READY_STATE_HEADERS_RECEIVED: 6275 this._addProgressAttributes(myevt, 25, 100); 6276 6277 this.onprogress(myevt); 6278 break; 6279 6280 case XHRConst.READY_STATE_LOADING: 6281 if (this._loadingCalled) break; 6282 this._loadingCalled = true; 6283 this._addProgressAttributes(myevt, 50, 100); 6284 6285 this.onprogress(myevt); 6286 break; 6287 6288 case XHRConst.READY_STATE_DONE: 6289 this._addProgressAttributes(myevt, 100, 100); 6290 //xhr level1 does not have timeout handler 6291 if (this._timeoutTimer) { 6292 //normally the timeout should not cause anything anymore 6293 //but just to make sure 6294 window.clearTimeout(this._timeoutTimer); 6295 this._timeoutTimer = null; 6296 } 6297 this._transferRequestValues(); 6298 this.onprogress(myevt); 6299 try { 6300 var status = xhr.status; 6301 if (status >= XHRConst.STATUS_OK_MINOR && status < XHRConst.STATUS_OK_MAJOR) { 6302 this.onload(myevt); 6303 } else { 6304 myevt.type = "error";
6305 this.onerror(myevt); 6306 } 6307 } finally { 6308 //remove for xhr level2 support 6309 this.onloadend(myevt); 6310 } 6311 } 6312 }, 6313 6314 _transferRequestValues: function() { 6315 //this._Lang.mixMaps(this, this._xhrObject, true, null, 6316 // {responseText:1,responseXML:1,status:1,statusText:1,response:1}); 6317 var UDEF = "undefined"; 6318 var xhr = this._xhrObject; 6319 6320 this.responseText = (UDEF != typeof xhr.responseText)?xhr.responseText: null; 6321 this.responseXML = (UDEF != typeof xhr.responseXML)?xhr.responseXML: null; 6322 this.status = (UDEF != typeof xhr.status)?xhr.status: null; 6323 this.statusText = (UDEF != typeof xhr.statusText)?xhr.statusText: null; 6324 this.response = (UDEF != typeof xhr.response)?xhr.response: null; 6325 }, 6326 6327 _startTimeout: function() { 6328 if (this.timeout == 0) return; 6329 6330 var xhr = this._xhrObject; 6331 //some browsers have timeouts in their xhr level 1.x objects implemented 6332 //we leverage them whenever they exist 6333 try { 6334 if ('undefined' != typeof xhr.timeout) { 6335 xhr.timeout = this.timeout; 6336 xhr.ontimeout = this.ontimeout; 6337 return; 6338 } 6339 } catch (e) { 6340 //firefox 12 has a bug here 6341 } 6342 6343 6344 this._timeoutTimer = setTimeout(this._Lang.hitch(this, function() { 6345 if (xhr.readyState != this._XHRConst.READY_STATE_DONE) { 6346 6347 xhr.onreadystatechange = function() { 6348 }; 6349 clearTimeout(this._timeoutTimer); 6350 xhr.abort(); 6351 this.ontimeout({}); 6352 } 6353 }), this.timeout); 6354 }, 6355 6356 getXHRObject: function() { 6357 return this._xhrObject; 6358 } 6359 6360 6361}); 6362/* Licensed to the Apache Software Foundation (ASF) under one or more 6363 * contributor license agreements. See the NOTICE file distributed with 6364 * this work for additional information regarding copyright ownership. 6365 * The ASF licenses this file to you under the Apache License, Version 2.0 6366 * (the "License"); you may not use this file except in compliance with 6367 * the License. You may obtain a copy of the License at 6368 * 6369 * http://www.apache.org/licenses/LICENSE-2.0 6370 * 6371 * Unless required by applicable law or agreed to in writing, software 6372 * distributed under the License is distributed on an "AS IS" BASIS, 6373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6374 * See the License for the specific language governing permissions and 6375 * limitations under the License. 6376 */ 6377 6378/** 6379 * @class 6380 * @name IFrame 6381 * @memberOf myfaces._impl.xhrCore.engine 6382 * @extends myfaces._impl.xhrCore.engine.BaseRequest 6383 * @description 6384 * 6385 * wrapper for an iframe transport object with all its differences 6386 * it emulates the xhr level2 api 6387 */ 6388_MF_CLS(_PFX_XHR + "engine.IFrame", myfaces._impl.xhrCore.engine.BaseRequest, 6389 /** @lends myfaces._impl.xhrCore.engine.IFrame.prototype */ 6390 { 6391 6392 _finalized: false, 6393 6394 /*the target frame responsible for the communication*/ 6395 _frame: null, 6396 //_requestHeader: null, 6397 _aborted: false, 6398 6399 CLS_NAME: "myfaces._impl.xhrCore._IFrameRequest", 6400 _FRAME_ID: "_mf_comm_frm", 6401 6402 /** 6403 * constructor which shifts the arguments 6404 * to the protected properties of this clas 6405 * 6406 * @param arguments 6407 */ 6408 constructor_: function (arguments) { 6409 //we fetch in the standard arguments 6410 6411 this._callSuper("constructor", arguments); 6412 6413 this._initDefaultFinalizableFields(); 6414 //this._requestHeader = {}; 6415 6416 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6417 6418 this._Lang.applyArgs(this, arguments); 6419 this.readyState = this._XHRConst.READY_STATE_UNSENT; 6420 this._startTimeout(); 6421 }, 6422 6423 setRequestHeader: function (key, value) { 6424 //this._requestHeader[key] = value; 6425 }, 6426 6427 open: function (method, url, async) { 6428 6429 this.readyState = this._XHRConst.READY_STATE_OPENED; 6430 6431 var _RT = myfaces._impl.core._Runtime; 6432 var _Lang = this._Lang; 6433 6434 this._frame = this._createTransportFrame(); 6435 6436 //we append an onload handler to the frame 6437 //to cover the starting and loading events, 6438 //timeouts cannot be covered in a cross browser way 6439 6440 //we point our onload handler to the frame, we do not use addOnLoad 6441 //because the frame should not have other onload handlers in place 6442 if (!_RT.browser.isIE || this._Dom.isDomCompliant()) { 6443 this._frame.onload = _Lang.hitch(this, this._callback); 6444 } else { 6445 //ie has a bug, onload is not settable outside of innerHTML on iframes 6446 this._frame.onload_IE = _Lang.hitch(this, this._callback); 6447 } 6448 6449 this.method = method || this.method; 6450 this.url = url || this.url; 6451 this.async = ('undefined' != typeof async) ? async : this.async; 6452 6453 var myevt = {}; 6454 this._addProgressAttributes(myevt, 10, 100); 6455 this.onprogress(myevt); 6456 }, 6457 6458 send: function (formData) { 6459 6460 var myevt = {}; 6461 this._addProgressAttributes(myevt, 20, 100); 6462 this.onloadstart(myevt); 6463 this.onprogress(myevt); 6464 6465 var formDataForm = formData.form, 6466 oldTarget = formDataForm.target, 6467 oldMethod = formDataForm.method, 6468 oldAction = formDataForm.action; 6469 6470 try { 6471 //_t._initAjaxParams(); 6472 //for (var key in this._requestHeader) { 6473 // formData.append(key, this._requestHeader[key]); 6474 //} 6475 6476 formDataForm.target = this._frame.name; 6477 formDataForm.method = this.method; 6478 if (this.url) { 6479 formDataForm.action = this.url; 6480 } 6481 this.readyState = this._XHRConst.READY_STATE_LOADING; 6482 this.onreadystatechange(myevt); 6483 formDataForm.submit(); 6484 } finally { 6485 formDataForm.action = oldAction; 6486 formDataForm.target = oldTarget; 6487 formDataForm.method = oldMethod; 6488 6489 formData._finalize(); 6490 //alert("finalizing"); 6491 this._finalized = true; 6492 } 6493 }, 6494 6495 /*we can implement it, but it will work only on browsers 6496 * which have asynchronous iframe loading*/ 6497 abort: function () { 6498 this._aborted = true; 6499 this.onabort({}); 6500 }, 6501 6502 _addProgressAttributes: function (evt, percent, total) { 6503 //http://www.w3.org/TR/progress-events/#progressevent 6504 evt.lengthComputable = true; 6505 evt.loaded = percent; 6506 evt.total = total; 6507 6508 }, 6509 6510 _callback: function () { 6511 //------------------------------------ 6512 // we are asynchronous which means we 6513 // have to check wether our code 6514 // is finalized or not 6515 //------------------------------------ 6516 if (this._aborted) return; 6517 if (this._timeoutTimer) { 6518 clearTimeout(this._timeoutTimer); 6519 } 6520 if (!this._finalized) { 6521 setTimeout(this._Lang.hitch(this, this._callback), 10); 6522 return; 6523 } 6524 //aborted no further processing 6525 6526 try { 6527 var myevt = {}; 6528 6529 this._addProgressAttributes(myevt, 100, 100); 6530 //this.readyState = this._XHRConst.READY_STATE_DONE; 6531 //this.onreadystatechange(myevt); 6532 6533 this.responseText = this._getFrameText(); 6534 this.responseXML = this._getFrameXml(); 6535 this.readyState = this._XHRConst.READY_STATE_DONE; 6536 6537 //TODO status and statusText 6538 6539 this.onreadystatechange(myevt); 6540 this.onloadend(); 6541 6542 if (!this._Lang.isXMLParseError(this.responseXML)) { 6543 this.status = 201; 6544 this.onload(); 6545 } else { 6546 this.status = 0; 6547 //we simulate the request for our xhr call
6548 this.onerror(); 6549 } 6550 6551 } finally { 6552 this._frame = null; 6553 } 6554 }, 6555 6556 /** 6557 * returns the frame text in a browser independend manner 6558 */ 6559 _getFrameDocument: function () { 6560 6561 //we cover various browsers here, because almost all browsers keep the document in a different 6562 //position 6563 return this._frame.contentWindow.document || this._frame.contentDocument || this._frame.document; 6564 }, 6565 6566 _getFrameText: function () { 6567 var framedoc = this._getFrameDocument(); 6568 //also ie keeps the body in framedoc.body the rest in documentElement 6569 var body = framedoc.body || framedoc.documentElement; 6570 return body.innerHTML; 6571 }, 6572 6573 _clearFrame: function () { 6574 6575 var framedoc = this._getFrameDocument(); 6576 var body = framedoc.documentElement || framedoc.body; 6577 //ie8 in 7 mode chokes on the innerHTML method 6578 //direct dom removal is less flakey and works 6579 //over all browsers, but is slower 6580 if (myfaces._impl.core._Runtime.browser.isIE) { 6581 this._Dom._removeChildNodes(body, false); 6582 } else { 6583 body.innerHTML = ""; 6584 } 6585 }, 6586 6587 /** 6588 * returns the processed xml from the frame 6589 */ 6590 _getFrameXml: function () { 6591 var framedoc = this._getFrameDocument(); 6592 //same situation here, the xml is hosted either in xmlDocument or 6593 //is located directly under the frame document 6594 return framedoc.XMLDocument || framedoc; 6595 }, 6596 6597 _createTransportFrame: function () { 6598 6599 var _FRM_ID = this._FRAME_ID; 6600 var frame = document.getElementById(_FRM_ID); 6601 if (frame) return frame; 6602 //normally this code should not be called 6603 //but just to be sure 6604 6605 if (this._Dom.isDomCompliant()) { 6606 frame = this._Dom.createElement('iframe', { 6607 "src": "about:blank", 6608 "id": _FRM_ID, 6609 "name": _FRM_ID, 6610 "type": "content", 6611 "collapsed": "true", 6612 "style": "display:none" 6613 }); 6614 6615 //probably the ie method would work on all browsers 6616 //but this code is the safe bet it works on all standards 6617 //compliant browsers in a clean manner 6618 6619 document.body.appendChild(frame); 6620 } else { //Now to the non compliant browsers 6621 var node = this._Dom.createElement("div", { 6622 "style": "display:none" 6623 }); 6624 6625 //we are dealing with two well known iframe ie bugs here 6626 //first the iframe has to be set via innerHTML to be present 6627 //secondly the onload handler is immutable on ie, we have to 6628 //use a dummy onload handler in this case and call this one 6629 //from the onload handler 6630 node.innerHTML = "<iframe id='" + _FRM_ID + "' name='" + _FRM_ID + "' style='display:none;' src='about:blank' type='content' onload='this.onload_IE();' ></iframe>"; 6631 6632 //avoid the ie open tag problem 6633 var body = document.body; 6634 if (body.firstChild) { 6635 body.insertBefore(node, document.body.firstChild); 6636 } else { 6637 body.appendChild(node); 6638 } 6639 } 6640 6641 //helps to for the onload handlers and innerhtml to be in sync again 6642 return document.getElementById(_FRM_ID); 6643 }, 6644 6645 _startTimeout: function () { 6646 6647 if (this.timeout == 0) return; 6648 this._timeoutTimer = setTimeout(this._Lang.hitch(this, function () { 6649 if (this._xhrObject.readyState != this._XHRConst.READY_STATE_DONE) { 6650 6651 this._aborted = true; 6652 clearTimeout(this._timeoutTimer); 6653 //we cannot abort an iframe request 6654 this.ontimeout({}); 6655 this._timeoutTimer = null; 6656 } 6657 }), this.timeout); 6658 } 6659 }); 6660 6661/* Licensed to the Apache Software Foundation (ASF) under one or more 6662 * contributor license agreements. See the NOTICE file distributed with 6663 * this work for additional information regarding copyright ownership. 6664 * The ASF licenses this file to you under the Apache License, Version 2.0 6665 * (the "License");
6665 you may not use this file except in compliance with 6666 * the License. You may obtain a copy of the License at 6667 * 6668 * http://www.apache.org/licenses/LICENSE-2.0 6669 * 6670 * Unless required by applicable law or agreed to in writing, software 6671 * distributed under the License is distributed on an "AS IS" BASIS, 6672 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6673 * See the License for the specific language governing permissions and 6674 * limitations under the License. 6675 */ 6676 6677/** 6678 * An implementation of an xhr request object 6679 * with partial page submit functionality, and jsf 6680 * ppr request and timeout handling capabilities 6681 * 6682 * Author: Werner Punz (latest modification by $Author: lustig#his.de $) 6683 * Version: $Revision: 1.2 $ $Date: 2020/05/03 23:15:00 $ 6684 */ 6685 6686/** 6687 * @class 6688 * @name _AjaxRequest 6689 * @memberOf myfaces._impl.xhrCore 6690 * @extends myfaces._impl.core.Object 6691 */ 6692_MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */ { 6693 6694 _contentType:"application/x-www-form-urlencoded", 6695 /** source element issuing the request */ 6696 _source:null, 6697 /** context passed down from the caller */ 6698 _context:null, 6699 /** source form issuing the request */ 6700 _sourceForm:null, 6701 /** passthrough parameters */ 6702 _passThrough:null, 6703 6704 /** queue control */ 6705 _timeout:null, 6706 /** enqueuing delay */ 6707 //_delay:null, 6708 /** queue size */ 6709 _queueSize:-1, 6710 6711 /** 6712 back reference to the xhr queue, 6713 only set if the object really is queued 6714 */ 6715 _xhrQueue:null, 6716 6717 /** pps an array of identifiers which should be part of the submit, the form is ignored */ 6718 _partialIdsArray:null, 6719 6720 /** xhr object, internal param */ 6721 _xhr:null, 6722 6723 /** predefined method */ 6724 _ajaxType:"POST", 6725 6726 //CONSTANTS 6727 ENCODED_URL:"javax.faces.encodedURL", 6728 /* 6729 * constants used internally 6730 */ 6731 _CONTENT_TYPE:"Content-Type", 6732 _HEAD_FACES_REQ:"Faces-Request", 6733 _VAL_AJAX:"partial/ajax", 6734 _XHR_CONST:myfaces._impl.xhrCore.engine.XhrConst, 6735 6736 // _exception: null, 6737 // _requestParameters: null, 6738 /** 6739 * Constructor 6740 * <p /> 6741 * note there is a load of common properties 6742 * inherited by the base class which define the corner 6743 * parameters and the general internal behavior 6744 * like _onError etc... 6745 * @param {Object} args an arguments map which an override any of the given protected 6746 * instance variables, by a simple name value pair combination 6747 */ 6748 constructor_:function (args) { 6749 6750 try { 6751 this._callSuper("constructor_", args); 6752 6753 this._initDefaultFinalizableFields(); 6754 delete this._resettableContent["_xhrQueue"]; 6755 6756 this.applyArgs(args); 6757 6758 /*namespace remapping for readability*/ 6759 //we fetch in the standard arguments 6760 //and apply them to our protected attributes 6761 //we do not gc the entry hence it is not defined on top 6762 var xhrCore = myfaces._impl.xhrCore; 6763 this._AJAXUTIL = xhrCore._AjaxUtils; 6764 6765 } catch (e) { 6766 //_onError 6767 this._stdErrorHandler(this._xhr, this._context, e); 6768 } 6769 }, 6770 6771 /** 6772 * Sends an Ajax request 6773 */ 6774 send:function () { 6775 6776 var _Lang = this._Lang; 6777 var _RT = this._RT; 6778 var _Dom = this._Dom; 6779 try { 6780 6781 var scopeThis = _Lang.hitch(this, function (functionName) { 6782 return _Lang.hitch(this, this[functionName]); 6783 }); 6784 this._xhr = _Lang.mixMaps(this._getTransport(), { 6785 onprogress:scopeThis("onprogress"), 6786 ontimeout:scopeThis("ontimeout"), 6787 //remove for xhr level2 support (chrome has problems with it) 6788 //for chrome we have to emulate the onloadend by calling it explicitely 6789 //and leave the onload out 6790 //onloadend: scopeThis("ondone"), 6791 onload:scopeThis("onsuccess"), 6792 onerror:scopeThis("onerror") 6793 6794 }, true); 6795 6796 this._applyClientWindowId(); 6797 var xhr = this._xhr, 6798 sourceForm = this._sourceForm, 6799 targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ? 6800 sourceForm.action : 6801 sourceForm.elements[this.ENCODED_URL].value, 6802 formData = this.getFormData(); 6803 6804 for (var key in this._passThrough) { 6805 if (!this._passThrough.hasOwnProperty(key)) continue; 6806 formData.append(key, this._passThrough[key]); 6807 } 6808 6809 xhr.open(this._ajaxType, targetURL + 6810 ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "") 6811 , true); 6812 6813 xhr.timeout = this._timeout || 0; 6814 6815 this._applyContentType(xhr); 6816 xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX); 6817 6818 //some webkit based mobile browsers do not follow the w3c spec of 6819 // setting the accept headers automatically 6820 if (this._RT.browser.isWebKit) { 6821 xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 6822 } 6823 this._sendEvent("BEGIN"); 6824 //Check if it is a custom form data object 6825 //if yes we use makefinal for the final handling 6826 if (formData && formData.makeFinal) { 6827 formData = formData.makeFinal() 6828 } 6829 xhr.send((this._ajaxType != "GET") ? formData : null); 6830 6831 } catch (e) { 6832 //_onError//_onError 6833 e = (e._mfInternal) ? e : this._Lang.makeException(new Error(), "sendError", "sendError", this._nameSpace, "send", e.message); 6834 this._stdErrorHandler(this._xhr, this._context, e); 6835 } finally { 6836 //no finally possible since the iframe uses real asynchronousity 6837 } 6838 }, 6839 6840 _applyClientWindowId:function () { 6841 var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow"); 6842 //pass through if exists already set by _Impl 6843 if ('undefined' != typeof this._context._mfInternal._clientWindow) { 6844 this._context._mfInternal._clientWindowOld = clientWindow.value; 6845 clientWindow.value = this._context._mfInternal._clientWindow; 6846 } else { 6847 if(clientWindow) { 6848 this._context._mfInternal._clientWindowDisabled = !! clientWindow.disabled; 6849 clientWindow.disabled = true; 6850 } 6851 } 6852 }, 6853 6854 _restoreClientWindowId:function () { 6855 //we have to reset the client window back to its original state 6856 6857 var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow"); 6858 if(!clientWindow) { 6859 return; 6860 } 6861 if ('undefined' != typeof this._context._mfInternal._clientWindowOld) { 6862 clientWindow.value = this._context._mfInternal._clientWindow; 6863 } 6864 if('undefined' != typeof this._context._mfInternal._clientWindowDisabled) { 6865 //we reset it to the old value 6866 clientWindow.disabled = this._context._mfInternal._clientWindowDisabled; 6867 } 6868 }, 6869 6870 /** 6871 * applies the content type, this needs to be done only for xhr 6872 * level1 6873 * @param xhr 6874 * @private 6875 */ 6876 _applyContentType:function (xhr) { 6877 var contentType = this._contentType + "; charset=utf-8"; 6878 xhr.setRequestHeader(this._CONTENT_TYPE, contentType); 6879 }, 6880 6881 ondone:function () { 6882 this._requestDone(); 6883 }, 6884 6885 onsuccess:function (/*evt*/) { 6886 this._restoreClientWindowId(); 6887 var context = this._context; 6888 var xhr = this._xhr; 6889 try { 6890 this._sendEvent("COMPLETE"); 6891 //now we have to reroute into our official api 6892 //because users might want to decorate it, we will split it apart afterwards 6893 6894 context._mfInternal = context._mfInternal || {}; 6895 jsf.ajax.response((xhr.getXHRObject) ? xhr.getXHRObject() : xhr, context); 6896 6897 } catch (e) { 6898 this._stdErrorHandler(this._xhr, this._context, e); 6899 6900 //add for xhr level2 support 6901 } finally { 6902 //W3C spec onloadend must be called no matter if success or not 6903 this.ondone(); 6904 } 6905 }, 6906 6907 onerror:function (/*evt*/) { 6908 this._restoreClientWindowId(); 6909 //TODO improve the error code detection here regarding server errors etc... 6910 //and push it into our general error handling subframework 6911 var context = this._context; 6912 var xhr = this._xhr; 6913 var _Lang = this._Lang; 6914 6915 var errorText = ""; 6916 this._sendEvent("COMPLETE"); 6917 try {
6918 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 6919 //status can be 0 and statusText can be "" 6920 var status = ('undefined' != xhr.status && null != xhr.status) ? xhr.status : UNKNOWN; 6921 var statusText = ('undefined' != xhr.statusText && null != xhr.statusText) ? xhr.statusText : UNKNOWN; 6922 errorText = _Lang.getMessage("ERR_REQU_FAILED", null, status, statusText); 6923 6924 } catch (e) { 6925 errorText = _Lang.getMessage("ERR_REQ_FAILED_UNKNOWN", null); 6926 } finally { 6927 try { 6928 var _Impl = this.attr("impl"); 6929 _Impl.sendError(xhr, context, _Impl.HTTPERROR, 6930 _Impl.HTTPERROR, errorText, "", "myfaces._impl.xhrCore._AjaxRequest", "onerror"); 6931 } finally { 6932 //add for xhr level2 support 6933 //since chrome does not call properly the onloadend we have to do it manually 6934 //to eliminate xhr level1 for the compile profile modern 6935 //W3C spec onloadend must be called no matter if success or not 6936 this.ondone(); 6937 } 6938 } 6939 //_onError 6940 }, 6941 6942 onprogress:function (/*evt*/) { 6943 //do nothing for now 6944 }, 6945 6946 ontimeout:function (/*evt*/) { 6947 try { 6948 this._restoreClientWindowId(); 6949 //we issue an event not an error here before killing the xhr process 6950 this._sendEvent("TIMEOUT_EVENT"); 6951 //timeout done we process the next in the queue 6952 } finally { 6953 this._requestDone(); 6954 } 6955 }, 6956 6957 _formDataToURI:function (formData) { 6958 if (formData && formData.makeFinal) { 6959 formData = formData.makeFinal() 6960 } 6961 return formData; 6962 }, 6963 6964 _getTransport:function () { 6965 6966 var xhr = this._RT.getXHRObject(); 6967 //the current xhr level2 timeout w3c spec is not implemented by the browsers yet 6968 //we have to do a fallback to our custom routines 6969 6970 //add for xhr level2 support 6971 //Chrome fails in the current builds, on our loadend, we disable the xhr 6972 //level2 optimisations for now 6973 if (/*('undefined' == typeof this._timeout || null == this._timeout) &&*/ this._RT.getXHRLvl() >= 2) { 6974 //no timeout we can skip the emulation layer 6975 return xhr; 6976 } 6977 return new myfaces._impl.xhrCore.engine.Xhr1({xhrObject:xhr}); 6978 }, 6979 6980 //----------------- backported from the base request -------------------------------- 6981 //non abstract ones 6982 /** 6983 * Spec. 13.3.1 6984 * Collect and encode input elements. 6985 * Additionally the hidden element javax.faces.ViewState 6986 * 6987 * 6988 * @return an element of formDataWrapper 6989 * which keeps the final Send Representation of the 6990 */ 6991 getFormData:function () { 6992 var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces; 6993 return this._Lang.createFormDataDecorator(jsf.getViewState(this._sourceForm)); 6994 }, 6995 6996 /** 6997 * Client error handlers which also in the long run route into our error queue 6998 * but also are able to deliver more meaningful messages 6999 * note, in case of an error all subsequent xhr requests are dropped 7000 * to get a clean state on things 7001 * 7002 * @param request the xhr request object 7003 * @param context the context holding all values for further processing 7004 * @param exception the embedded exception 7005 */ 7006 _stdErrorHandler:function (request, context, exception) { 7007 var xhrQueue = this._xhrQueue; 7008 try { 7009 this.attr("impl").stdErrorHandler(request, context, exception); 7010 } finally { 7011 if (xhrQueue) { 7012 xhrQueue.cleanup(); 7013 } 7014 } 7015 }, 7016 7017 _sendEvent:function (evtType) { 7018 var _Impl = this.attr("impl"); 7019 _Impl.sendEvent(this._xhr, this._context, _Impl[evtType]); 7020 }, 7021 7022 _requestDone:function () { 7023 var queue = this._xhrQueue; 7024 if (queue) { 7025 queue.processQueue(); 7026 } 7027 //ie6 helper cleanup 7028 delete this._context.source; 7029 this._finalize(); 7030 }, 7031 7032 //cleanup 7033 _finalize:function () { 7034 if (this._xhr.readyState == this._XHR_CONST.READY_STATE_DONE) { 7035 this._callSuper("_finalize"); 7036 } 7037 } 7038}); 7039 7040 7041/* Licensed to the Apache Software Foundation (ASF) under one or more 7042 * contributor license agreements. See the NOTICE file distributed with 7043 * this work for additional information regarding copyright ownership. 7044 * The ASF licenses this file to you under the Apache License, Version 2.0 7045 * (the "License");
7045 you may not use this file except in compliance with 7046 * the License. You may obtain a copy of the License at 7047 * 7048 * http://www.apache.org/licenses/LICENSE-2.0 7049 * 7050 * Unless required by applicable law or agreed to in writing, software 7051 * distributed under the License is distributed on an "AS IS" BASIS, 7052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7053 * See the License for the specific language governing permissions and 7054 * limitations under the License. 7055 */ 7056/** 7057 * this method is used only for pure multipart form parts 7058 * otherwise the normal method is used 7059 * IT is a specialized request which uses the form data 7060 * element for the handling of forms 7061 */ 7062_MF_CLS(_PFX_XHR + "_MultipartAjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, { 7063 7064 _sourceForm:null, 7065 7066 constructor_:function (arguments) { 7067 this._callSuper("constructor_", arguments); 7068 //TODO xhr level2 can deal with real props 7069 7070 }, 7071 7072 getFormData:function () { 7073 var ret; 7074 //in case of a multipart form post we savely can use the FormData object 7075 if (this._context._mfInternal.xhrOp === "multipartQueuedPost") { 7076 ret = new FormData(this._sourceForm); 7077 this._AJAXUTIL.appendIssuingItem(this._source, ret); 7078 } else { 7079 //we switch back to the encode submittable fields system 7080 this._AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, null); 7081 this._AJAXUTIL.appendIssuingItem(this._source, ret); 7082 } 7083 return ret; 7084 }, 7085 7086 /** 7087 * applies the content type, this needs to be done only for xhr 7088 * level1 7089 * @param xhr 7090 * @private 7091 */ 7092 _applyContentType:function (xhr) { 7093 //content type is not set in case of xhr level2 because 7094 //the form data object does it itself 7095 }, 7096 7097 _formDataToURI:function (formData) { 7098 //in xhr level2 form data takes care of the http get parametrisation 7099 return ""; 7100 }, 7101 7102 _getTransport:function () { 7103 return new XMLHttpRequest(); 7104 } 7105}); 7106 7107/** 7108 * for normal requests we basically use 7109 * only the xhr level2 object but 7110 */ 7111_MF_CLS(_PFX_XHR + "_AjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, { 7112 7113 _sourceForm:null, 7114 7115 constructor_:function (arguments) { 7116 this._callSuper("constructor_", arguments); 7117 //TODO xhr level2 can deal with real props 7118 7119 }, 7120 7121 _getTransport:function () { 7122 return new XMLHttpRequest(); 7123 } 7124}); 7125 7126 7127 7128 7129 7130/* Licensed to the Apache Software Foundation (ASF) under one or more 7131 * contributor license agreements. See the NOTICE file distributed with 7132 * this work for additional information regarding copyright ownership. 7133 * The ASF licenses this file to you under the Apache License, Version 2.0 7134 * (the "License"); you may not use this file except in compliance with 7135 * the License. You may obtain a copy of the License at 7136 * 7137 * http://www.apache.org/licenses/LICENSE-2.0 7138 * 7139 * Unless required by applicable law or agreed to in writing, software 7140 * distributed under the License is distributed on an "AS IS" BASIS, 7141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7142 * See the License for the specific language governing permissions and 7143 * limitations under the License. 7144 */ 7145 7146 7147/** 7148 * @class 7149 * @name _IFrameRequest 7150 * @memberOf myfaces._impl.xhrCore 7151 * @extends myfaces._impl.xhrCore._AjaxRequest 7152 * @description specialized implementation of the jsf js ajax request class 7153 * which utilizes an iframe transport for communications to the server 7154 */ 7155_MF_CLS(_PFX_XHR+"_IFrameRequest", myfaces._impl.xhrCore._AjaxRequest, 7156 /** @lends myfaces._impl.xhrCore._IFrameRequest.prototype */ 7157 { 7158 7159 /** 7160 * @constant 7161 * @description request marker that the request is an iframe based request 7162 */ 7163 //JX_PART_IFRAME: "javax.faces.partial.iframe", 7164 /** 7165 * @constant 7166 * @description request marker that the request is an apache myfaces iframe request based request 7167 */ 7168 MF_PART_IFRAME: "javax.faces.transport.iframe", 7169 7170 MF_PART_FACES_REQUEST: "javax.faces.request", 7171 7172 7173 constructor_: function(arguments) { 7174 this._callSuper("constructor_", arguments); 7175 }, 7176 7177 getFormData: function() { 7178 var ret = new myfaces._impl.xhrCore.engine.FormData(this._sourceForm); 7179 //marker that this is an ajax iframe request 7180 //ret.append(this.JX_PART_IFRAME, "true"); 7181 ret.append(this.MF_PART_IFRAME, "true"); 7182 ret.append(this.MF_PART_FACES_REQUEST, "partial/ajax"); 7183 7184 var viewState = decodeURIComponent(jsf.getViewState(this._sourceForm)); 7185 viewState = viewState.split("&"); 7186 7187 //we append all viewstate values which are not part of the original form 7188 //just in case getViewState is decorated 7189 for(var cnt = 0, len = viewState.length; cnt < len; cnt++) { 7190 var currViewState = viewState[cnt]; 7191 var keyVal = currViewState.split("="); 7192 var name = keyVal[0]; 7193 if(!this._Dom.getNamedElementFromForm(this._sourceForm, name)) { 7194 ret.append(name, keyVal[1]); 7195 } 7196 } 7197 7198 return ret; 7199 }, 7200 7201 _formDataToURI: function(/*formData*/) { 7202 //http get alwyays sends the form data 7203 return ""; 7204 }, 7205 7206 _getTransport: function() { 7207 return new myfaces._impl.xhrCore.engine.IFrame(); 7208 } 7209 7210}); 7211/* Licensed to the Apache Software Foundation (ASF) under one or more 7212 * contributor license agreements. See the NOTICE file distributed with 7213 * this work for additional information regarding copyright ownership. 7214 * The ASF licenses this file to you under the Apache License, Version 2.0 7215 * (the "License");
7215 you may not use this file except in compliance with 7216 * the License. You may obtain a copy of the License at 7217 * 7218 * http://www.apache.org/licenses/LICENSE-2.0 7219 * 7220 * Unless required by applicable law or agreed to in writing, software 7221 * distributed under the License is distributed on an "AS IS" BASIS, 7222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7223 * See the License for the specific language governing permissions and 7224 * limitations under the License. 7225 */ 7226 7227/** 7228 * @class 7229 * @name _AjaxResponse 7230 * @memberOf myfaces._impl.xhrCore 7231 * @extends myfaces._impl.core.Object 7232 * @description 7233 * This singleton is responsible for handling the standardized xml ajax response 7234 * Note: since the semantic processing can be handled about 90% in a functional 7235 * style we make this class stateless. Every state information is stored 7236 * temporarily in the context. 7237 * 7238 * The singleton approach also improves performance 7239 * due to less object gc compared to the old instance approach. 7240 * 7241 */ 7242_MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxResponse.prototype */ { 7243 7244 /*partial response types*/ 7245 RESP_PARTIAL:"partial-response", 7246 RESP_TYPE_ERROR:"error", 7247 RESP_TYPE_REDIRECT:"redirect", 7248 RESP_TYPE_CHANGES:"changes", 7249 7250 /*partial commands*/ 7251 CMD_CHANGES:"changes", 7252 CMD_UPDATE:"update", 7253 CMD_DELETE:"delete", 7254 CMD_INSERT:"insert", 7255 CMD_EVAL:"eval", 7256 CMD_ERROR:"error", 7257 CMD_ATTRIBUTES:"attributes", 7258 CMD_EXTENSION:"extension", 7259 CMD_REDIRECT:"redirect", 7260 7261 /*other constants*/ 7262 P_VIEWSTATE:"javax.faces.ViewState", 7263 P_CLIENTWINDOW: "javax.faces.ClientWindow", 7264 P_VIEWROOT:"javax.faces.ViewRoot", 7265 P_VIEWHEAD:"javax.faces.ViewHead", 7266 P_VIEWBODY:"javax.faces.ViewBody", 7267 P_RESOURCE:"javax.faces.Resource", 7268 7269 /** 7270 * uses response to start Html element replacement 7271 * 7272 * @param {Object} request (xhrRequest) - xhr request object 7273 * @param {Object} context (Map) - AJAX context 7274 * 7275 * A special handling has to be added to the update cycle 7276 * according to the JSDoc specs if the CDATA block contains html tags the outer rim must be stripped 7277 * if the CDATA block contains a head section the document head must be replaced 7278 * and if the CDATA block contains a body section the document body must be replaced! 7279 * 7280 */ 7281 processResponse:function (request, context) { 7282 //mfinternal handling, note, the mfinternal is only optional 7283 //according to the spec 7284 context._mfInternal = context._mfInternal || {}; 7285 var mfInternal = context._mfInternal; 7286 7287 //the temporary data is hosted here 7288 mfInternal._updateElems = []; 7289 mfInternal._updateForms = []; 7290 mfInternal.appliedViewState = null; 7291 mfInternal.appliedClientWindow = null; 7292 7293 try { 7294 var _Impl = this.attr("impl"), _Lang = this._Lang; 7295 // TODO: 7296 // Solution from 7297 // http://www.codingforums.com/archive/index.php/t-47018.html 7298 // to solve IE error 1072896658 when a Java server sends iso88591 7299 // istead of ISO-8859-1 7300 7301 if (!request || !_Lang.exists(request, "responseXML")) { 7302 throw this.makeException(new Error(), _Impl.EMPTY_RESPONSE, _Impl.EMPTY_RESPONSE, this._nameSpace, "processResponse", ""); 7303 } 7304 //check for a parseError under certain browsers 7305 7306 var xmlContent = request.responseXML; 7307 //ie6+ keeps the parsing response under xmlContent.parserError 7308 //while the rest of the world keeps it as element under the first node 7309 var xmlErr = _Lang.fetchXMLErrorMessage(request.responseText || request.response, xmlContent) 7310 if (xmlErr) { 7311 throw this._raiseError(new Error(), xmlErr.errorMessage + "\n" + xmlErr.sourceText + "\n" + xmlErr.visualError + "\n", "processResponse"); 7312 } 7313 var partials = xmlContent.childNodes[0]; 7314 if ('undefined' == typeof partials || partials == null) { 7315 throw this._raiseError(new Error(), "No child nodes for response", "processResponse"); 7316 7317 } else { 7318 if (partials.tagName != this.RESP_PARTIAL) { 7319 // IE 8 sees XML Header as first sibling ... 7320 partials = partials.nextSibling; 7321 if (!partials || partials.tagName != this.RESP_PARTIAL) { 7322 throw this._raiseError(new Error(), "Partial response not set", "processResponse"); 7323 } 7324 } 7325 } 7326 7327 var childNodesLength = partials.childNodes.length; 7328 7329 for (var loop = 0; loop < childNodesLength; loop++) { 7330 var childNode = partials.childNodes[loop]; 7331 var tagName = childNode.tagName; 7332 /** 7333 * <eval> 7334 * <![CDATA[javascript]]> 7335 * </eval> 7336 */ 7337 7338 //this ought to be enough for eval 7339 //however the run scripts still makes sense 7340 //in the update and insert area for components 7341 //which do not use the response writer properly 7342 //we might add this one as custom option in update and 7343 //insert!
7344 if (tagName == this.CMD_ERROR) { 7345 this.processError(request, context, childNode); 7346 } else if (tagName == this.CMD_REDIRECT) { 7347 this.processRedirect(request, context, childNode); 7348 } else if (tagName == this.CMD_CHANGES) { 7349 this.processChanges(request, context, childNode); 7350 } 7351 } 7352 7353 //fixup missing viewStates due to spec deficiencies 7354 if(mfInternal.appliedViewState) { 7355 this.fixViewStates(context); 7356 } 7357 if(mfInternal.appliedClientWindow) { 7358 this.fixClientWindows(context); 7359 } 7360 7361 //spec jsdoc, the success event must be sent from response 7362 _Impl.sendEvent(request, context, _Impl["SUCCESS"]); 7363 7364 } finally { 7365 delete mfInternal._updateElems; 7366 delete mfInternal._updateForms; 7367 delete mfInternal.appliedViewState; 7368 delete mfInternal.appliedClientWindow; 7369 } 7370 }, 7371 7372 /** 7373 * fixes the viewstates in the current page 7374 * 7375 * @param context 7376 */ 7377 fixViewStates:function (context) { 7378 var _Lang = this._Lang; 7379 var mfInternal = context._mfInternal; 7380 7381 if (null == mfInternal.appliedViewState) { 7382 return; 7383 } 7384 7385 //if we set our no portlet env we safely can update all forms with 7386 //the new viewstate 7387 if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) { 7388 for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) { 7389 this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedViewState, this.P_VIEWSTATE); 7390 } 7391 return; 7392 } 7393 7394 // Now update the forms that were not replaced but forced to be updated, because contains child ajax tags 7395 // we should only update forms with view state hidden field. If by some reason, the form was set to be 7396 // updated but the form was replaced, it does not have hidden view state, so later in changeTrace processing the 7397 // view state is updated. 7398 7399 //set the viewstates of all outer forms parents of our updated elements 7400 7401 _Lang.arrForEach(mfInternal._updateForms, function (elem) { 7402 this._setVSTCWForm(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE); 7403 }, 0, this); 7404 7405 //set the viewstate of all forms within our updated elements 7406 _Lang.arrForEach(mfInternal._updateElems, function (elem) { 7407 this._setVSTCWInnerForms(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE); 7408 }, 0, this); 7409 }, 7410 7411 fixClientWindows:function (context, theForm) { 7412 var _Lang = this._Lang; 7413 var mfInternal = context._mfInternal; 7414 7415 if (null == mfInternal.appliedClientWindow) { 7416 return; 7417 } 7418 //if we set our no portlet env we safely can update all forms with 7419 //the new viewstate 7420 if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) { 7421 for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) { 7422 this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7423 } 7424 return; 7425 } 7426 //set the client window of all outer form of updated elements 7427 7428 _Lang.arrForEach(mfInternal._updateForms, function (elem) { 7429 this._setVSTCWForm(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7430 }, 0, this); 7431 7432 //set the client window of all forms within our updated elements 7433 _Lang.arrForEach(mfInternal._updateElems, function (elem) { 7434 this._setVSTCWInnerForms(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7435 }, 0, this); 7436 }, 7437 7438 /** 7439 * sets the viewstate element in a given form 7440 * 7441 * @param theForm the form to which the element has to be set to 7442 * @param context the current request context 7443 */ 7444 _setVSTCWForm:function (context, theForm, value, identifier) { 7445 theForm = this._Lang.byId(theForm); 7446 var mfInternal = context._mfInternal; 7447 7448 if (!theForm) return; 7449 7450 //in IE7 looking up form elements with complex names (such as 'javax.faces.ViewState') fail
7450s in certain cases 7451 //iterate through the form elements to find the element, instead 7452 var fieldToApply = this._Dom.getNamedElementFromForm(theForm, identifier); 7453 7454 if (fieldToApply) { 7455 this._Dom.setAttribute(fieldToApply, "value", value); 7456 } else if (!fieldToApply) { 7457 var element = this._Dom.getDummyPlaceHolder(); 7458 //spec error, two elements with the same id should not be there, TODO recheck the space if the name does not suffice alone 7459 element.innerHTML = ["<input type='hidden'", "id='", identifier+jsf.separatorchar+Math.random() , "' name='", identifier , "' value='" , value , "' />"].join(""); 7460 //now we go to proper dom handling after having to deal with another ie screwup 7461 try { 7462 theForm.appendChild(element.childNodes[0]); 7463 } finally { 7464 element.innerHTML = ""; 7465 } 7466 } 7467 }, 7468 7469 _setVSTCWInnerForms:function (context, elem, value, identifier) { 7470 7471 var _Lang = this._Lang, _Dom = this._Dom; 7472 elem = _Dom.byIdOrName(elem); 7473 //elem not found for whatever reason 7474 //https://issues.apache.org/jira/browse/MYFACES-3544 7475 if (!elem) return; 7476 7477 var replacedForms = _Dom.findByTagName(elem, "form", false); 7478 7479 var applyVST = _Lang.hitch(this, function (elem) { 7480 this._setVSTCWForm(context, elem, value, identifier); 7481 }); 7482 7483 try { 7484 _Lang.arrForEach(replacedForms, applyVST, 0, this); 7485 } finally { 7486 applyVST = null; 7487 } 7488 }, 7489 7490 /** 7491 * processes an incoming error from the response 7492 * which is hosted under the <error> tag 7493 * @param request the current request 7494 * @param context the contect object 7495 * @param node the node in the xml hosting the error message 7496 */ 7497 processError:function (request, context, node) { 7498 /** 7499 * <error> 7500 * <error-name>String</error-name> 7501 * <error-message><![CDATA[message]]></error-message> 7502 * <error> 7503 */ 7504 var errorName = node.firstChild.textContent || node.firstChild.text || "", 7505 errorMessage = node.childNodes[1].firstChild.data || ""; 7506 7507 this.attr("impl").sendError(request, context, this.attr("impl").SERVER_ERROR, errorName, errorMessage, "myfaces._impl.xhrCore._AjaxResponse", "processError"); 7508 }, 7509 7510 /** 7511 * processes an incoming xml redirect directive from the ajax response 7512 * @param request the request object 7513 * @param context the context 7514 * @param node the node hosting the redirect data 7515 */ 7516 processRedirect:function (request, context, node) { 7517 /** 7518 * <redirect url="url to redirect" /> 7519 */ 7520 var _Lang = this._Lang; 7521 var redirectUrl = node.getAttribute("url"); 7522 if (!redirectUrl) { 7523 throw this._raiseError(new Error(), _Lang.getMessage("ERR_RED_URL", null, "_AjaxResponse.processRedirect"), "processRedirect"); 7524 } 7525 redirectUrl = _Lang.trim(redirectUrl); 7526 if (redirectUrl == "") { 7527 return false; 7528 } 7529 window.location = redirectUrl; 7530 return true; 7531 }, 7532 7533 /** 7534 * main entry point for processing the changes 7535 * it deals with the <changes> node of the 7536 * response 7537 * 7538 * @param request the xhr request object 7539 * @param context the context map 7540 * @param node the changes node to be processed 7541 */ 7542 processChanges:function (request, context, node) { 7543 var changes = node.childNodes; 7544 var _Lang = this._Lang; 7545 //note we need to trace the changes which could affect our insert update or delete 7546 //se that we can realign our ViewStates afterwards 7547 //the realignment must happen post change processing 7548 7549 for (var i = 0; i < changes.length; i++) { 7550 7551 switch (changes[i].tagName) { 7552 7553 case this.CMD_UPDATE: 7554 this.processUpdate(request, context, changes[i]); 7555 break; 7556 case this.CMD_EVAL: 7557 _Lang.globalEval(changes[i].firstChild.data); 7558 break; 7559 case this.CMD_INSERT: 7560 this.processInsert(request, context, changes[i]); 7561 break; 7562 case this.CMD_DELETE: 7563 this.processDelete(request, context, changes[i]); 7564 break; 7565 case this.CMD_ATTRIBUTES: 7566 this.processAttributes(request, context, changes[i]); 7567 break; 7568 case this.CMD_EXTENSION: 7569 break; 7570 default: 7571 throw this._raiseError(new Error(), "_AjaxResponse.processChanges: Illegal Command Issued", "processChanges"); 7572 } 7573 } 7574 7575 return true; 7576 }, 7577 7578 /** 7579 * First sub-step process a pending update tag 7580 * 7581 * @param request the xhr request object 7582 * @param context the context map 7583 * @param node the changes node to be processed 7584 */ 7585 processUpdate:function (request, context, node) { 7586 if ( (node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) || (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) ) { 7587 //update the submitting forms viewstate to the new value 7588 // The source form has to be pulled out of the CURRENT document first because the context object
7589 // may refer to an invalid document if an update of the entire body has occurred before this point. 7590 var mfInternal = context._mfInternal, 7591 fuzzyFormDetection = this._Lang.hitch(this._Dom, this._Dom.fuzzyFormDetection); 7592 var elemId = (mfInternal._mfSourceControlId) ? mfInternal._mfSourceControlId : 7593 ((context.source) ? context.source.id : null); 7594 7595 //theoretically a source of null can be given, then our form detection fails for 7596 //the source element case and hence updateviewstate is skipped for the source 7597 //form, but still render targets still can get the viewstate 7598 var sourceForm = (mfInternal && mfInternal["_mfSourceFormId"] && 7599 document.forms[mfInternal["_mfSourceFormId"]]) ? 7600 document.forms[mfInternal["_mfSourceFormId"]] : ((elemId) ? fuzzyFormDetection(elemId) : null); 7601 7602 if(node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) { 7603 mfInternal.appliedViewState = this._Dom.concatCDATABlocks(node);//node.firstChild.nodeValue; 7604 } else if(node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) { 7605 mfInternal.appliedClientWindow = node.firstChild.nodeValue; 7606 } 7607 //source form could not be determined either over the form identifer or the element 7608 //we now skip this phase and just add everything we need for the fixup code 7609 7610 if (!sourceForm) { 7611 //no source form found is not an error because 7612 //we might be able to recover one way or the other 7613 return true; 7614 } 7615 7616 mfInternal._updateForms.push(sourceForm.id); 7617 7618 } 7619 else { 7620 // response may contain several blocks 7621 var cDataBlock = this._Dom.concatCDATABlocks(node), 7622 resultNode = null, 7623 pushOpRes = this._Lang.hitch(this, this._pushOperationResult); 7624 7625 switch (node.getAttribute('id')) { 7626 case this.P_VIEWROOT: 7627 7628 cDataBlock = cDataBlock.substring(cDataBlock.indexOf("<html")); 7629 7630 var parsedData = this._replaceHead(request, context, cDataBlock); 7631 7632 resultNode = ('undefined' != typeof parsedData && null != parsedData) ? this._replaceBody(request, context, cDataBlock, parsedData) : this._replaceBody(request, context, cDataBlock); 7633 if (resultNode) { 7634 pushOpRes(context, resultNode); 7635 } 7636 break; 7637 case this.P_VIEWHEAD: 7638 //we cannot replace the head, almost no browser allows this, some of them throw errors 7639 //others simply ignore it or replace it and destroy the dom that way! 7640 this._replaceHead(request, context, cDataBlock); 7641 7642 break; 7643 case this.P_VIEWBODY: 7644 //we assume the cdata block is our body including the tag 7645 resultNode = this._replaceBody(request, context, cDataBlock); 7646 if (resultNode) { 7647 pushOpRes(context, resultNode); 7648 } 7649 break; 7650 7651 case this.P_RESOURCE: 7652 this._addResourceToHead(request, context, cDataBlock); 7653 break; 7654 7655 default: 7656 resultNode = this.replaceHtmlItem(request, context, node.getAttribute('id'), cDataBlock); 7657 if (resultNode) { 7658 pushOpRes(context, resultNode); 7659 } 7660 break; 7661 } 7662 } 7663 7664 return true; 7665 }, 7666 7667 _pushOperationResult:function (context, resultNode) { 7668 var mfInternal = context._mfInternal; 7669 var pushSubnode = this._Lang.hitch(this, function (currNode) { 7670 var parentForm = this._Dom.getParent(currNode, "form"); 7671 //if possible we work over the ids 7672 //so that elements later replaced are referenced 7673 //at the latest possibility 7674 if (null != parentForm) { 7675 mfInternal._updateForms.push(parentForm.id || parentForm); 7676 } 7677 else { 7678 mfInternal._updateElems.push(currNode.id || currNode); 7679 } 7680 }); 7681 var isArr = 'undefined' != typeof resultNode.length && 'undefined' == typeof resultNode.nodeType; 7682 if (isArr && resultNode.length) { 7683 for (var cnt = 0; cnt < resultNode.length; cnt++) { 7684 pushSubnode(resultNode[cnt]); 7685 } 7686 } else if (!isArr) { 7687 pushSubnode(resultNode); 7688 } 7689 7690 }, 7691 7692 /** 7693 * replaces a current head theoretically, 7694 * pratically only the scripts are evaled anew since nothing else 7695 * can be changed. 7696 * 7697 * @param request the current request 7698 * @param context the ajax context
7699 * @param newData the data to be processed 7700 * 7701 * @return an xml representation of the page for further processing if possible 7702 */ 7703 _replaceHead:function (request, context, newData) { 7704 7705 var _Lang = this._Lang, 7706 _Dom = this._Dom, 7707 isWebkit = this._RT.browser.isWebKit, 7708 //we have to work around an xml parsing bug in Webkit 7709 //see https://issues.apache.org/jira/browse/MYFACES-3061 7710 doc = (!isWebkit) ? _Lang.parseXML(newData) : null, 7711 newHead = null; 7712 7713 if (!isWebkit && _Lang.isXMLParseError(doc)) { 7714 doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->")); 7715 } 7716 7717 if (isWebkit || _Lang.isXMLParseError(doc)) { 7718 //the standard xml parser failed we retry with the stripper 7719 var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7720 var headData = parser.parse(newData, "head"); 7721 //We cannot avoid it here, but we have reduced the parsing now down to the bare minimum 7722 //for further processing 7723 newHead = _Lang.parseXML("<head>" + headData + "</head>"); 7724 //last and slowest option create a new head element and let the browser 7725 //do its slow job 7726 if (_Lang.isXMLParseError(newHead)) { 7727 try { 7728 newHead = _Dom.createElement("head"); 7729 newHead.innerHTML = headData; 7730 } catch (e) { 7731 //we give up no further fallbacks 7732 throw this._raiseError(new Error(), "Error head replacement failed reason:" + e.toString(), "_replaceHead"); 7733 } 7734 } 7735 } else { 7736 //parser worked we go on 7737 newHead = doc.getElementsByTagName("head")[0]; 7738 } 7739 7740 var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"link":true, "style":true}); 7741 _Dom.runCss(newHead, true); 7742 _Dom.deleteItems(oldTags); 7743 7744 //var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"script": true}); 7745 //_Dom.deleteScripts(oldTags); 7746 _Dom.runScripts(newHead, true); 7747 7748 return doc; 7749 }, 7750 7751 _alreadyHasHeadResource: function (tag, attr, newData) { 7752 if (newData.indexOf("<" + tag + " ") >= 0) { 7753 var attrPos = newData.indexOf(" " + attr + "=\""); 7754 if (attrPos >= 0) { 7755 var attrStartPos = newData.indexOf("\"", attrPos); 7756 var attrEndPos = newData.indexOf("\"", attrStartPos+1); 7757 var attrValue = newData.substring(attrStartPos+1, attrEndPos); 7758 attrValue = attrValue.replace("&", "&"); 7759 var selector = "head " + tag + "[" + attr + "='" + attrValue + "']"; 7760 var resource = document.querySelector(selector); 7761 if (resource) return true; 7762 } 7763 } 7764 return false; 7765 }, 7766 7767 _addResourceToHead: function (request, context, newData) { 7768 if (this._alreadyHasHeadResource("script", "src", newData)){ 7769 return; 7770 }; 7771 7772 if (this._alreadyHasHeadResource("link", "href", newData)){ 7773 return; 7774 }; 7775 7776 var lastHeadElement = document.getElementsByTagName("head")[0].lastChild; 7777 this._Dom.insertAfter(lastHeadElement, newData); 7778 }, 7779 7780 /** 7781 * special method to handle the body dom manipulation, 7782 * replacing the entire body does not work fully by simply adding a second body 7783 * and by creating a range instead we have to work around that by dom creating a second 7784 * body and then filling it properly! 7785 * 7786 * @param {Object} request our request object 7787 * @param {Object} context (Map) the response context 7788 * @param {String} newData the markup which replaces the old dom node! 7789 * @param {Node} parsedData (optional) preparsed XML representation data of the current document 7790 */ 7791 _replaceBody:function (request, context, newData /*varargs*/) { 7792 var _RT = this._RT, 7793 _Dom = this._Dom, 7794 _Lang = this._Lang, 7795 7796 oldBody = document.getElementsByTagName("body")[0], 7797 placeHolder = document.createElement("div"), 7798 isWebkit = _RT.browser.isWebKit; 7799 7800 placeHolder.id = "myfaces_bodyplaceholder"; 7801 7802 _Dom._removeChildNodes(oldBody); 7803 oldBody.innerHTML = ""; 7804 oldBody.appendChild(placeHolder); 7805 7806 var bodyData, doc = null, parser; 7807 7808 //we have to work around an xml parsing bug in Webkit 7809 //see https://issues.apache.org/jira/browse/MYFACES-3061 7810 if (!isWebkit) { 7811 doc = (arguments.length > 3) ? arguments[3] : _Lang.parseXML(newData); 7812 } 7813 7814 if (!isWebkit && _Lang.isXMLParseError(doc)) { 7815 doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->")); 7816 } 7817 7818 if (isWebkit || _Lang.isXMLParseError(doc)) { 7819 //the standard xml parser failed we retry with the stripper 7820 7821 parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7822 7823 bodyData = parser.parse(newData, "body"); 7824 } else { 7825 //parser worked we go on 7826 var newBodyData = doc.getElementsByTagName("body")[0]; 7827 7828 //speedwise we serialize back into the code 7829 //for code reduction, speedwise we will take a small hit 7830 //there which we will clean up in the future, but for now 7831 //this is ok, I guess, since replace body only is a small subcase 7832 //bodyData = _Lang.serializeChilds(newBodyData); 7833 var browser = _RT.browser; 7834 if (!browser.isIEMobile || browser.isIEMobile >= 7) { 7835 //TODO check what is failing there 7836 for (var cnt = 0; cnt < newBodyData.attributes.length; cnt++) { 7837 var value = newBodyData.attributes[cnt].value; 7838 if (value) 7839 _Dom.setAttribute(oldBody, newBodyData.attributes[cnt].name, value); 7840 } 7841 } 7842 } 7843 //we cannot serialize here, due to escape problems 7844 //we must parse, this is somewhat unsafe but should be safe enough 7845 parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7846 bodyData = parser.parse(newData, "body"); 7847 7848 var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData); 7849 7850 if (returnedElement) { 7851 this._pushOperationResult(context, returnedElement); 7852 } 7853 return returnedElement; 7854 }, 7855 7856 /** 7857 * Replaces HTML elements through others and handle errors if the occur in the replacement part 7858 * 7859 * @param {Object} request (xhrRequest) 7860 * @param {Object} context (Map) 7861 * @param {Object} itemIdToReplace (String|Node) - ID of the element to replace 7862 * @param {String} markup - the new tag 7863 */ 7864 replaceHtmlItem:function (request, context, itemIdToReplace, markup) { 7865 var _Lang = this._Lang, _Dom = this._Dom; 7866 7867 var item = (!_Lang.isString(itemIdToReplace)) ? itemIdToReplace : 7868 _Dom.byIdOrName(itemIdToReplace); 7869 7870 if (!item) {
7871 throw this._raiseError(new Error(), _Lang.getMessage("ERR_ITEM_ID_NOTFOUND", null, "_AjaxResponse.replaceHtmlItem", (itemIdToReplace) ? itemIdToReplace.toString() : "undefined"), "replaceHtmlItem"); 7872 } 7873 return _Dom.outerHTML(item, markup, this._RT.getLocalOrGlobalConfig(context, "preserveFocus", false)); 7874 }, 7875 7876 /** 7877 * xml insert command handler 7878 * 7879 * @param request the ajax request element 7880 * @param context the context element holding the data 7881 * @param node the xml node holding the insert data 7882 * @return true upon successful completion, false otherwise 7883 * 7884 **/ 7885 processInsert:function (request, context, node) { 7886 /*remapping global namespaces for speed and readability reasons*/ 7887 var _Dom = this._Dom, 7888 _Lang = this._Lang, 7889 //determine which path to go: 7890 insertData = this._parseInsertData(request, context, node); 7891 7892 if (!insertData) return false; 7893 7894 var opNode = _Dom.byIdOrName(insertData.opId); 7895 if (!opNode) { 7896 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_INSERTBEFID_1", null, "_AjaxResponse.processInsert", insertData.opId), "processInsert"); 7897 } 7898 7899 //call insertBefore or insertAfter in our dom routines 7900 var replacementFragment = _Dom[insertData.insertType](opNode, insertData.cDataBlock); 7901 if (replacementFragment) { 7902 this._pushOperationResult(context, replacementFragment); 7903 } 7904 return true; 7905 }, 7906 7907 /** 7908 * determines the corner data from the insert tag parsing process 7909 * 7910 * 7911 * @param request request 7912 * @param context context 7913 * @param node the current node pointing to the insert tag 7914 * @return false if the parsing failed, otherwise a map with follwing attributes 7915 * <ul> 7916 * <li>inserType - a ponter to a constant which maps the direct function name for the insert operation </li> 7917 * <li>opId - the before or after id </li> 7918 * <li>cDataBlock - the html cdata block which needs replacement </li> 7919 * </ul> 7920 * 7921 * TODO we have to find a mechanism to replace the direct sendError calls with a javascript exception 7922 * which we then can use for cleaner error code handling 7923 */ 7924 _parseInsertData:function (request, context, node) { 7925 var _Lang = this._Lang, 7926 _Dom = this._Dom, 7927 concatCDATA = _Dom.concatCDATABlocks, 7928 7929 INSERT_TYPE_BEFORE = "insertBefore", 7930 INSERT_TYPE_AFTER = "insertAfter", 7931 7932 id = node.getAttribute("id"), 7933 beforeId = node.getAttribute("before"), 7934 afterId = node.getAttribute("after"), 7935 ret = {}; 7936 7937 //now we have to make a distinction between two different parsing paths 7938 //due to a spec malalignment 7939 //a <insert id="... beforeId|AfterId ="... 7940 //b <insert><before id="..., <insert> <after id=".... 7941 //see https://issues.apache.org/jira/browse/MYFACES-3318 7942 //simple id, case1 7943 if (id && beforeId && !afterId) { 7944 ret.insertType = INSERT_TYPE_BEFORE; 7945 ret.opId = beforeId; 7946 ret.cDataBlock = concatCDATA(node); 7947 7948 //<insert id=".. afterId=".. 7949 } else if (id && !beforeId && afterId) { 7950 ret.insertType = INSERT_TYPE_AFTER; 7951 ret.opId = afterId; 7952 ret.cDataBlock = concatCDATA(node); 7953 7954 //<insert><before id="... <insert><after id="... 7955 } else if (!id) { 7956 var opType = node.childNodes[0].tagName; 7957 7958 if (opType != "before" && opType != "after") { 7959 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_INSERTBEFID"), "_parseInsertData"); 7960 } 7961 opType = opType.toLowerCase(); 7962 var beforeAfterId = node.childNodes[0].getAttribute("id"); 7963 ret.insertType = (opType == "before") ? INSERT_TYPE_BEFORE : INSERT_TYPE_AFTER; 7964 ret.opId = beforeAfterId; 7965 ret.cDataBlock = concatCDATA(node.childNodes[0]); 7966 } else {
7967 throw this._raiseError(new Error(), [_Lang.getMessage("ERR_PPR_IDREQ"), 7968 "\n ", 7969 _Lang.getMessage("ERR_PPR_INSERTBEFID")].join(""), "_parseInsertData"); 7970 } 7971 ret.opId = _Lang.trim(ret.opId); 7972 return ret; 7973 }, 7974 7975 processDelete:function (request, context, node) { 7976 7977 var _Lang = this._Lang, 7978 _Dom = this._Dom, 7979 deleteId = node.getAttribute('id'); 7980 7981 if (!deleteId) { 7982 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_UNKNOWNCID", null, "_AjaxResponse.processDelete", ""), "processDelete"); 7983 } 7984 7985 var item = _Dom.byIdOrName(deleteId); 7986 if (!item) { 7987 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_UNKNOWNCID", null, "_AjaxResponse.processDelete", deleteId), "processDelete"); 7988 } 7989 7990 var parentForm = this._Dom.getParent(item, "form"); 7991 if (null != parentForm) { 7992 context._mfInternal._updateForms.push(parentForm); 7993 } 7994 _Dom.deleteItem(item); 7995 7996 return true; 7997 }, 7998 7999 processAttributes:function (request, context, node) { 8000 //we now route into our attributes function to bypass 8001 //IE quirks mode incompatibilities to the biggest possible extent 8002 //most browsers just have to do a setAttributes but IE 8003 //behaves as usual not like the official standard 8004 //myfaces._impl._util.this._Dom.setAttribute(domNode, attribute, value; 8005 8006 var _Lang = this._Lang, 8007 //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes> 8008 elemId = node.getAttribute('id'); 8009 8010 if (!elemId) { 8011 throw this._raiseError(new Error(), "Error in attributes, id not in xml markup", "processAttributes"); 8012 } 8013 var childNodes = node.childNodes; 8014 8015 if (!childNodes) { 8016 return false; 8017 } 8018 for (var loop2 = 0; loop2 < childNodes.length; loop2++) { 8019 var attributesNode = childNodes[loop2], 8020 attrName = attributesNode.getAttribute("name"), 8021 attrValue = attributesNode.getAttribute("value"); 8022 8023 if (!attrName) { 8024 continue; 8025 } 8026 8027 attrName = _Lang.trim(attrName); 8028 /*no value means reset*/ 8029 //value can be of boolean value hence full check 8030 if ('undefined' == typeof attrValue || null == attrValue) { 8031 attrValue = ""; 8032 } 8033 8034 switch (elemId) { 8035 case this.P_VIEWROOT: 8036 throw this._raiseError(new Error(), _Lang.getMessage("ERR_NO_VIEWROOTATTR", null, "_AjaxResponse.processAttributes"), "processAttributes"); 8037 8038 case this.P_VIEWHEAD: 8039 throw this._raiseError(new Error(), _Lang.getMessage("ERR_NO_HEADATTR", null, "_AjaxResponse.processAttributes"), "processAttributes"); 8040 8041 case this.P_VIEWBODY: 8042 var element = document.getElementsByTagName("body")[0]; 8043 this._Dom.setAttribute(element, attrName, attrValue); 8044 break; 8045 8046 default: 8047 this._Dom.setAttribute(document.getElementById(elemId), attrName, attrValue); 8048 break; 8049 } 8050 } 8051 return true; 8052 }, 8053 8054 /** 8055 * internal helper which raises an error in the 8056 * format we need for further processing 8057 * 8058 * @param message the message 8059 * @param title the title of the error (optional) 8060 * @param name the name of the error (optional) 8061 */ 8062 _raiseError:function (error, message, caller, title, name) { 8063 var _Impl = this.attr("impl"); 8064 var finalTitle = title || _Impl.MALFORMEDXML; 8065 var finalName = name || _Impl.MALFORMEDXML; 8066 var finalMessage = message || ""; 8067 8068 return this._Lang.makeException(error, finalTitle, finalName, this._nameSpace, caller || ( (arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMe
8068ssage); 8069 } 8070}); 8071 8072/* Licensed to the Apache Software Foundation (ASF) under one or more 8073 * contributor license agreements. See the NOTICE file distributed with 8074 * this work for additional information regarding copyright ownership. 8075 * The ASF licenses this file to you under the Apache License, Version 2.0 8076 * (the "License"); you may not use this file except in compliance with 8077 * the License. You may obtain a copy of the License at 8078 * 8079 * http://www.apache.org/licenses/LICENSE-2.0 8080 * 8081 * Unless required by applicable law or agreed to in writing, software 8082 * distributed under the License is distributed on an "AS IS" BASIS, 8083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8084 * See the License for the specific language governing permissions and 8085 * limitations under the License. 8086 */ 8087 8088/** 8089 * @class 8090 * @name _Transports 8091 * @memberOf myfaces._impl.xhrCore 8092 * @description 8093 * 8094 * The xhr core adapter 8095 * which provides the transport mechanisms to the calling 8096 * objects, and controls the queue behavior, the error handling 8097 * and partial page submit functionality among other things 8098 * <p /> 8099 * The idea behind this is to make the ajax request object as barebones 8100 * as possible and shift the extra functionality like queuing 8101 * parameter handling etc... to this class so that our transports become more easily 8102 * pluggable. This should keep the path open to iframe submits and other transport layers 8103 * <p /> 8104 * the call to the corresponding transport just should be a 8105 * transport.xhrQueuedPost <br /> 8106 * or transport.xhrPost,transport.xhrGet etc... in the future 8107 * <p /> 8108 * Note we have taken a pattern lesson or two from the dojo toolkit and its excellent handling 8109 * of transports by our patterns here (which is mainly a centralized transport singleton which routes 8110 * to different transport implementations and the auto passing of parameters into their 8111 * corresponding protected attributes on class level in the transports themselves) 8112 */ 8113_MF_SINGLTN(_PFX_XHR + "_Transports", _MF_OBJECT, 8114 /** @lends myfaces._impl.xhrCore._Transports.prototype */ { 8115 8116 _PAR_ERRORLEVEL:"errorlevel", 8117 _PAR_QUEUESIZE:"queuesize", 8118 _PAR_PPS:"pps", 8119 _PAR_TIMEOUT:"timeout", 8120 _PAR_DELAY:"delay", 8121 8122 8123 /** 8124 * a singleton queue 8125 * note the structure of our inheritance 8126 * is that that _queue is attached to prototype 8127 * and hence the pointer to the request qeue 8128 * is shared over all instances 8129 * 8130 * if you need to have it per instance for complex objects 8131 * you have to initialize in the constructor 8132 * 8133 * (This is the same limitation dojo class inheritance 8134 * where our inheritance pattern is derived from has) 8135 */ 8136 _q: new myfaces._impl.xhrCore._AjaxRequestQueue(), 8137 8138 /** 8139 * xhr post with enqueuing as defined by the jsf 2.0 specification 8140 * 8141 * mapped options already have the exec and view properly in place 8142 * myfaces specifics can be found under mappedOptions.myFaces 8143 * @param {Node} source the source of this call 8144 * @param {Node} sourceForm the html form which is the source of this call 8145 * @param {Object} context (Map) the internal pass through context 8146 * @param {Object} passThrgh (Map) values to be passed through 8147 **/ 8148 xhrQueuedPost : function(source, sourceForm, context, passThrgh) { 8149 context._mfInternal.xhrOp = "xhrQueuedPost"; 8150 this._q.enqueue( 8151 new (this._getAjaxReqClass(context))(this._getArguments(source, sourceForm, context, passThrgh))); 8152 }, 8153 8154 /** 8155 * iframe queued post 8156 * 8157 * mapped options already have the exec and view properly in place 8158 * myfaces specifics can be found under mappedOptions.myFaces 8159 * @param {Node} source the source of this call 8160 * @param {Node} sourceForm the html form which is the source of this call 8161 * @param {Object} context (Map) the internal pass through context 8162 * @param {Object} passThrgh (Map) values to be passed through 8163 **/ 8164 multipartQueuedPost : function(source, sourceForm, context, passThrgh) { 8165 context._mfInternal.xhrOp = "multipartQueuedPost"; 8166 var args = this._getArguments(source, sourceForm, context, passThrgh); 8167 // note in get the timeout is not working delay however is and queue size as well 8168 // since there are no cross browser ways to resolve a timeout on xhr level 8169 this._q.enqueue( 8170 new (this._getMultipartReqClass(context))(args)); 8171 }, 8172 8173 8174 /** 8175 * creates the arguments map and 8176 * fetches the config params in a proper way in to 8177 * deal with them in a flat way (from the nested context way) 8178 * 8179 * @param source the source of the request 8180 * @param sourceForm the sourceform 8181 * @param context the context holding all values 8182 * @param passThrgh the passThrough values to be blended into the response 8183 */ 8184 _getArguments: function(source, sourceForm, context, passThrgh) { 8185 var _RT = myfaces._impl.core._Runtime, 8186 /** @ignore */ 8187 _Lang = myfaces._impl._util._Lang, 8188 applyCfg = _Lang.hitch(this, this._applyConfig), 8189 //RT does not have this references, hence no hitch needed 8190 getCfg = _RT.getLocalOrGlobalConfig, 8191 8192 8193 ret = { 8194 "source": source, 8195 "sourceForm": sourceForm, 8196 "context": context, 8197 "passThrough": passThrgh, 8198 "xhrQueue": this._q 8199 }; 8200 8201 //we now mix in the config settings which might either be set globally 8202 //or pushed in under the context myfaces.<contextValue> into the current request 8203 applyCfg(ret, context, "alarmThreshold", this._PAR_ERRORLEVEL); 8204 applyCfg(ret, context, "queueSize", this._PAR_QUEUESIZE); 8205 //TODO timeout probably not needed anymore 8206 applyCfg(ret, context, "timeout", this._PAR_TIMEOUT); 8207 //applyCfg(ret, context, "delay", this._PAR_DELAY); 8208 8209 //now partial page submit needs a different treatment 8210 //since pps == execute strings 8211 if (getCfg(context, this._PAR_PPS, false) 8212 && _Lang.exists(passThrgh, myfaces._impl.core.Impl.P_EXECUTE) 8213 && passThrgh[myfaces._impl.core.Impl.P_EXECUTE].length > 0) { 8214 ret['partialIdsArray'] = passThrgh[myfaces._impl.core.Impl.P_EXECUTE].split(" "); 8215 } 8216 return ret; 8217 }, 8218 8219 /** 8220 * helper method to apply a config setting to our varargs param list 8221 * 8222 * @param destination the destination map to receive the setting 8223 * @param context the current context 8224 * @param destParm the destination param of the destination map 8225 * @param srcParm the source param which is the key to our config setting 8226 */ 8227 _applyConfig: function(destination, context, destParm, srcParm) { 8228 var _RT = myfaces._impl.core._Runtime; 8229 /** @ignore */ 8230 var _getConfig = _RT.getLocalOrGlobalConfig; 8231 if (_getConfig(context, srcParm, null) != null) { 8232 destination[destParm] = _getConfig(context, srcParm, null); 8233 } 8234 }, 8235 8236 /** 8237 * centralized transport switching helper 8238 * for the multipart submit case 8239 * 8240 * @param context the context which is passed down 8241 */ 8242 _getMultipartReqClass: function(context) { 8243 if (this._RT.getXHRLvl() >= 2) { 8244 return myfaces._impl.xhrCore._MultipartAjaxRequestLevel2; 8245 } else { 8246 return myfaces._impl.xhrCore._IFrameRequest; 8247 } 8248 }, 8249 8250 8251 _getAjaxReqClass: function(context) { 8252 // var _RT = myfaces._impl.core._Runtime; 8253 if(this._RT.getXHRLvl() < 2) { 8254 return myfaces._impl.xhrCore._AjaxRequest; 8255 } else { 8256 return myfaces._impl.xhrCore._AjaxRequestLevel2; 8257 } 8258 } 8259 8260}); 8261 8262/* Licensed to the Apache Software Foundation (ASF) under one or more 8263 * contributor license agreements. See the NOTICE file distributed with 8264 * this work for additional information regarding copyright ownership. 8265 * The ASF licenses this file to you under the Apache License, Version 2.0 8266 * (the "License");
8266 you may not use this file except in compliance with 8267 * the License. You may obtain a copy of the License at 8268 * 8269 * http://www.apache.org/licenses/LICENSE-2.0 8270 * 8271 * Unless required by applicable law or agreed to in writing, software 8272 * distributed under the License is distributed on an "AS IS" BASIS, 8273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8274 * See the License for the specific language governing permissions and 8275 * limitations under the License. 8276 */ 8277 8278/** 8279 * @class 8280 * @name _Transports 8281 * @memberOf myfaces._impl.xhrCore 8282 * @description 8283 * 8284 * The xhr core adapter 8285 * which provides the transport mechanisms to the calling 8286 * objects, and controls the queue behavior, the error handling 8287 * and partial page submit functionality among other things 8288 * <p /> 8289 * The idea behind this is to make the ajax request object as barebones 8290 * as possible and shift the extra functionality like queuing 8291 * parameter handling etc... to this class so that our transports become more easily 8292 * pluggable. This should keep the path open to iframe submits and other transport layers 8293 * <p /> 8294 * the call to the corresponding transport just should be a 8295 * transport.xhrQueuedPost <br /> 8296 * or transport.xhrPost,transport.xhrGet etc... in the future 8297 * <p /> 8298 * Note we have taken a pattern lesson or two from the dojo toolkit and its excellent handling 8299 * of transports by our patterns here (which is mainly a centralized transport singleton which routes 8300 * to different transport implementations and the auto passing of parameters into their 8301 * corresponding protected attributes on class level in the transports themselves) 8302 */ 8303_MF_SINGLTN(_PFX_XHR+"_ExtTransports" , myfaces._impl.xhrCore._Transports, 8304 /** @lends myfaces._impl.xhrCore._Transports.prototype */ { 8305 8306 8307 constructor_: function() { 8308 this._callSuper("constructor_"); 8309 myfaces._impl.xhrCore._Transports = this; 8310 //we change the transport to our new implementation 8311 this.updateSingletons("transport", this); 8312 }, 8313 8314 /** 8315 * a simple not enqueued xhr post 8316 * 8317 * mapped options already have the exec and view properly in place 8318 * myfaces specifics can be found under mappedOptions.myFaces 8319 * @param {Node} source the source of this call 8320 * @param {Node} sourceForm the html form which is the source of this call 8321 * @param {Object} context (Map) the internal pass through context 8322 * @param {Object} passThrgh (Map) values to be passed through 8323 **/ 8324 xhrPost : function(source, sourceForm, context, passThrgh) { 8325 context._mfInternal.xhrOp = "xhrPost"; 8326 var args = this._getArguments(source, sourceForm, context, passThrgh); 8327 delete args.xhrQueue; 8328 (new (this._getAjaxReqClass(context))(args)).send(); 8329 }, 8330 8331 8332 /** 8333 * xhr get without enqueuing 8334 * 8335 * mapped options already have the exec and view properly in place 8336 * myfaces specifics can be found under mappedOptions.myFaces 8337 * @param {Node} source the source of this call 8338 * @param {Node} sourceForm the html form which is the source of this call 8339 * @param {Object} context (Map) the internal pass through context 8340 * @param {Object} passThrgh (Map) values to be passed through 8341 **/ 8342 xhrGet : function(source, sourceForm, context, passThrgh) { 8343 context._mfInternal.xhrOp = "xhrGet"; 8344 var args = this._getArguments(source, sourceForm, context, passThrgh); 8345 // note in get the timeout is not working delay however is and queue size as well 8346 // since there are no cross browser ways to resolve a timeout on xhr level 8347 // we have to live with it 8348 args.ajaxType = "GET"; 8349 delete args.xhrQueue; 8350 (new (this._getAjaxReqClass(context))(args)).send(); 8351 }, 8352 8353 /** 8354 * xhr get which takes the existing queue into consideration to by synchronized 8355 * to previous queued post requests 8356 * 8357 * mapped options already have the exec and view properly in place 8358 * myfaces specifics can be found under mappedOptions.myFaces 8359 * @param {Node} source the source of this call 8360 * @param {Node} sourceForm the html form which is the source of this call 8361 * @param {Object} context (Map) the internal pass through context 8362 * @param {Object} passThrgh (Map) values to be passed through 8363 **/ 8364 xhrQueuedGet : function(source, sourceForm, context, passThrgh) { 8365 context._mfInternal.xhrOp = "xhrQueuedGet"; 8366 var args = this._getArguments(source, sourceForm, context, passThrgh); 8367 // note in get the timeout is not working delay however is and queue size as well 8368 // since there are no cross browser ways to resolve a timeout on xhr level 8369 // we have to live with it 8370 args.ajaxType = "GET"; 8371 this._q.enqueue( 8372 new (this._getAjaxReqClass(context))(args)); 8373 }, 8374 8375 8376 /** 8377 * iframe post without queueing 8378 * 8379 * mapped options already have the exec and view properly in place 8380 * myfaces specifics can be found under mappedOptions.myFaces 8381 * @param {Node} source the source of this call 8382 * @param {Node} sourceForm the html form which is the source of this call 8383 * @param {Object} context (Map) the internal pass through context 8384 * @param {Object} passThrgh (Map) values to be passed through 8385 **/ 8386 multipartPost : function(source, sourceForm, context, passThrgh) { 8387 context._mfInternal.xhrOp = "multipartPost"; 8388 var args = this._getArguments(source, sourceForm, context, passThrgh); 8389 // note in get the timeout is not working delay however is and queue size as well 8390 // since there are no cross browser ways to resolve a timeout on xhr level 8391 // we have to live with it 8392 delete args.xhrQueue; 8393 (new (this._getMultipartReqClass(context))(args)).send(); 8394 }, 8395 8396 8397 /** 8398 * iframe get without queueing 8399 * 8400 * mapped options already have the exec and view properly in place 8401 * myfaces specifics can be found under mappedOptions.myFaces 8402 * @param {Node} source the source of this call 8403 * @param {Node} sourceForm the html form which is the source of this call 8404 * @param {Object} context (Map) the internal pass through context 8405 * @param {Object} passThrgh (Map) values to be passed through 8406 **/ 8407 multipartGet : function(source, sourceForm, context, passThrgh) { 8408 context._mfInternal.xhrOp = "multiPartGet"; 8409 var args = this._getArguments(source, sourceForm, context, passThrgh); 8410 // note in get the timeout is not working delay however is and queue size as well 8411 // since there are no cross browser ways to resolve a timeout on xhr level 8412 // we have to live with it 8413 args.ajaxType = "GET"; 8414 delete args.xhrQueue; 8415 (new (this._getMultipartReqClass(context))(args)).send(); 8416 }, 8417 8418 /** 8419 * iframe queued http get 8420 * 8421 * mapped options already have the exec and view properly in place 8422 * myfaces specifics can be found under mappedOptions.myFaces 8423 * @param {Node} source the source of this call 8424 * @param {Node} sourceForm the html form which is the source of this call 8425 * @param {Object} context (Map) the internal pass through context 8426 * @param {Object} passThrgh (Map) values to be passed through 8427 **/ 8428 multipartQueuedGet : function(source, sourceForm, context, passThrgh) { 8429 context._mfInternal.xhrOp = "multipartQueuedGet"; 8430 var args = this._getArguments(source, sourceForm, context, passThrgh); 8431 // note in get the timeout is not working delay however is and queue size as well 8432 // since there are no cross browser ways to resolve a timeout on xhr level 8433 args.ajaxType = "GET"; 8434 this._q.enqueue( 8435 new (this._getMultipartReqClass(context))(args)); 8436 } 8437}); 8438 8439/* Licensed to the Apache Software Foundation (ASF) under one or more 8440 * contributor license agreements. See the NOTICE file distributed with 8441 * this work for additional information regarding copyright ownership. 8442 * The ASF licenses this file to you under the Apache License, Version 2.0 8443 * (the "License");
8443 you may not use this file except in compliance with 8444 * the License. You may obtain a copy of the License at 8445 * 8446 * http://www.apache.org/licenses/LICENSE-2.0 8447 * 8448 * Unless required by applicable law or agreed to in writing, software 8449 * distributed under the License is distributed on an "AS IS" BASIS, 8450 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8451 * See the License for the specific language governing permissions and 8452 * limitations under the License. 8453 */ 8454 8455/** 8456 * @class 8457 * @name Impl 8458 * @memberOf myfaces._impl.core 8459 * @description Implementation singleton which implements all interface method 8460 * defined by our jsf.js API 8461 * */ 8462_MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.prototype */ { 8463 8464 //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now 8465 _transport:myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Transports), 8466 8467 /** 8468 * external event listener queue! 8469 */ 8470 _evtListeners:new (myfaces._impl.core._Runtime.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))(), 8471 8472 /** 8473 * external error listener queue! 8474 */ 8475 _errListeners:new (myfaces._impl.core._Runtime.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))(), 8476 8477 /*CONSTANTS*/ 8478 8479 /*internal identifiers for options*/ 8480 IDENT_ALL:"@all", 8481 IDENT_NONE:"@none", 8482 IDENT_THIS:"@this", 8483 IDENT_FORM:"@form", 8484 8485 /* 8486 * [STATIC] constants 8487 */ 8488 8489 P_PARTIAL_SOURCE:"javax.faces.source", 8490 P_VIEWSTATE:"javax.faces.ViewState", 8491 P_CLIENTWINDOW:"javax.faces.ClientWindow", 8492 P_AJAX:"javax.faces.partial.ajax", 8493 P_EXECUTE:"javax.faces.partial.execute", 8494 P_RENDER:"javax.faces.partial.render", 8495 P_EVT:"javax.faces.partial.event", 8496 P_WINDOW_ID:"javax.faces.ClientWindow", 8497 P_RESET_VALUES:"javax.faces.partial.resetValues", 8498 8499 /* message types */ 8500 ERROR:"error", 8501 EVENT:"event", 8502 8503 /* event emitting stages */ 8504 BEGIN:"begin", 8505 COMPLETE:"complete", 8506 SUCCESS:"success", 8507 8508 /*ajax errors spec 14.4.2*/ 8509 HTTPERROR:"httpError", 8510 EMPTY_RESPONSE:"emptyResponse", 8511 MALFORMEDXML:"malformedXML", 8512 SERVER_ERROR:"serverError", 8513 CLIENT_ERROR:"clientError", 8514 TIMEOUT_EVENT:"timeout", 8515 8516 /*error reporting threshold*/ 8517 _threshold:"ERROR", 8518 8519 /*blockfilter for the passthrough filtering, the attributes given here 8520 * will not be transmitted from the options into the passthrough*/ 8521 _BLOCKFILTER:{onerror:1, onevent:1, render:1, execute:1, myfaces:1, delay:1, resetValues:1}, 8522 8523 /** 8524 * collect and encode data for a given form element (must be of type form) 8525 * find the javax.faces.ViewState element and encode its value as well! 8526 * return a concatenated string of the encoded values! 8527 * 8528 * @throws Error in case of the given element not being of type form! 8529 * https://issues.apache.org/jira/browse/MYFACES-2110 8530 */ 8531 getViewState:function (form) { 8532 /** 8533 * typecheck assert!, we opt for strong typing here 8534 * because it makes it easier to detect bugs 8535 */ 8536 if (form) { 8537 form = this._Lang.byId(form); 8538 } 8539 8540 if (!form 8541 || !form.nodeName 8542 || form.nodeName.toLowerCase() != "form") { 8543 throw new Error(this._Lang.getMessage("ERR_VIEWSTATE")); 8544 } 8545 8546 var ajaxUtils = myfaces._impl.xhrCore._AjaxUtils; 8547 8548 var ret = this._Lang.createFormDataDecorator([]); 8549 ajaxUtils.encodeSubmittableFields(ret, form, null); 8550 8551 return ret.makeFinal(); 8552 }, 8553 8554 /** 8555 * this function has to send the ajax requests 8556 * 8557 * following request conditions must be met: 8558 * <ul> 8559 * <li> the request must be sent asynchronously! </li> 8560 * <li> the request must be a POST!!! request </li> 8561 * <li> the request url must be the form action attribute </li> 8562 * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li> 8563 * </ul> 8564 * 8565 * @param {String|Node} elem any dom element no matter being it html or jsf, from which the event is emitted 8566 * @param {|Event|} event any javascript event supported by that object 8567 * @param {|Object|}
8567 options map of options being pushed into the ajax cycle 8568 * 8569 * 8570 * a) transformArguments out of the function 8571 * b) passThrough handling with a map copy with a filter map block map 8572 */ 8573 request:function (elem, event, options) { 8574 if (this._delayTimeout) { 8575 clearTimeout(this._delayTimeout); 8576 delete this._delayTimeout; 8577 } 8578 /*namespace remap for our local function context we mix the entire function namespace into 8579 *a local function variable so that we do not have to write the entire namespace 8580 *all the time 8581 **/ 8582 var _Lang = this._Lang, 8583 _Dom = this._Dom; 8584 /*assert if the onerror is set and once if it is set it must be of type function*/ 8585 _Lang.assertType(options.onerror, "function"); 8586 /*assert if the onevent is set and once if it is set it must be of type function*/ 8587 _Lang.assertType(options.onevent, "function"); 8588 8589 //options not set we define a default one with nothing 8590 options = options || {}; 8591 8592 /** 8593 * we cross reference statically hence the mapping here 8594 * the entire mapping between the functions is stateless 8595 */ 8596 //null definitely means no event passed down so we skip the ie specific checks 8597 if ('undefined' == typeof event) { 8598 event = window.event || null; 8599 } 8600 8601 //improve the error messages if an empty elem is passed 8602 if (!elem) { 8603 throw _Lang.makeException(new Error(), "ArgNotSet", null, this._nameSpace, "request", _Lang.getMessage("ERR_MUST_BE_PROVIDED1", "{0}: source must be provided", "jsf.ajax.request", "source element id")); 8604 } 8605 var oldElem = elem; 8606 elem = _Dom.byIdOrName(elem); 8607 if (!elem) { 8608 throw _Lang.makeException(new Error(), "Notfound", null, this._nameSpace, "request", _Lang.getMessage("ERR_PPR_UNKNOWNCID", "{0}: Node with id {1} could not be found from source", this._nameSpace + ".request", oldElem)); 8609 } 8610 8611 var elementId = _Dom.nodeIdOrName(elem); 8612 8613 /* 8614 * We make a copy of our options because 8615 * we should not touch the incoming params! 8616 * this copy is also the pass through parameters 8617 * which are sent down our request 8618 */ 8619 var passThrgh = _Lang.mixMaps({}, options, true, this._BLOCKFILTER); 8620 8621 if (event) { 8622 passThrgh[this.P_EVT] = event.type; 8623 } 8624 8625 /** 8626 * ajax pass through context with the source 8627 * onevent and onerror 8628 */ 8629 var context = { 8630 source:elem, 8631 onevent:options.onevent, 8632 onerror:options.onerror, 8633 8634 //TODO move the myfaces part into the _mfInternal part 8635 myfaces:options.myfaces, 8636 _mfInternal:{} 8637 }; 8638 //additional meta information to speed things up, note internal non jsf 8639 //pass through options are stored under _mfInternal in the context 8640 var mfInternal = context._mfInternal; 8641 8642 /** 8643 * fetch the parent form 8644 * 8645 * note we also add an override possibility here 8646 * so that people can use dummy forms and work 8647 * with detached objects 8648 */ 8649 var form = (options.myfaces && options.myfaces.form) ? 8650 _Lang.byId(options.myfaces.form) : 8651 this._getForm(elem, event); 8652 8653 /** 8654 * JSF2.2 client window must be part of the issuing form so it is encoded 8655 * automatically in the request 8656 */ 8657 //we set the client window before encoding by a call to jsf.getClientWindow 8658 var clientWindow = jsf.getClientWindow(form); 8659 //in case someone decorates the getClientWindow we reset the value from 8660 //what we are getting 8661 if ('undefined' != typeof clientWindow && null != clientWindow) { 8662 var formElem = _Dom.getNamedElementFromForm(form, this.P_CLIENTWINDOW); 8663 if (formElem) { 8664 //we store the value for later processing during the ajax phase 8665 //job so that we do not get double values 8666 context._mfInternal._clientWindow = jsf.getClientWindow(form); 8667 } else { 8668 passThrgh[this.P_CLIENTWINDOW] = jsf.getClientWindow(form); 8669 } 8670 } /* spec proposal 8671 else { 8672 var formElem = _Dom.getNamedElementFromForm(form, this.P_CLIENTWINDOW); 8673 if (formElem) { 8674 context._mfInternal._clientWindow = "undefined"; 8675 } else { 8676 passThrgh[this.P_CLIENTWINDOW] = "undefined"; 8677 } 8678 } 8679 */ 8680 8681 /** 8682 * binding contract the javax.faces.source must be set 8683 */ 8684 passThrgh[this.P_PARTIAL_SOURCE] = elementId; 8685 8686 /** 8687 * javax.faces.partial.ajax must be set to true 8688 */ 8689 passThrgh[this.P_AJAX] = true; 8690 8691 /** 8692 * if resetValues is set to true 8693 * then we have to set javax.faces.resetValues as well 8694 * as pass through parameter 8695 * the value has to be explicitly true, according to 8696 * the specs jsdoc 8697 */ 8698 if(options.resetValues === true) { 8699 passThrgh[this.P_RESET_VALUES] = true; 8700 } 8701 8702 if (options.execute) { 8703 /*the options must be a blank delimited list of strings*/ 8704 /*compliance with Mojarra which automatically adds @this to an execute 8705 * the spec rev 2.0a however states, if none is issued nothing at all should be sent down 8706 */ 8707 options.execute = (options.execute.indexOf("@this") == -1) ? options.execute : options.execute; 8708 8709 this._transformList(passThrgh, this.P_EXECUTE, options.execute, form, elementId); 8710 } else { 8711 passThrgh[this.P_EXECUTE] = elementId; 8712 } 8713 8714 if (options.render) { 8715 this._transformList(passThrgh, this.P_RENDER, options.render, form, elementId); 8716 } 8717 8718 /** 8719 * multiple transports upcoming jsf 2.x feature currently allowed 8720 * default (no value) xhrQueuedPost 8721 * 8722 * xhrQueuedPost 8723 * xhrPost 8724 * xhrGet 8725 * xhrQueuedGet 8726 * iframePost 8727 * iframeQueuedPost 8728 * 8729 */ 8730 var transportType = this._getTransportType(context, passThrgh, form); 8731 8732 mfInternal["_mfSourceFormId"] = form.id; 8733 mfInternal["_mfSourceControlId"] = elementId; 8734 mfInternal["_mfTransportType"] = transportType; 8735 8736 //mojarra compatibility, mojarra is sending the form id as well 8737 //this is not documented behavior but can be determined by running 8738 //mojarra under blackbox conditions 8739 //i assume it does the same as our formId_submit=1 so leaving it out 8740 //wont hurt but for the sake of compatibility we are going to add it 8741 passThrgh[form.id] = form.id; 8742 8743 /* jsf2.2 only: options.delay || */ 8744 var delayTimeout = options.delay || this._RT.getLocalOrGlobalConfig(context, "delay", false); 8745 if (delayTimeout) { 8746 if (this._delayTimeout) { 8747 clearTimeout(this._delayTimeout); 8748 } 8749 this._delayTimeout = setTimeout(_Lang.hitch(this, function () { 8750 this._transport[transportType](elem, form, context, passThrgh); 8751 this._delayTimeout = null; 8752 }), parseInt(delayTimeout)); 8753 } else { 8754 this._transport[transportType](elem, form, context, passThrgh); 8755 } 8756 }, 8757 8758 /** 8759 * fetches the form in an unprecise manner depending 8760 * on an element or event target 8761 * 8762 * @param elem 8763 * @param event 8764 */ 8765 _getForm:function (elem, event) { 8766 var _Dom = this._Dom; 8767 var _Lang = this._Lang; 8768 var form = _Dom.fuzzyFormDetection(elem); 8769 8770 if (!form && event) { 8771 //in case of no form is given we retry over the issuing event 8772 form = _Dom.fuzzyFormDetection(_Lang.getEventTarget(event)); 8773 if (!form) { 8774 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getForm", _Lang.getMe
8774ssage("ERR_FORM")); 8775 } 8776 } else if (!form) { 8777 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getForm", _Lang.getMessage("ERR_FORM")); 8778 8779 } 8780 return form; 8781 }, 8782 8783 /** 8784 * determines the transport type to be called 8785 * for the ajax call 8786 * 8787 * @param context the context 8788 * @param passThrgh pass through values 8789 * @param form the form which issues the request 8790 */ 8791 _getTransportType:function (context, passThrgh, form) { 8792 /** 8793 * if execute or render exist 8794 * we have to pass them down as a blank delimited string representation 8795 * of an array of ids! 8796 */ 8797 //for now we turn off the transport auto selection, to enable 2.0 backwards compatibility 8798 //on protocol level, the file upload only can be turned on if the auto selection is set to true 8799 var getConfig = this._RT.getLocalOrGlobalConfig, 8800 _Lang = this._Lang, 8801 _Dom = this._Dom; 8802 8803 var transportAutoSelection = getConfig(context, "transportAutoSelection", true); 8804 /*var isMultipart = (transportAutoSelection && _Dom.getAttribute(form, "enctype") == "multipart/form-data") ? 8805 _Dom.isMultipartCandidate((!getConfig(context, "pps",false))? form : passThrgh[this.P_EXECUTE]) : 8806 false; 8807 **/ 8808 if (!transportAutoSelection) { 8809 return getConfig(context, "transportType", "xhrQueuedPost"); 8810 } 8811 var multiPartCandidate = _Dom.isMultipartCandidate((!getConfig(context, "pps", false)) ? 8812 form : passThrgh[this.P_EXECUTE]); 8813 var multipartForm = (_Dom.getAttribute(form, "enctype") || "").toLowerCase() == "multipart/form-data"; 8814 //spec section jsdoc, if we have a multipart candidate in our execute (aka fileupload) 8815 //and the form is not multipart then we have to raise an error 8816 if (multiPartCandidate && !multipartForm) { 8817 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getTransportType", _Lang.getMessage("ERR_NO_MULTIPART_FORM", "No Multipart form", form.id)); 8818 } 8819 var isMultipart = multiPartCandidate && multipartForm; 8820 /** 8821 * multiple transports upcoming jsf 2.2 feature currently allowed 8822 * default (no value) xhrQueuedPost 8823 * 8824 * xhrQueuedPost 8825 * xhrPost 8826 * xhrGet 8827 * xhrQueuedGet 8828 * iframePost 8829 * iframeQueuedPost 8830 * 8831 */ 8832 var transportType = (!isMultipart) ? 8833 getConfig(context, "transportType", "xhrQueuedPost") : 8834 getConfig(context, "transportType", "multipartQueuedPost"); 8835 if (!this._transport[transportType]) { 8836 //throw new Error("Transport type " + transportType + " does not exist"); 8837 throw new Error(_Lang.getMessage("ERR_TRANSPORT", null, transportType)); 8838 } 8839 return transportType; 8840 8841 }, 8842 8843 /** 8844 * transforms the list to the expected one 8845 * with the proper none all form and this handling 8846 * (note we also could use a simple string replace but then 8847 * we would have had double entries under some circumstances) 8848 * 8849 * @param passThrgh 8850 * @param target 8851 * @param srcStr 8852 * @param form 8853 * @param elementId 8854 */ 8855 _transformList:function (passThrgh, target, srcStr, form, elementId) { 8856 var _Lang = this._Lang; 8857 //this is probably the fastest transformation method 8858 //it uses an array and an index to position all elements correctly 8859 //the offset variable is there to prevent 0 which results in a javascript 8860 //false 8861 srcStr = this._Lang.trim(srcStr); 8862 var offset = 1, 8863 vals = (srcStr) ? srcStr.split(/\s+/) : [], 8864 idIdx = (vals.length) ? _Lang.arrToMap(vals, offset) : {}, 8865 8866 //helpers to improve speed and compression 8867 none = idIdx[this.IDENT_NONE], 8868 all = idIdx[this.IDENT_ALL], 8869 theThis = idIdx[this.IDENT_THIS], 8870 theForm = idIdx[this.IDENT_FORM]; 8871 8872 if (none) { 8873 //in case of none nothing is returned 8874 if ('undefined' != typeof passThrgh.target) { 8875 delete passThrgh.target; 8876 } 8877 return passThrgh; 8878 } 8879 if (all) { 8880 //in case of all only one value is returned 8881 passThrgh[target] = this.IDENT_ALL; 8882 return passThrgh; 8883 } 8884 8885 if (theForm) { 8886 //the form is replaced with the proper id but the other 8887 //values are not touched 8888 vals[theForm - offset] = form.id; 8889 } 8890 if (theThis && !idIdx[elementId]) { 8891 //in case of this, the element id is set 8892 vals[theThis - offset] = elementId; 8893 } 8894 8895 //the final list must be blank separated 8896 passThrgh[target] = vals.join(" "); 8897 return passThrgh; 8898 }, 8899 8900 addOnError:function (/*function*/errorListener) { 8901 /*error handling already done in the assert of the queue*/ 8902 this._errListeners.enqueue(errorListener); 8903 }, 8904 8905 addOnEvent:function (/*function*/eventListener) { 8906 /*error handling already done in the assert of the queue*/ 8907 this._evtListeners.enqueue(eventListener); 8908 }, 8909 8910 /** 8911 * implementation triggering the error chain 8912 * 8913 * @param {Object} request the request object which comes from the xhr cycle 8914 * @param {Object} context (Map) the context object being pushed over the xhr cycle keeping additional metadata 8915 * @param {String} name the error name 8916 * @param {String} serverErrorName the server error name in case of a server error 8917 * @param {String} serverErrorMessage the server error message in case of a server error 8918 * @param {String} caller optional caller reference for extended error messages 8919 * @param {String} callFunc optional caller Function reference for extended error messages 8920 * 8921 * handles the errors, in case of an onError exists within the context the onError is called as local error handler 8922 * the registered error handlers in the queue receiv an error message to be dealt with 8923 * and if the projectStage is at development an alert box is displayed 8924 * 8925 * note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided 8926 * which changes the default output behavior from alert to something else 8927 * 8928 * 8929 */ 8930 sendError:function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage, caller, callFunc) { 8931 var _Lang = myfaces._impl._util._Lang;
8932 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 8933 8934 var eventData = {}; 8935 //we keep this in a closure because we might reuse it for our serverErrorMessage 8936 var malFormedMessage = function () { 8937 return (name && name === myfaces._impl.core.Impl.MALFORMEDXML) ? _Lang.getMessage("ERR_MALFORMEDXML") : ""; 8938 }; 8939 8940 //by setting unknown values to unknown we can handle cases 8941 //better where a simulated context is pushed into the system 8942 eventData.type = this.ERROR; 8943 8944 eventData.status = name || UNKNOWN; 8945 eventData.serverErrorName = serverErrorName || UNKNOWN; 8946 eventData.serverErrorMessage = serverErrorMessage || UNKNOWN; 8947 8948 try { 8949 eventData.source = context.source || UNKNOWN; 8950 eventData.responseCode = request.status || UNKNOWN; 8951 eventData.responseText = request.responseText || UNKNOWN; 8952 eventData.responseXML = request.responseXML || UNKNOWN; 8953 } catch (e) { 8954 // silently ignore: user can find out by examining the event data 8955 } 8956 //extended error message only in dev mode 8957 if (jsf.getProjectStage() === "Development") { 8958 eventData.serverErrorMessage = eventData.serverErrorMessage || ""; 8959 eventData.serverErrorMessage = (caller) ? eventData.serverErrorMessage + "\nCalling class: " + caller : eventData.serverErrorMessage; 8960 eventData.serverErrorMessage = (callFunc) ? eventData.serverErrorMessage + "\n Calling function: " + callFunc : eventData.serverErrorMessage; 8961 } 8962 8963 /**/ 8964 if (context["onerror"]) { 8965 context.onerror(eventData); 8966 } 8967 8968 /*now we serve the queue as well*/ 8969 this._errListeners.broadcastEvent(eventData); 8970 8971 if (jsf.getProjectStage() === "Development" && this._errListeners.length() == 0 && !context["onerror"]) { 8972 var DIVIDER = "--------------------------------------------------------", 8973 defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert), 8974 finalMessage = [], 8975 //we remap the function to achieve a better compressability 8976 pushMsg = _Lang.hitch(finalMessage, finalMessage.push); 8977 8978 (serverErrorMessage) ? pushMsg(_Lang.getMessage("MSG_ERROR_MESSAGE") + " " + serverErrorMessage + "\n") : null; 8979 8980 pushMsg(DIVIDER); 8981 8982 (caller) ? pushMsg("Calling class:" + caller) : null; 8983 (callFunc) ? pushMsg("Calling function:" + callFunc) : null; 8984 (name) ? pushMsg(_Lang.getMessage("MSG_ERROR_NAME") + " " + name) : null; 8985 (serverErrorName && name != serverErrorName) ? pushMsg("Server error name: " + serverErrorName) : null; 8986 8987 pushMsg(malFormedMessage()); 8988 pushMsg(DIVIDER); 8989 pushMsg(_Lang.getMessage("MSG_DEV_MODE")); 8990 defaultErrorOutput(finalMessage.join("\n")); 8991 } 8992 }, 8993 8994 /** 8995 * sends an event 8996 */ 8997 sendEvent:function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) { 8998 var _Lang = myfaces._impl._util._Lang; 8999 var eventData = {};
9000 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 9001 9002 eventData.type = this.EVENT; 9003 9004 eventData.status = name; 9005 eventData.source = context.source; 9006 9007 if (name !== this.BEGIN) { 9008 9009 try { 9010 //we bypass a problem with ie here, ie throws an exception if no status is given on the xhr object instead of just passing a value 9011 var getValue = function (value, key) { 9012 try { 9013 return value[key] 9014 } catch (e) { 9015 return UNKNOWN; 9016 } 9017 }; 9018 9019 eventData.responseCode = getValue(request, "status"); 9020 eventData.responseText = getValue(request, "responseText"); 9021 eventData.responseXML = getValue(request, "responseXML"); 9022 9023 } catch (e) { 9024 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9025 impl.sendError(request, context, this.CLIENT_ERROR, "ErrorRetrievingResponse", 9026 _Lang.getMessage("ERR_CONSTRUCT", e.toString())); 9027 9028 //client errors are not swallowed 9029 throw e; 9030 } 9031 9032 } 9033 9034 /**/ 9035 if (context.onevent) { 9036 /*calling null to preserve the original scope*/ 9037 context.onevent.call(null, eventData); 9038 } 9039 9040 /*now we serve the queue as well*/ 9041 this._evtListeners.broadcastEvent(eventData); 9042 }, 9043 9044 /** 9045 * Spec. 13.3.3 9046 * Examining the response markup and updating the DOM tree 9047 * @param {XMLHttpRequest} request - the ajax request 9048 * @param {Object} context - the ajax context 9049 */ 9050 response:function (request, context) { 9051 this._RT.getLocalOrGlobalConfig(context, "responseHandler", myfaces._impl.xhrCore._AjaxResponse).processResponse(request, context); 9052 }, 9053 9054 /** 9055 * fetches the separator char from the given script tags 9056 * 9057 * @return {char} the separator char for the given script tags 9058 */ 9059 getSeparatorChar:function () { 9060 if (this._separator) { 9061 return this.separatorchar; 9062 } 9063 var SEPARATOR_CHAR = "separatorchar", 9064 found = false, 9065 getConfig = myfaces._impl.core._Runtime.getGlobalConfig, 9066 scriptTags = document.getElementsByTagName("script"); 9067 for (var i = 0; i < scriptTags.length && !found; i++) { 9068 if (scriptTags[i].src.search(/\/javax\.faces\.resource.*\/jsf\.js.*separator/) != -1) { 9069 found = true; 9070 var result = scriptTags[i].src.match(/separator=([^&;]*)/); 9071 this._separator = decodeURIComponent(result[1]); 9072 } 9073 } 9074 this._separator = getConfig(SEPARATOR_CHAR, this._separator || ":"); 9075 return this._separator; 9076 }, 9077 9078 /** 9079 * @return the project stage also emitted by the server: 9080 * it cannot be cached and must be delivered over the server 9081 * The value for it comes from the request parameter of the jsf.js script called "stage". 9082 */ 9083 getProjectStage:function () { 9084 //since impl is a singleton we only have to do it once at first access 9085 9086 if (!this._projectStage) { 9087 var PRJ_STAGE = "projectStage", 9088 STG_PROD = "Production", 9089 9090 scriptTags = document.getElementsByTagName("script"), 9091 getConfig = myfaces._impl.core._Runtime.getGlobalConfig, 9092 projectStage = null, 9093 found = false, 9094 allowedProjectStages = {STG_PROD:1, "Development":1, "SystemTest":1, "UnitTest":1}; 9095 9096 /* run through all script tags and try to find the one that includes jsf.js */ 9097 for (var i = 0; i < scriptTags.length && !found; i++) { 9098 if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1) { 9099 var result = scriptTags[i].src.match(/stage=([^&;]*)/); 9100 found = true; 9101 if (result) { 9102 // we found stage=XXX 9103 // return only valid values of ProjectStage 9104 projectStage = (allowedProjectStages[result[1]]) ? result[1] : null; 9105 9106 } 9107 else { 9108 //we found the script, but there was no stage parameter -- Production 9109 //(we also add an override here for testing purposes, the default, however is Production) 9110 projectStage = getConfig(PRJ_STAGE, STG_PROD); 9111 } 9112 } 9113 } 9114 /* we could not find anything valid --> return the default value */ 9115 this._projectStage = getConfig(PRJ_STAGE, projectStage || STG_PROD); 9116 } 9117 return this._projectStage; 9118 }, 9119 9120 /**
9121 * implementation of the external chain function 9122 * moved into the impl 9123 * 9124 * @param {Object} source the source which also becomes 9125 * the scope for the calling function (unspecified side behavior) 9126 * the spec states here that the source can be any arbitrary code block. 9127 * Which means it either is a javascript function directly passed or a code block 9128 * which has to be evaluated separately. 9129 * 9130 * After revisiting the code additional testing against components showed that 9131 * the this parameter is only targeted at the component triggering the eval 9132 * (event) if a string code block is passed. This is behavior we have to resemble 9133 * in our function here as well, I guess. 9134 * 9135 * @param {Event} event the event object being passed down into the the chain as event origin 9136 * the spec is contradicting here, it on one hand defines event, and on the other 9137 * it says it is optional, after asking, it meant that event must be passed down 9138 * but can be undefined 9139 */ 9140 chain:function (source, event) { 9141 var len = arguments.length; 9142 var _Lang = this._Lang; 9143 var throwErr = function (msgKey) {
9144 throw Error("jsf.util.chain: " + _Lang.getMessage(msgKey)); 9145 }; 9146 /** 9147 * generic error condition checker which raises 9148 * an exception if the condition is met 9149 * @param assertion 9150 * @param message 9151 */ 9152 var errorCondition = function (assertion, message) { 9153 if (assertion === true) throwErr(message); 9154 }; 9155 var FUNC = 'function'; 9156 var ISSTR = _Lang.isString; 9157 9158 //the spec is contradicting here, it on one hand defines event, and on the other 9159 //it says it is optional, I have cleared this up now 9160 //the spec meant the param must be passed down, but can be 'undefined' 9161 9162 errorCondition(len < 2, "ERR_EV_OR_UNKNOWN"); 9163 errorCondition(len < 3 && (FUNC == typeof event || ISSTR(event)), "ERR_EVT_PASS"); 9164 if (len < 3) { 9165 //nothing to be done here, move along 9166 return true; 9167 } 9168 //now we fetch from what is given from the parameter list 9169 //we cannot work with splice here in any performant way so we do it the hard way 9170 //arguments only are give if not set to undefined even null values! 9171 9172 //assertions source either null or set as dom element: 9173 errorCondition('undefined' == typeof source, "ERR_SOURCE_DEF_NULL"); 9174 errorCondition(FUNC == typeof source, "ERR_SOURCE_FUNC"); 9175 errorCondition(ISSTR(source), "ERR_SOURCE_NOSTR"); 9176 9177 //assertion if event is a function or a string we already are in our function elements 9178 //since event either is undefined, null or a valid event object 9179 errorCondition(FUNC == typeof event || ISSTR(event), "ERR_EV_OR_UNKNOWN"); 9180 9181 for (var cnt = 2; cnt < len; cnt++) { 9182 //we do not change the scope of the incoming functions 9183 //but we reuse the argument array capabilities of apply 9184 var ret; 9185 9186 console.log("[.ajax] jsf function: %s", arguments[cnt]); 9187 9188 if (FUNC == typeof arguments[cnt]) { 9189 ret = arguments[cnt].call(source, event); 9190 } else { 9191 //either a function or a string can be passed in case of a string we have to wrap it into another function 9192 ret = new Function("event", arguments[cnt]).call(source, event); 9193 } 9194 //now if one function returns false in between we stop the execution of the cycle 9195 //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering 9196 if (ret === false /*undefined check implicitly done here by using a strong compare*/) { 9197 return false; 9198 } 9199 } 9200 return true; 9201 }, 9202 9203 /** 9204 * error handler behavior called internally 9205 * and only into the impl it takes care of the 9206 * internal message transformation to a myfaces internal error 9207 * and then uses the standard send error mechanisms 9208 * also a double error logging prevention is done as well 9209 * 9210 * @param request the request currently being processed 9211 * @param context the context affected by this error 9212 * @param exception the exception being thrown 9213 */ 9214 stdErrorHandler:function (request, context, exception) { 9215 //newer browsers do not allow to hold additional values on native objects like exceptions 9216 //we hence capsule it into the request, which is gced automatically 9217 //on ie as well, since the stdErrorHandler usually is called between requests 9218 //this is a valid approach 9219 if (this._threshold == "ERROR") { 9220 var mfInternal = exception._mfInternal || {}; 9221 9222 var finalMsg = []; 9223 finalMsg.push(exception.message); 9224 this.sendError(request, context, 9225 mfInternal.title || this.CLIENT_ERROR, mfInternal.name || exception.name, finalMsg.join("\n"), mfInternal.caller, mfInternal.callFunc); 9226 } 9227 }, 9228 9229 /** 9230 * @return the client window id of the current window, if one is given 9231 */ 9232 getClientWindow:function (node) { 9233 var fetchWindowIdFromForms = this._Lang.hitch(this, function (forms) { 9234 var result_idx = {}; 9235 var result; 9236 var foundCnt = 0; 9237 for (var cnt = forms.length - 1; cnt >= 0; cnt--) { 9238 9239 var currentForm = forms[cnt]; 9240 var winIdElement = this._Dom.getNamedElementFromForm(currentForm, this.P_WINDOW_ID); 9241 var windowId = (winIdElement) ? winIdElement.value : null; 9242 9243 if (windowId) { 9244 if (foundCnt > 0 && "undefined" == typeof result_idx[windowId]) throw Error("Multiple different windowIds found in document"); 9245 result = windowId; 9246 result_idx[windowId] = true; 9247 foundCnt++; 9248 } 9249 } 9250 return result; 9251 }); 9252 9253 var fetchWindowIdFromURL = function () { 9254 var href = window.location.href, windowId = "jfwid";
9255 var regex = new RegExp("[\\?&]" + windowId + "=([^&#\\;]*)"); 9256 var results = regex.exec(href); 9257 //initial trial over the url and a regexp 9258 if (results != null) return results[1]; 9259 return null; 9260 }; 9261 9262 //byId ($) 9263 var finalNode = (node) ? this._Dom.byId(node) : document.body; 9264 9265 var forms = this._Dom.findByTagName(finalNode, "form"); 9266 var result = fetchWindowIdFromForms(forms); 9267 return (null != result) ? result : fetchWindowIdFromURL(); 9268 } 9269}); 9270 9271 9272 9273/* Licensed to the Apache Software Foundation (ASF) under one or more 9274 * contributor license agreements. See the NOTICE file distributed with 9275 * this work for additional information regarding copyright ownership. 9276 * The ASF licenses this file to you under the Apache License, Version 2.0 9277 * (the "License"); you may not use this file except in compliance with 9278 * the License. You may obtain a copy of the License at 9279 * 9280 * http://www.apache.org/licenses/LICENSE-2.0 9281 * 9282 * Unless required by applicable law or agreed to in writing, software 9283 * distributed under the License is distributed on an "AS IS" BASIS, 9284 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9285 * See the License for the specific language governing permissions and 9286 * limitations under the License. 9287 */ 9288/*last file loaded, must restore the state of affairs*/ 9289(function() { 9290 //some mobile browsers do not have a window object 9291 var target = window || document; 9292 9293 var resetAbbreviation = function (name) { 9294 var _temp = target.myfaces._implTemp; 9295 (!!_temp[name]) ? 9296 target[name] = _temp[name] : null; 9297 }, 9298 resetArr = ["_MF_CLS", 9299 "_MF_SINGLTN", 9300 "_MF_OBJECT", 9301 "_PFX_UTIL", 9302 "_PFX_XHR", 9303 "_PFX_CORE", 9304 "_PFX_I18N"]; 9305 for (var cnt = resetArr.length - 1; cnt >= 0; cnt--) { 9306 resetAbbreviation(resetArr[cnt]); 9307 } 9308})(); 9309 9310 9311 9312/* 9313 * Licensed to the Apache Software Foundation (ASF) under one or more 9314 * contributor license agreements. See the NOTICE file distributed with 9315 * this work for additional information regarding copyright ownership. 9316 * The ASF licenses this file to you under the Apache License, Version 2.0 9317 * (the "License"); you may not use this file except in compliance with 9318 * the License. You may obtain a copy of the License at 9319 * 9320 * http://www.apache.org/licenses/LICENSE-2.0 9321 * 9322 * Unless required by applicable law or agreed to in writing, software 9323 * distributed under the License is distributed on an "AS IS" BASIS, 9324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9325 * See the License for the specific language governing permissions and 9326 * limitations under the License. 9327*/ 9328 9329/** 9330 *MyFaces core javascripting libraries 9331 * 9332 * Those are the central public API functions in the JSF2 9333 * Ajax API! They handle the entire form submit and ajax send 9334 * and resolve cycle! 9335 */ 9336 9337/** 9338 * reserve the root namespace 9339 */ 9340if ('undefined' != typeof OpenAjax && ('undefined' == typeof jsf || null == typeof jsf)) { 9341 OpenAjax.hub.registerLibrary("jsf", "www.sun.com", "1.0", null); 9342} 9343//just in case openajax has failed (testing environment) 9344/** 9345* @ignore 9346*/ 9347if (!window.jsf) { 9348 /** 9349 * @namespace jsf 9350 */ 9351 var jsf = new function() { 9352 /* 9353 * Version of the implementation for the jsf.js. 9354 * <p /> 9355 * as specified within the jsf specifications jsf.html: 9356 * <ul> 9357 * <li>left two digits major release number</li> 9358 * <li>middle two digits minor spec release number</li> 9359 * <li>right two digits bug release number</li> 9360 * </ul> 9361 * @constant 9362 */ 9363 this.specversion = 220000; 9364 /** 9365 * Implementation version as specified within the jsf specification. 9366 * <p /> 9367 * A number increased with every implementation version 9368 * and reset by moving to a new spec release number 9369 * 9370 * @constant 9371 */ 9372 this.implversion = 0; 9373 9374 /** 9375 * SeparatorChar as defined by UINamingContainer.getNamingContainerSeparatorChar() 9376 * @type {Char} 9377 */ 9378 this.separatorchar = getSeparatorChar(); 9379 9380 /** 9381 * This method is responsible for the return of a given project stage as defined 9382 * by the jsf specification. 9383 * <p/> 9384 * Valid return values are: 9385 * <ul> 9386 * <li>"Production"</li> 9387 * <li>"Development"</li> 9388 * <li>"SystemTest"</li> 9389 * <li>"UnitTest"</li> 9390 * </li> 9391 * 9392 * @return {String} the current project state emitted by the server side method: 9393 * <i>javax.faces.application.Application.getProjectStage()</i> 9394 */ 9395 this.getProjectStage = function() { 9396 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9397 return impl.getProjectStage(); 9398 }; 9399 9400 /** 9401 * collect and encode data for a given form element (must be of type form) 9402 * find the javax.faces.ViewState element and encode its value as well! 9403 * return a concatenated string of the encoded values! 9404 * 9405 * @throws an exception in case of the given element not being of type form! 9406 * https://issues.apache.org/jira/browse/MYFACES-2110 9407 */ 9408 this.getViewState = function(formElement) { 9409 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9410 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9411 return impl.getViewState(formElement); 9412 }; 9413 9414 /** 9415 * returns the window identifier for the given node / window
9416 * @param {optional String | DomNode} the node for which the client identifier has to be determined 9417 * @return the window identifier or null if none is found 9418 */ 9419 this.getClientWindow = function() { 9420 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9421 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9422 return (arguments.length)? impl.getClientWindow(arguments[0]) : impl.getClientWindow(); 9423 } 9424 9425 //private helper functions 9426 function getSeparatorChar() { 9427 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9428 return impl.getSeparatorChar(); 9429 } 9430 9431 }; 9432 //jsdoc helper to avoid warnings, we map later 9433 window.jsf = jsf; 9434} 9435 9436/** 9437 * just to make sure no questions arise, I simply prefer here a weak 9438 * typeless comparison just in case some frameworks try to interfere 9439 * by overriding null or fiddeling around with undefined or typeof in some ways 9440 * it is safer in this case than the standard way of doing a strong comparison 9441 **/ 9442if (!jsf.ajax) { 9443 /** 9444 * @namespace jsf.ajax 9445 */ 9446 jsf.ajax = new function() { 9447 9448 9449 /** 9450 * this function has to send the ajax requests 9451 * 9452 * following request conditions must be met: 9453 * <ul> 9454 * <li> the request must be sent asynchronously! </li> 9455 * <li> the request must be a POST!!! request </li> 9456 * <li> the request url must be the form action attribute </li> 9457 * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li> 9458 * </ul> 9459 * 9460 * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted 9461 * @param {EVENT} event: any javascript event supported by that object 9462 * @param {Map} options : map of options being pushed into the ajax cycle 9463 */ 9464 this.request = function(element, event, options) { 9465 if (!options) { 9466 options = {}; 9467 } 9468 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9469 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9470 return impl.request(element, event, options); 9471 }; 9472 9473 /** 9474 * Adds an error handler to our global error queue. 9475 * the error handler must be of the format <i>function errorListener(<errorData>)</i> 9476 * with errorData being of following format: 9477 * <ul> 9478 * <li> errorData.type : "error"</li> 9479 * <li> errorData.status : the error status message</li> 9480 * <li> errorData.serverErrorName : the server error name in case of a server error</li> 9481 * <li> errorData.serverErrorMessage : the server error message in case of a server error</li> 9482 * <li> errorData.source : the issuing source element which triggered the request </li> 9483 * <li> eventData.responseCode: the response code (aka http request response code, 401 etc...) </li> 9484 * <li> eventData.responseText: the request response text </li> 9485 * <li> eventData.responseXML: the request response xml </li> 9486 * </ul> 9487 * 9488 * @param {function} errorListener error handler must be of the format <i>function errorListener(<errorData>)</i> 9489 */ 9490 this.addOnError = function(/*function*/errorListener) { 9491 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9492 return impl.addOnError(errorListener); 9493 }; 9494 9495 /** 9496 * Adds a global event listener to the ajax event queue. The event listener must be a function 9497 * of following format: <i>function eventListener(<eventData>)</i> 9498 * 9499 * @param {function} eventListener event must be of the format <i>function eventListener(<eventData>)</i> 9500 */ 9501 this.addOnEvent = function(/*function*/eventListener) { 9502 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9503 return impl.addOnEvent(eventListener); 9504 }; 9505 9506 /**
9507 * processes the ajax response if the ajax request completes successfully 9508 * @param request the ajax request! 9509 * @param context the ajax context! 9510 */ 9511 this.response = function(/*xhr request object*/request, context) { 9512 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9513 return impl.response(request, context); 9514 }; 9515 9516 9517 this.cancel = function() { 9518 console.log("[.ajax] cancel"); 9519 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9520 impl._transport._q.cleanup(); 9521 }; 9522 } 9523} 9524 9525if (!jsf.util) { 9526 /** 9527 * @namespace jsf.util 9528 */ 9529 jsf.util = new function() { 9530 9531 /** 9532 * varargs function which executes a chain of code (functions or any other code) 9533 * 9534 * if any of the code returns false, the execution 9535 * is terminated prematurely skipping the rest of the code! 9536 * 9537 * @param {DomNode} source, the callee object 9538 * @param {Event} event, the event object of the callee event triggering this function 9539 * @param {optional} functions to be chained, if any of those return false the chain is broken 9540 */ 9541 this.chain = function(source, event) { 9542 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9543 return impl.chain.apply(impl, arguments); 9544 }; 9545 9546 } 9547} 9548 9549 9550
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.