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 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", "application/x-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, allowlistFilter) { 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 (allowlistFilter && !allowlistFilter[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 var _Lang = this; 2714 if (!this.FormDataDecoratorArray) { 2715 this.FormDataDecoratorArray = function (theFormData) { 2716 this._valBuf = theFormData; 2717 this._idx = {}; 2718 var _t = this; 2719 _Lang.arrForEach(theFormData, function(item) { 2720 var key = item[0]; 2721 _t._idx[decodeURIComponent(key)] = true; 2722 }); 2723 }; 2724 _newCls = this.FormDataDecoratorArray; 2725 _newCls.prototype.append = function (key, val) { 2726 this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)].join("=")); 2727 this._idx[key] = true; 2728 }; 2729 _newCls.prototype.hasKey = function (key) { 2730 return !!this._idx[key]; 2731 }; 2732 _newCls.prototype.makeFinal = function () { 2733 return this._valBuf.join("&"); 2734 }; 2735 } 2736 if (!this.FormDataDecoratorString) { 2737 this.FormDataDecoratorString = function (theFormData) { 2738 this._preprocessedData = theFormData; 2739 this._valBuf = []; 2740 this._idx = {}; 2741 var _t = this; 2742 var keyValuePairs = theFormData.split(/\&/gi); 2743 _Lang.arrForEach(keyValuePairs, function(item) { 2744 var key = _Lang.trim(item.split(/\=/gi)[0]); 2745 _t._idx[decodeURIComponent(key)] = true; 2746 }); 2747 }; 2748 _newCls = this.FormDataDecoratorString; 2749 _newCls.prototype.append = function (key, val) { 2750 this._valBuf.push([encodeURIComponent(key), encodeURIComponent(val)].join("=")); 2751 this._idx[key] = true; 2752 }; 2753 //for now we check only for keys which are added subsequently otherwise we do not perform any checks 2754 _newCls.prototype.hasKey = function (key) { 2755 var _t = this; 2756 return !!(this._idx[key]); 2757 }; 2758 _newCls.prototype.makeFinal = function () { 2759 if (this._preprocessedData != "") { 2760 return this._preprocessedData + "&" + this._valBuf.join("&") 2761 } else { 2762 return this._valBuf.join("&"); 2763 } 2764 }; 2765 } 2766 if (!this.FormDataDecoratorOther) { 2767 /** 2768 * expected a form data object 2769 * @param theFormData object of type form data or something similar 2770 * @constructor 2771 */ 2772 this.FormDataDecoratorOther = function (theFormData) { 2773 this._valBuf = theFormData; 2774 this._idx = {}; 2775 2776 }; 2777 _newCls = this.FormDataDecoratorOther;
2778 _newCls.prototype.append = function (key, val) { 2779 this._valBuf.append(key, val); 2780 this._idx[key] = true; 2781 }; 2782 _newCls.prototype.hasKey = function (key) { 2783 return !!(this._idx[key] || this._valBuf.has(key)); 2784 }; 2785 _newCls.prototype.makeFinal = function () { 2786 return this._valBuf; 2787 }; 2788 } 2789 if (formData instanceof Array) { 2790 bufInstance = new this.FormDataDecoratorArray(formData); 2791 } else if (this.isString(formData)) { 2792 bufInstance = new this.FormDataDecoratorString(formData); 2793 } else { 2794 bufInstance = new this.FormDataDecoratorOther(formData); 2795 } 2796 return bufInstance; 2797 }, 2798 /** 2799 * define a property mechanism which is browser neutral 2800 * we cannot use the existing setter and getter mechanisms 2801 * for now because old browsers do not support them 2802 * in the long run we probably can switch over 2803 * or make a code split between legacy and new 2804 * 2805 * 2806 * @param obj 2807 * @param name 2808 * @param value 2809 */ 2810 attr:function (obj, name, value) { 2811 var findAccessor = function (theObj, theName) { 2812 return (theObj["_" + theName]) ? "_" + theName : ( (theObj[theName]) ? theName : null) 2813 }; 2814 var applyAttr = function (theObj, theName, value, isFunc) { 2815 if (value) { 2816 if (isFunc) { 2817 theObj[theName](value); 2818 } else { 2819 theObj[theName] = value; 2820 } 2821 return null; 2822 } 2823 return (isFunc) ? theObj[theName]() : theObj[theName]; 2824 }; 2825 try { 2826 var finalAttr = findAccessor(obj, name); 2827 //simple attibute no setter and getter overrides 2828 if (finalAttr) { 2829 return applyAttr(obj, finalAttr, value); 2830 } 2831 //lets check for setter and getter overrides 2832 var found = false; 2833 var prefix = (value) ? "set" : "get"; 2834 finalAttr = [prefix, name.substr(0, 1).toUpperCase(), name.substr(1)].join(""); 2835 finalAttr = findAccessor(obj, finalAttr); 2836 if (finalAttr) { 2837 return applyAttr(obj, finalAttr, value, true); 2838 } 2839 2840 throw this.makeException(new Error(), null, null, this._nameSpace, "contains", "property " + name + " not found"); 2841 } finally { 2842 findAccessor = null; 2843 applyAttr = null; 2844 } 2845 }, 2846 2847 /** 2848 * creates an exeption with additional internal parameters 2849 * for extra information 2850 * 2851 * @param {String} title the exception title 2852 * @param {String} name the exception name 2853 * @param {String} callerCls the caller class 2854 * @param {String} callFunc the caller function 2855 * @param {String} message the message for the exception 2856 */ 2857 makeException:function (error, title, name, callerCls, callFunc, message) { 2858 error.name = name || "clientError"; 2859 error.title = title || ""; 2860 error.message = message || ""; 2861 error._mfInternal = {}; 2862 error._mfInternal.name = name || "clientError"; 2863 error._mfInternal.title = title || "clientError"; 2864 error._mfInternal.caller = callerCls || this._nameSpace; 2865 error._mfInternal.callFunc = callFunc || ("" + arguments.caller.toString()); 2866 return error; 2867 } 2868}); 2869 2870/* Licensed to the Apache Software Foundation (ASF) under one or more 2871 * contributor license agreements. See the NOTICE file distributed with 2872 * this work for additional information regarding copyright ownership. 2873 * The ASF licenses this file to you under the Apache License, Version 2.0 2874 * (the "License"); you may not use this file except in compliance with 2875 * the License. You may obtain a copy of the License at 2876 * 2877 * http://www.apache.org/licenses/LICENSE-2.0 2878 * 2879 * Unless required by applicable law or agreed to in writing, software 2880 * distributed under the License is distributed on an "AS IS" BASIS, 2881 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2882 * See the License for the specific language governing permissions and 2883 * limitations under the License. 2884 */ 2885 2886 2887/* 2888 theoretically we could save some code 2889 by 2890 defining the parent object as 2891 var parent = new Object(); 2892 parent.prototype = new myfaces._impl.core._Runtime(); 2893 extendClass(function () { 2894 }, parent , { 2895 But for now we are not doing it the little bit of saved 2896 space is not worth the loss of readability 2897 */ 2898 2899//html5 ecmascript 3 compliant browser, no quirks mode needed 2900if(!Array.prototype.forEach && _MF_SINGLTN) { 2901/** 2902 * @memberOf myfaces._impl 2903 * @namespace 2904 * @name _util 2905 */ 2906 2907/** 2908 * @class 2909 * @name _Lang 2910 * @memberOf myfaces._impl._util 2911 * @extends myfaces._impl.core._Runtime 2912 * @namespace 2913 * @description Object singleton for Language related methods, this object singleton 2914 * decorates the namespace myfaces._impl.core._Runtime and adds a bunch of new methods to 2915 * what _Runtime provided 2916 * <p>This class provides the proper fallbacks for ie8- and Firefox 3.6-</p> 2917 * */ 2918_MF_SINGLTN(_PFX_UTIL+"_LangQuirks", myfaces._impl._util._Lang, { 2919 2920 constructor_: function() { 2921 this._callSuper("constructor_"); 2922 var _RT = this._RT; 2923 var _T = this; 2924 //we only apply lazy if the jsf part is loaded already 2925 //otherwise we are at the correct position 2926 if(myfaces._impl.core.Impl) { 2927 _RT.iterateClasses(function(proto) { 2928 if(proto._Lang) proto._Lang = _T; 2929 }); 2930 } 2931 2932 myfaces._impl._util._Lang = _T; 2933 }, 2934 2935 /** 2936 * foreach implementation utilizing the 2937 * ECMAScript wherever possible 2938 * with added functionality 2939 * 2940 * @param arr the array to filter 2941 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2942 * function (element<,key, array>) 2943 * <p /> 2944 * optional params 2945 * <p /> 2946 * <ul> 2947 * <li>param startPos (optional) the starting position </li> 2948 * <li>param scope (optional) the scope to apply the closure to </li> 2949 * </ul> 2950 */ 2951 arrForEach: function(arr, func /*startPos, scope*/) { 2952 if (!arr || !arr.length) return; 2953 try { 2954 var startPos = Number(arguments[2]) || 0; 2955 var thisObj = arguments[3]; 2956 2957 //check for an existing foreach mapping on array prototypes 2958 //IE9 still does not pass array objects as result for dom ops 2959 if (Array.prototype.forEach && arr.forEach) {
2960 (startPos) ? arr.slice(startPos).forEach(func, thisObj) : arr.forEach(func, thisObj); 2961 } else { 2962 startPos = (startPos < 0) ? Math.ceil(startPos) : Math.floor(startPos); 2963 if (typeof func != "function") { 2964 throw new TypeError(); 2965 } 2966 for (var cnt = 0; cnt < arr.length; cnt++) { 2967 if (thisObj) { 2968 func.call(thisObj, arr[cnt], cnt, arr); 2969 } else { 2970 func(arr[cnt], cnt, arr); 2971 } 2972 } 2973 } 2974 } finally { 2975 func = null; 2976 } 2977 }, 2978 2979 /** 2980 * foreach implementation utilizing the 2981 * ECMAScript wherever possible 2982 * with added functionality 2983 * 2984 * @param arr the array to filter 2985 * @param func the closure to apply the function to, with the syntax defined by the ecmascript functionality 2986 * function (element<,key, array>) 2987 * <p /> 2988 * additional params 2989 * <ul> 2990 * <li> startPos (optional) the starting position</li> 2991 * <li> scope (optional) the scope to apply the closure to</li> 2992 * </ul> 2993 */ 2994 arrFilter: function(arr, func /*startPos, scope*/) { 2995 if (!arr || !arr.length) return []; 2996 try { 2997 var startPos = Number(arguments[2]) || 0; 2998 var thisObj = arguments[3]; 2999 3000 //check for an existing foreach mapping on array prototypes 3001 if (Array.prototype.filter) { 3002 return ((startPos) ? arr.slice(startPos).filter(func, thisObj) : arr.filter(func, thisObj)); 3003 } else { 3004 if (typeof func != "function") { 3005 throw new TypeError(); 3006 } 3007 var ret = []; 3008 startPos = (startPos < 0) ? Math.ceil(startPos) : Math.floor(startPos); 3009 3010 for (var cnt = startPos; cnt < arr.length; cnt++) { 3011 var elem = null; 3012 if (thisObj) { 3013 elem = arr[cnt]; 3014 if (func.call(thisObj, elem, cnt, arr)) ret.push(elem); 3015 } else { 3016 elem = arr[cnt]; 3017 if (func(arr[cnt], cnt, arr)) ret.push(elem); 3018 } 3019 } 3020 } 3021 } finally { 3022 func = null; 3023 } 3024 }, 3025 3026 /** 3027 * adds a EcmaScript optimized indexOf to our mix, 3028 * checks for the presence of an indexOf functionality 3029 * and applies it, otherwise uses a fallback to the hold 3030 * loop method to determine the index 3031 * 3032 * @param arr the array 3033 * @param element the index to search for 3034 */ 3035 arrIndexOf: function(arr, element /*fromIndex*/) { 3036 if (!arr || !arr.length) return -1; 3037 var pos = Number(arguments[2]) || 0; 3038 3039 if (Array.prototype.indexOf) { 3040 return arr.indexOf(element, pos); 3041 } 3042 //var cnt = this._space; 3043 var len = arr.length; 3044 pos = (pos < 0) ? Math.ceil(pos) : Math.floor(pos); 3045 3046 //if negative then it is taken from as offset from the length of the array 3047 if (pos < 0) { 3048 pos += len; 3049 } 3050 while (pos < len && arr[pos] !== element) { 3051 pos++; 3052 } 3053 return (pos < len) ? pos : -1; 3054 }, 3055 3056 parseXML: function(txt) { 3057 try { 3058 var xmlDoc = null; 3059 if (window.DOMParser) { 3060 xmlDoc = this._callSuper("parseXML", txt); 3061 } 3062 else // Internet Explorer 3063 { 3064 xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 3065 xmlDoc.async = "false"; 3066 xmlDoc.loadXML(txt); 3067 } 3068 return xmlDoc; 3069 } catch (e) { 3070 //undefined internal parser error 3071 return null; 3072 } 3073 }, 3074 3075 serializeXML: function(xmlNode, escape) { 3076 if (xmlNode.xml) return xmlNode.xml; //IE 3077 return this._callSuper("serializeXML", xmlNode, escape); 3078 }, 3079 3080 /** 3081 * Concatenates an array to a string 3082 * @param {Array} arr the array to be concatenated 3083 * @param {String} delimiter the concatenation delimiter if none is set \n is used 3084 * 3085 * @return the concatenated array, one special behavior to enable j4fry compatibility has been added 3086 * if no delimiter is used the [entryNumber]+entry is generated for a single entry 3087 * TODO check if this is still needed it is somewhat outside of the scope of the function 3088 * and functionality wise dirty 3089 */ 3090 arrToString : function(/*String or array*/ arr, /*string*/ delimiter) { 3091 if (!arr) { 3092 throw this._Lang.makeException(new Error(), null, null, this._nameSpace,"arrToString", this.getMessage("ERR_MUST_BE_PROVIDED1",null, "arr {array}")); 3093 } 3094 if (this.isString(arr)) { 3095 return arr; 3096 } 3097 3098 delimiter = delimiter || "\n"; 3099 return arr.join(delimiter); 3100 } 3101}); 3102 3103} 3104 3105/* Licensed to the Apache Software Foundation (ASF) under one or more 3106 * contributor license agreements. See the NOTICE file distributed with 3107 * this work for additional information regarding copyright ownership. 3108 * The ASF licenses this file to you under the Apache License, Version 2.0 3109 * (the "License");
3109 you may not use this file except in compliance with 3110 * the License. You may obtain a copy of the License at 3111 * 3112 * http://www.apache.org/licenses/LICENSE-2.0 3113 * 3114 * Unless required by applicable law or agreed to in writing, software 3115 * distributed under the License is distributed on an "AS IS" BASIS, 3116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3117 * See the License for the specific language governing permissions and 3118 * limitations under the License. 3119 */ 3120/** 3121 Base class which provides several helper functions over all objects 3122 */ 3123_MF_CLS(_PFX_CORE+"Object", Object, { 3124 3125 3126 3127 constructor_: function() { 3128 this._resettableContent = {}; 3129 //to make those singleton references 3130 //overridable in the instance we have 3131 //to load them into the prototype instead 3132 //of the instance 3133 var proto = this._mfClazz.prototype; 3134 var impl = myfaces._impl; 3135 if(!proto._RT) { 3136 proto._RT = impl.core._Runtime; 3137 proto._Lang = impl._util._Lang; 3138 proto._Dom = impl._util._Dom; 3139 } 3140 }, 3141 3142 /*optional functionality can be provided 3143 * for ie6 but is turned off by default*/ 3144 _initDefaultFinalizableFields: function() { 3145 var isIE = this._RT.browser.isIE; 3146 if(!isIE || isIE > 7) return; 3147 for (var key in this) { 3148 //per default we reset everything which is not preinitalized 3149 if (null == this[key] && key != "_resettableContent" && key.indexOf("_mf") != 0 && key.indexOf("_") == 0) { 3150 this._resettableContent[key] = true; 3151 } 3152 } 3153 }, 3154 3155 /** 3156 * ie6 cleanup 3157 * This method disposes all properties manually in case of ie6 3158 * hence reduces the chance of running into a gc problem tremendously 3159 * on other browsers this method does nothing 3160 */ 3161 _finalize: function() { 3162 try { 3163 if (this._isGCed || !this._RT.browser.isIE || !this._resettableContent) { 3164 //no ie, no broken garbage collector 3165 return; 3166 } 3167 3168 for (var key in this._resettableContent) { 3169 if (this._RT.exists(this[key], "_finalize")) { 3170 this[key]._finalize(); 3171 } 3172 delete this[key]; 3173 } 3174 } finally { 3175 this._isGCed = true; 3176 } 3177 }, 3178 3179 attr: function(name, value) { 3180 return this._Lang.attr(this, name, value); 3181 }, 3182 3183 getImpl: function() { 3184 this._Impl = this._Impl || this._RT.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 3185 return this._Impl; 3186 }, 3187 3188 applyArgs: function(args) { 3189 this._Lang.applyArgs(this, args); 3190 }, 3191 3192 updateSingletons: function(key) { 3193 var _T = this; 3194 _T._RT.iterateSingletons(function(namespace) { 3195 if(namespace[key]) namespace[key] = _T; 3196 }); 3197 } 3198 3199}); 3200 3201(function() { 3202 /*some mobile browsers do not have a window object*/ 3203 var target = window ||document; 3204 var _RT = myfaces._impl.core._Runtime; 3205 _RT._MF_OBJECT = target._MF_OBJECT; 3206 3207 target._MF_OBJECT = myfaces._impl.core.Object; 3208})(); 3209 3210/* Licensed to the Apache Software Foundation (ASF) under one or more 3211 * contributor license agreements. See the NOTICE file distributed with 3212 * this work for additional information regarding copyright ownership. 3213 * The ASF licenses this file to you under the Apache License, Version 2.0 3214 * (the "License"); you may not use this file except in compliance with 3215 * the License. You may obtain a copy of the License at 3216 * 3217 * http://www.apache.org/licenses/LICENSE-2.0 3218 * 3219 * Unless required by applicable law or agreed to in writing, software 3220 * distributed under the License is distributed on an "AS IS" BASIS, 3221 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3222 * See the License for the specific language governing permissions and 3223 * limitations under the License. 3224 */ 3225 3226/** 3227 * @class 3228 * @name _Queue 3229 * @memberOf myfaces._impl._util 3230 * @description Queue implementation used by our runtime system 3231 * improved version of
3232 * @see <a href="http://safalra.com/web-design/javascript/queues/Queue.js">http://safalra.com/web-design/javascript/queues/Queue.js</a> 3233 */ 3234_MF_CLS(_PFX_UTIL+"_Queue", _MF_OBJECT, 3235 /** 3236 * @lends myfaces._impl._util._Queue.prototype 3237 */ 3238{ 3239 //faster queue by http://safalra.com/web-design/javascript/queues/Queue.js 3240 //license public domain 3241 //The trick is to simply reduce the number of slice and slice ops to a bare minimum. 3242 3243 _q : null, 3244 _space : 0, 3245 _size: -1, 3246 3247 /** 3248 * Standard constructor 3249 */ 3250 constructor_: function() { 3251 this._callSuper("constructor_"); 3252 this._q = []; 3253 }, 3254 3255 /** 3256 * @return the length of the queue as integer 3257 */ 3258 length: function() { 3259 // return the number of elements in the queue 3260 return this._q.length - this._space; 3261 3262 }, 3263 3264 /** 3265 * @return true if the current queue is empty false otherwise 3266 */ 3267 isEmpty: function() { 3268 // return true if the queue is empty, and false otherwise 3269 return (this._q.length == 0); 3270 }, 3271 3272 /** 3273 * Sets the current queue to a new size, all overflow elements at the end are stripped 3274 * automatically 3275 * 3276 * @param {int} newSize as numeric value 3277 */ 3278 setQueueSize: function(newSize) { 3279 this._size = newSize; 3280 this._readjust(); 3281 }, 3282 3283 /** 3284 * adds a listener to the queue 3285 * 3286 * @param element the listener to be added 3287 */ 3288 enqueue : function(/*function*/element) { 3289 this._q.push(element); 3290 //qeuesize is bigger than the limit we drop one element so that we are 3291 //back in line 3292 3293 this._readjust(); 3294 }, 3295 3296 _readjust: function() { 3297 var size = this._size; 3298 while (size && size > -1 && this.length() > size) { 3299 this.dequeue(); 3300 } 3301 }, 3302 3303 /** 3304 * removes a listener form the queue 3305 * 3306 * @param element the listener to be removed 3307 */ 3308 remove : function(/*function*/element) { 3309 /*find element in queue*/ 3310 var index = this.indexOf(element); 3311 /*found*/ 3312 if (index != -1) { 3313 this._q.splice(index, 1); 3314 } 3315 }, 3316 3317 /** 3318 * dequeues the last element in the queue 3319 * @return {Object} element which is dequeued 3320 */ 3321 dequeue: function() { 3322 // initialise the element to return to be undefined 3323 var element = null; 3324 3325 // check whether the queue is empty 3326 var qLen = this._q.length; 3327 var queue = this._q; 3328 3329 if (qLen) { 3330 3331 // fetch the oldest element in the queue 3332 element = queue[this._space]; 3333 3334 // update the amount of space and check whether a shift should occur 3335 //added here a max limit of 30 3336 //now bit shift left is a tad faster than multiplication on most vms and does the same 3337 //unless we run into a bit skipping which is impossible in our usecases here 3338 if ((++this._space) << 1 >= qLen) { 3339 3340 // set the queue equal to the non-empty portion of the queue 3341 this._q = queue.slice(this._space); 3342 3343 // reset the amount of space at the front of the queue 3344 this._space = 0; 3345 3346 } 3347 3348 } 3349 3350 // return the removed element 3351 return element; 3352 }, 3353 3354 /** 3355 * simple foreach 3356 * 3357 * @param closure a closure which processes the element 3358 * @code 3359 * queue.each(function(element) { 3360 * //do something with the element 3361 * }); 3362 */ 3363 each: function(closure) { 3364 this._Lang.arrForEach(this._q, closure, this._space); 3365 }, 3366 3367 /** 3368 * Simple filter 3369 * 3370 * @param closure a closure which returns true or false depending 3371 * whether the filter has triggered 3372 *
3373 * @return an array of filtered queue entries 3374 */ 3375 arrFilter: function(closure) { 3376 return this._Lang.arrFilter(this._q, closure, this._space); 3377 }, 3378 3379 /** 3380 * @param element 3381 * @return the current index of the element in the queue or -1 if it is not found 3382 */ 3383 indexOf: function(element) { 3384 return this._Lang.arrIndexOf(this._q, element); 3385 }, 3386 3387 /** 3388 * resets the queue to initial empty state 3389 */ 3390 cleanup: function() { 3391 this._q = []; 3392 this._space = 0; 3393 } 3394}); 3395 3396 3397/* 3398 * Licensed to the Apache Software Foundation (ASF) under one or more 3399 * contributor license agreements. See the NOTICE file distributed with 3400 * this work for additional information regarding copyright ownership. 3401 * The ASF licenses this file to you under the Apache License, Version 2.0 3402 * (the "License"); you may not use this file except in compliance with 3403 * the License. You may obtain a copy of the License at 3404 * 3405 * http://www.apache.org/licenses/LICENSE-2.0 3406 * 3407 * Unless required by applicable law or agreed to in writing, software 3408 * distributed under the License is distributed on an "AS IS" BASIS, 3409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3410 * See the License for the specific language governing permissions and 3411 * limitations under the License. 3412 */ 3413/* 3414 * a classical listener queue pattern 3415 */ 3416 3417 3418 3419/** 3420 * @class 3421 * @name _ListenerQueue 3422 * @extends myfaces._impl._util._Queue 3423 * @memberOf myfaces._impl._util 3424 * @description Implementation of the listener queue for jsf.js 3425 * <p>It is based upon our high performance queue and adds dedicated 3426 * methods for listener based closures to the mix </p> 3427 * */ 3428_MF_CLS(_PFX_UTIL+"_ListenerQueue", myfaces._impl._util._Queue, 3429/** 3430 * @lends myfaces._impl._util._ListenerQueue.prototype 3431 */ 3432{ 3433 /** 3434 * listener type safety assertion function 3435 * 3436 * @param {function} listener must be of type function otherwise an error is raised 3437 */ 3438 _assertListener : function( listener) { 3439 if ("function" != typeof (listener)) {
3440 var msg = myfaces._impl._util._Lang.getMessage("ERR_PARAM_GENERIC",null,"_ListenerQueue", arguments.caller.toString(),"function" ); 3441 throw this._Lang.makeException(new Error(), null, null, this._nameSpace,arguments.caller.toString(), msg); 3442 } 3443 }, 3444 3445 /** 3446 * adds a listener to the queue 3447 * 3448 * @param {function} listener the listener to be added 3449 */ 3450 enqueue : function(listener) { 3451 this._assertListener(listener); 3452 this._callSuper("enqueue", listener); 3453 }, 3454 3455 /** 3456 * removes a listener form the queue 3457 * 3458 * @param {function} listener the listener to be removed 3459 */ 3460 remove : function(listener) { 3461 this._assertListener(listener); 3462 this._callSuper("remove", listener); 3463 }, 3464 3465 /** 3466 * generic broadcast with a number of arguments being passed down 3467 * @param {Object} argument the arguments passed down which are broadcast 3468 */ 3469 broadcastEvent : function(argument) { 3470 var _args = myfaces._impl._util._Lang.objToArray(arguments); 3471 3472 var broadCastFunc = function(element) { 3473 element.apply(null, _args); 3474 }; 3475 try { 3476 this.each(broadCastFunc); 3477 } finally { 3478 broadCastFunc = null; 3479 } 3480 } 3481}); 3482/* Licensed to the Apache Software Foundation (ASF) under one or more 3483 * contributor license agreements. See the NOTICE file distributed with 3484 * this work for additional information regarding copyright ownership. 3485 * The ASF licenses this file to you under the Apache License, Version 2.0 3486 * (the "License"); you may not use this file except in compliance with 3487 * the License. You may obtain a copy of the License at 3488 * 3489 * http://www.apache.org/licenses/LICENSE-2.0 3490 * 3491 * Unless required by applicable law or agreed to in writing, software 3492 * distributed under the License is distributed on an "AS IS" BASIS, 3493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3494 * See the License for the specific language governing permissions and 3495 * limitations under the License. 3496 */ 3497 3498/** 3499 * @class 3500 * @name _Dom 3501 * @memberOf myfaces._impl._util 3502 * @extends myfaces._impl.core._Runtime 3503 * @description Object singleton collection of dom helper routines 3504 * (which in later incarnations will 3505 * get browser specific speed optimizations) 3506 * 3507 * Since we have to be as tight as possible 3508 * we will focus with our dom routines to only 3509 * the parts which our impl uses. 3510 * A jquery like query API would be nice 3511 * but this would increase up our codebase significantly 3512 * 3513 * <p>This class provides the proper fallbacks for ie8- and Firefox 3.6-</p> 3514 */ 3515_MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prototype */ { 3516 3517 /*table elements which are used in various parts */ 3518 TABLE_ELEMS: { 3519 "thead": 1, 3520 "tbody": 1, 3521 "tr": 1, 3522 "th": 1, 3523 "td": 1, 3524 "tfoot" : 1 3525 }, 3526 3527 _Lang: myfaces._impl._util._Lang, 3528 _RT: myfaces._impl.core._Runtime, 3529 _dummyPlaceHolder:null, 3530 3531 /** 3532 * standard constructor 3533 */ 3534 constructor_: function() { 3535 }, 3536 3537 runCss: function(item/*, xmlData*/) { 3538 3539 var UDEF = "undefined", 3540 _RT = this._RT, 3541 _Lang = this._Lang, 3542 applyStyle = function(item, style) { 3543 var newSS = document.createElement("style"); 3544 3545 newSS.setAttribute("rel", item.getAttribute("rel") || "stylesheet"); 3546 newSS.setAttribute("type", item.getAttribute("type") || "text/css"); 3547 document.getElementsByTagName("head")[0].appendChild(newSS); 3548 //ie merrily again goes its own way 3549 if (window.attachEvent && !_RT.isOpera && UDEF != typeof newSS.styleSheet && UDEF != newSS.styleSheet.cssText) newSS.styleSheet.cssText = style; 3550 else newSS.appendChild(document.createTextNode(style)); 3551 }, 3552 3553 execCss = function(item) { 3554 var equalsIgnoreCase = _Lang.equalsIgnoreCase; 3555 var tagName = item.tagName; 3556 if (tagName && equalsIgnoreCase(tagName, "link") && equalsIgnoreCase(item.getAttribute("type"), "text/css")) { 3557 applyStyle(item, "@import url('" + item.getAttribute("href") + "');"); 3558 } else if (tagName && equalsIgnoreCase(tagName, "style") && equalsIgnoreCase(item.getAttribute("type"), "text/css")) { 3559 var innerText = []; 3560 //compliant browsers know child nodes 3561 var childNodes = item.childNodes; 3562 if (childNodes) { 3563 var len = childNodes.length; 3564 for (var cnt = 0; cnt < len; cnt++) { 3565 innerText.push(childNodes[cnt].innerHTML || childNodes[cnt].data); 3566 } 3567 //non compliant ones innerHTML 3568 } else if (item.innerHTML) { 3569 innerText.push(item.innerHTML); 3570 } 3571 3572 applyStyle(item, innerText.join("")); 3573 } 3574 }; 3575 3576 try { 3577 var scriptElements = this.findByTagNames(item, {"link":1,"style":1}, true); 3578 if (scriptElements == null) return; 3579 for (var cnt = 0; cnt < scriptElements.length; cnt++) { 3580 execCss(scriptElements[cnt]); 3581 } 3582 3583 } finally { 3584 //the usual ie6 fix code 3585 //the IE6 garbage collector is broken 3586 //nulling closures helps somewhat to reduce 3587 //mem leaks, which are impossible to avoid 3588 //at this browser 3589 execCss = null; 3590 applyStyle = null; 3591 } 3592 }, 3593 3594 3595 /** 3596 * Run through the given Html item and execute the inline scripts 3597 * (IE doesn't do this by itself) 3598 * @param {Node} item 3599 */ 3600 runScripts: function(item, xmlData) { 3601 var _Lang = this._Lang, 3602 _RT = this._RT, 3603 finalScripts = [], 3604 execScrpt = function(item) { 3605 var tagName = item.tagName; 3606 var type = item.type || ""; 3607 //script type javascript has to be handled by eval, other types 3608 //must be handled by the browser 3609 if (tagName && _Lang.equalsIgnoreCase(tagName, "script") && 3610 (type === "" || 3611 _Lang.equalsIgnoreCase(type,"text/javascript") || 3612 _Lang.equalsIgnoreCase(type,"javascript") || 3613 _Lang.equalsIgnoreCase(type,"text/ecmascript") || 3614 _Lang.equalsIgnoreCase(type,"ecmascript"))) { 3615 3616 var src = item.getAttribute('src'); 3617 if ('undefined' != typeof src 3618 && null != src 3619 && src.length > 0 3620 ) { 3621 //we have to move this into an inner if because chrome otherwise chokes 3622 //due to changing the and order instead of relying on left to right 3623 //if jsf.js is already registered we do not replace it anymore 3624 if ((src.indexOf("ln=scripts") == -1 && src.indexOf("ln=javax.faces") == -1) || (src.indexOf("/jsf.js") == -1 3625 && src.indexOf("/jsf-uncompressed.js") == -1)) { 3626 if (finalScripts.length) { 3627 //script source means we have to eval the existing 3628 //scripts before running the include 3629 _RT.globalEval(finalScripts.join("\n")); 3630 3631 finalScripts = []; 3632 } 3633 _RT.loadScriptEval(src, item.getAttribute('type'), false, "UTF-8", false); 3634 } 3635 3636 } else { 3637 // embedded script auto eval 3638 var test = (!xmlData) ? item.text : _Lang.serializeChilds(item); 3639 var go = true; 3640 while (go) { 3641 go = false;
3642 if (test.substring(0, 1) == " ") { 3643 test = test.substring(1); 3644 go = true; 3645 } 3646 if (test.substring(0, 4) == "<!--") { 3647 test = test.substring(4); 3648 go = true; 3649 } 3650 if (test.substring(0, 11) == "//<![CDATA[") { 3651 test = test.substring(11); 3652 go = true; 3653 } 3654 } 3655 // we have to run the script under a global context 3656 //we store the script for less calls to eval 3657 finalScripts.push(test); 3658 3659 } 3660 } 3661 }; 3662 try { 3663 var scriptElements = this.findByTagName(item, "script", true); 3664 if (scriptElements == null) return; 3665 for (var cnt = 0; cnt < scriptElements.length; cnt++) { 3666 execScrpt(scriptElements[cnt]); 3667 } 3668 if (finalScripts.length) { 3669 _RT.globalEval(finalScripts.join("\n")); 3670 } 3671 } catch (e) { 3672 //we are now in accordance with the rest of the system of showing errors only in development mode 3673 //the default error output is alert we always can override it with 3674 //window.myfaces = window.myfaces ||Â {}; 3675 //myfaces.config = myfaces.config ||Â {}; 3676 //myfaces.config.defaultErrorOutput = console.error; 3677 if(jsf.getProjectStage() === "Development") { 3678 var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert); 3679 defaultErrorOutput("Error in evaluated javascript:"+ (e.message || e.description || e)); 3680 } 3681 } finally { 3682 //the usual ie6 fix code 3683 //the IE6 garbage collector is broken 3684 //nulling closures helps somewhat to reduce 3685 //mem leaks, which are impossible to avoid 3686 //at this browser 3687 execScrpt = null; 3688 } 3689 }, 3690 3691 3692 /** 3693 * determines to fetch a node 3694 * from its id or name, the name case 3695 * only works if the element is unique in its name 3696 * @param {String} elem 3697 */ 3698 byIdOrName: function(elem) { 3699 if (!elem) return null; 3700 if (!this._Lang.isString(elem)) return elem; 3701 3702 var ret = this.byId(elem); 3703 if (ret) return ret; 3704 //we try the unique name fallback 3705 var items = document.getElementsByName(elem); 3706 return ((items.length == 1) ? items[0] : null); 3707 }, 3708 3709 /** 3710 * node id or name, determines the valid form identifier of a node 3711 * depending on its uniqueness 3712 * 3713 * Usually the id is chosen for an elem, but if the id does not 3714 * exist we try a name fallback. If the passed element has a unique 3715 * name we can use that one as subsequent identifier. 3716 * 3717 * 3718 * @param {String} elem 3719 */ 3720 nodeIdOrName: function(elem) { 3721 if (elem) { 3722 //just to make sure that the pas 3723 3724 elem = this.byId(elem); 3725 if (!elem) return null; 3726 //detached element handling, we also store the element name 3727 //to get a fallback option in case the identifier is not determinable 3728 // anymore, in case of a framework induced detachment the element.name should 3729 // be shared if the identifier is not determinable anymore 3730 //the downside of this method is the element name must be unique 3731 //which in case of jsf it is 3732 var elementId = elem.id || elem.name; 3733 if ((elem.id == null || elem.id == '') && elem.name) { 3734 elementId = elem.name; 3735 3736 //last check for uniqueness 3737 if (this.getElementsByName(elementId).length > 1) { 3738 //no unique element name so we need to perform 3739 //a return null to let the caller deal with this issue 3740 return null; 3741 } 3742 } 3743 return elementId; 3744 } 3745 return null; 3746 }, 3747 3748 deleteItems: function(items) { 3749 if (! items || ! items.length) return; 3750 for (var cnt = 0; cnt < items.length; cnt++) { 3751 this.deleteItem(items[cnt]); 3752 } 3753 }, 3754 3755 /** 3756 * Simple delete on an existing item 3757 */ 3758 deleteItem: function(itemIdToReplace) { 3759 var item = this.byId(itemIdToReplace); 3760 if (!item) { 3761 throw this._Lang.makeException(new Error(),null, null, this._nameSpace, "deleteItem", "_Dom.deleteItem Unknown Html-Component-ID: " + itemIdToReplace); 3762 } 3763 3764 this._removeNode(item, false); 3765 }, 3766 3767 /** 3768 * creates a node upon a given node name 3769 * @param nodeName {String} the node name to be created 3770 * @param attrs {Array} a set of attributes to be set 3771 */ 3772 createElement: function(nodeName, attrs) { 3773 var ret = document.createElement(nodeName); 3774 if (attrs) { 3775 for (var key in attrs) { 3776 if(!attrs.hasOwnProperty(key)) continue; 3777 this.setAttribute(ret, key, attrs[key]); 3778 } 3779 } 3780 return ret; 3781 }, 3782 3783 /** 3784 * Checks whether the browser is dom compliant. 3785 * Dom compliant means that it performs the basic dom operations safely 3786 * without leaking and also is able to perform a native setAttribute 3787 * operation without freaking out 3788 * 3789 * 3790 * Not dom compliant browsers are all microsoft browsers in quirks mode 3791 * and ie6 and ie7 to some degree in standards mode 3792 * and pretty much every browser who cannot create ranges 3793 * (older mobile browsers etc...) 3794 * 3795 * We dont do a full browser detection here because it probably is safer 3796 * to test for existing features to make an assumption about the 3797 * browsers capabilities 3798 */ 3799 isDomCompliant: function() { 3800 return true; 3801 }, 3802 3803 /** 3804 * proper insert before which takes tables into consideration as well as 3805 * browser deficiencies 3806 * @param item the node to insert before 3807 * @param markup the markup to be inserted 3808 */ 3809 insertBefore: function(item, markup) { 3810 this._assertStdParams(item, markup, "insertBefore"); 3811 3812 markup = this._Lang.trim(markup); 3813 if (markup === "") return null; 3814 3815 var evalNodes = this._buildEvalNodes(item, markup), 3816 currentRef = item, 3817 parentNode = item.parentNode, 3818 ret = []; 3819 for (var cnt = evalNodes.length - 1; cnt >= 0; cnt--) { 3820 currentRef = parentNode.insertBefore(evalNodes[cnt], currentRef);
3821 ret.push(currentRef); 3822 } 3823 ret = ret.reverse(); 3824 this._eval(ret); 3825 return ret; 3826 }, 3827 3828 /** 3829 * proper insert before which takes tables into consideration as well as 3830 * browser deficiencies 3831 * @param item the node to insert before 3832 * @param markup the markup to be inserted 3833 */ 3834 insertAfter: function(item, markup) { 3835 this._assertStdParams(item, markup, "insertAfter"); 3836 markup = this._Lang.trim(markup); 3837 if (markup === "") return null; 3838 3839 var evalNodes = this._buildEvalNodes(item, markup), 3840 currentRef = item, 3841 parentNode = item.parentNode, 3842 ret = []; 3843 3844 for (var cnt = 0; cnt < evalNodes.length; cnt++) { 3845 if (currentRef.nextSibling) { 3846 //Winmobile 6 has problems with this strategy, but it is not really fixable 3847 currentRef = parentNode.insertBefore(evalNodes[cnt], currentRef.nextSibling); 3848 } else { 3849 currentRef = parentNode.appendChild(evalNodes[cnt]); 3850 } 3851 ret.push(currentRef); 3852 } 3853 this._eval(ret); 3854 return ret; 3855 }, 3856 3857 propertyToAttribute: function(name) { 3858 if (name === 'className') { 3859 return 'class'; 3860 } else if (name === 'xmllang') { 3861 return 'xml:lang'; 3862 } else { 3863 return name.toLowerCase(); 3864 } 3865 }, 3866 3867 isFunctionNative: function(func) { 3868 return /^\s*function[^{]+{\s*\[native code\]\s*}\s*$/.test(String(func)); 3869 }, 3870 3871 detectAttributes: function(element) { 3872 //test if 'hasAttribute' method is present and its native code is intact 3873 //for example, Prototype can add its own implementation if missing 3874 if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) { 3875 return function(name) { 3876 return element.hasAttribute(name); 3877 } 3878 } else { 3879 try { 3880 //when accessing .getAttribute method without arguments does not throw an error then the method is not available 3881 element.getAttribute; 3882 3883 var html = element.outerHTML; 3884 var startTag = html.match(/^<[^>]*>/)[0]; 3885 return function(name) { 3886 return startTag.indexOf(name + '=') > -1; 3887 } 3888 } catch (ex) { 3889 return function(name) { 3890 return element.getAttribute(name); 3891 } 3892 } 3893 } 3894 }, 3895 3896 /** 3897 * copy all attributes from one element to another - except id 3898 * @param target element to copy attributes to 3899 * @param source element to copy attributes from 3900 * @ignore 3901 */ 3902 cloneAttributes: function(target, source) { 3903 3904 // enumerate core element attributes - without 'dir' as special case 3905 var coreElementProperties = ['className', 'title', 'lang', 'xmllang']; 3906 // enumerate additional input element attributes 3907 var inputElementProperties = [ 3908 'name', 'value', 'size', 'maxLength', 'src', 'alt', 'useMap', 'tabIndex', 'accessKey', 'accept', 'type' 3909 ]; 3910 // enumerate additional boolean input attributes 3911 var inputElementBooleanProperties = [ 3912 'checked', 'disabled', 'readOnly' 3913 ]; 3914 3915 // Enumerate all the names of the event listeners 3916 var listenerNames = 3917 [ 'onclick', 'ondblclick', 'onmousedown', 'onmousemove', 'onmouseout', 3918 'onmouseover', 'onmouseup', 'onkeydown', 'onkeypress', 'onkeyup', 3919 'onhelp', 'onblur', 'onfocus', 'onchange', 'onload', 'onunload', 'onabort', 3920 'onreset', 'onselect', 'onsubmit' 3921 ]; 3922 3923 var sourceAttributeDetector = this.detectAttributes(source); 3924 var targetAttributeDetector = this.detectAttributes(target); 3925 3926 var isInputElement = target.nodeName.toLowerCase() === 'input'; 3927 var propertyNames = isInputElement ? coreElementProperties.concat(inputElementProperties) : coreElementProperties; 3928 var isXML = !source.ownerDocument.contentType || source.ownerDocument.contentType == 'text/xml'; 3929 for (var iIndex = 0, iLength = propertyNames.length; iIndex < iLength; iIndex++) { 3930 var propertyName = propertyNames[iIndex]; 3931 var attributeName = this.propertyToAttribute(propertyName); 3932 if (sourceAttributeDetector(attributeName)) { 3933 3934 //With IE 7 (quirks or standard mode) and IE 8/9 (quirks mode only), 3935 //you cannot get the attribute using 'class'. You must use 'className' 3936 //which is the same value you use to get the indexed property. The only 3937 //reliable way to detect this (without trying to evaluate the browser 3938 //mode and version) is to compare the two return values using 'className' 3939 //to see if they exactly the same. If they are, then use the property 3940 //name when using getAttribute. 3941 if( attributeName == 'class'){ 3942 if( this._RT.browser.isIE && (source.getAttribute(propertyName) === source[propertyName]) ){ 3943 attributeName = propertyName; 3944 } 3945 } 3946 3947 var newValue = isXML ? source.getAttribute(attributeName) : source[propertyName]; 3948 var oldValue = target[propertyName]; 3949 if (oldValue != newValue) { 3950 target[propertyName] = newValue; 3951 } 3952 } else { 3953 target.removeAttribute(attributeName); 3954 if (attributeName == "value") { 3955 target[propertyName] = ''; 3956 } 3957 } 3958 } 3959 3960 var booleanPropertyNames = isInputElement ? inputElementBooleanProperties : []; 3961 for (var jIndex = 0, jLength = booleanPropertyNames.length; jIndex < jLength; jIndex++) { 3962 var booleanPropertyName = booleanPropertyNames[jIndex]; 3963 var newBooleanValue = source[booleanPropertyName]; 3964 var oldBooleanValue = target[booleanPropertyName]; 3965 if (oldBooleanValue != newBooleanValue) { 3966 target[booleanPropertyName] = newBooleanValue; 3967 } 3968 } 3969 3970 //'style' attribute special case 3971 if (sourceAttributeDetector('style')) { 3972 var newStyle; 3973 var oldStyle; 3974 if (this._RT.browser.isIE) { 3975 newStyle = source.style.cssText; 3976 oldStyle = target.style.cssText; 3977 if (newStyle != oldStyle) { 3978 target.style.cssText = newStyle; 3979 } 3980 } else { 3981 newStyle = source.getAttribute('style'); 3982 oldStyle = target.getAttribute('style'); 3983 if (newStyle != oldStyle) { 3984 target.setAttribute('style', newStyle); 3985 } 3986 } 3987 } else if (targetAttributeDetector('style')){ 3988 target.removeAttribute('style'); 3989 } 3990 3991 // Special case for 'dir' attribute 3992 if (!this._RT.browser.isIE && source.dir != target.dir) { 3993 if (sourceAttributeDetector('dir')) { 3994 target.dir = source.dir; 3995 } else if (targetAttributeDetector('dir')) { 3996 target.dir = ''; 3997 } 3998 } 3999 4000 for (var lIndex = 0, lLength = listenerNames.length; lIndex < lLength; lIndex++) { 4001 var name = listenerNames[lIndex]; 4002 target[name] = source[name] ? source[name] : null; 4003 if (source[name]) { 4004 source[name] = null; 4005 } 4006 } 4007 4008 //clone HTML5 data-* attributes 4009 try{ 4010 var targetDataset = target.dataset; 4011 var sourceDataset = source.dataset; 4012 if (targetDataset || sourceDataset) { 4013 //cleanup the dataset 4014 for (var tp in targetDataset) { 4015 delete targetDataset[tp]; 4016 } 4017 //copy dataset's properties 4018 for (var sp in sourceDataset) { 4019 targetDataset[sp] = sourceDataset[sp]; 4020 } 4021 } 4022 } catch (ex) { 4023 //most probably dataset properties are not supported 4024 } 4025 }, 4026 //from 4027 // http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ 4028 getCaretPosition:function (ctrl) { 4029 var caretPos = 0; 4030 4031 try { 4032 4033 // other browsers make it simpler by simply having a selection start element 4034 if (ctrl.selectionStart || ctrl.selectionStart == '0') 4035 caretPos = ctrl.selectionStart; 4036 // ie 5 quirks mode as second option because 4037 // this option is flakey in conjunction with text areas 4038 // TODO move this into the quirks class 4039 else if (document.selection) { 4040 ctrl.focus(); 4041 var selection = document.selection.createRange(); 4042 //the selection now is start zero 4043 selection.moveStart('character', -ctrl.value.length); 4044 //the caretposition is the selection start 4045 caretPos = selection.text.length; 4046 } 4047 } catch (e) { 4048 //now this is ugly, but not supported input types throw errors for selectionStart 4049 //this way we are future proof by having not to define every selection enabled 4050 //input in an if (which will be a lot in the near future with html5) 4051 } 4052 return caretPos; 4053 }, 4054 4055 setCaretPosition:function (ctrl, pos) { 4056 4057 if (ctrl.createTextRange) { 4058 var range = ctrl.createTextRange(); 4059 range.collapse(true); 4060 range.moveEnd('character', pos); 4061 range.moveStart('character', pos); 4062 range.select(); 4063 } 4064 //IE quirks mode again, TODO move this into the quirks class 4065 else if (ctrl.setSelectionRange) { 4066 ctrl.focus();
4067 //the selection range is our caret position 4068 ctrl.setSelectionRange(pos, pos); 4069 } 4070 }, 4071 4072 /** 4073 * outerHTML replacement which works cross browserlike 4074 * but still is speed optimized 4075 * 4076 * @param item the item to be replaced 4077 * @param markup the markup for the replacement 4078 * @param preserveFocus, tries to preserve the focus within the outerhtml operation 4079 * if set to true a focus preservation algorithm based on document.activeElement is 4080 * used to preserve the focus at the exactly same location as it was 4081 * 4082 */ 4083 outerHTML : function(item, markup, preserveFocus) { 4084 this._assertStdParams(item, markup, "outerHTML"); 4085 // we can work on a single element in a cross browser fashion 4086 // regarding the focus thanks to the 4087 // icefaces team for providing the code 4088 if (item.nodeName.toLowerCase() === 'input') { 4089 var replacingInput = this._buildEvalNodes(item, markup)[0]; 4090 this.cloneAttributes(item, replacingInput); 4091 return item; 4092 } else { 4093 markup = this._Lang.trim(markup); 4094 if (markup !== "") { 4095 var ret = null; 4096 4097 var focusElementId = null; 4098 var caretPosition = 0; 4099 if (preserveFocus && 'undefined' != typeof document.activeElement) { 4100 focusElementId = (document.activeElement) ? document.activeElement.id : null; 4101 caretPosition = this.getCaretPosition(document.activeElement); 4102 } 4103 // we try to determine the browsers compatibility 4104 // level to standards dom level 2 via various methods 4105 if (this.isDomCompliant()) { 4106 ret = this._outerHTMLCompliant(item, markup); 4107 } else { 4108 //call into abstract method 4109 ret = this._outerHTMLNonCompliant(item, markup); 4110 } 4111 if (focusElementId) { 4112 var newFocusElement = this.byId(focusElementId); 4113 if (newFocusElement && newFocusElement.nodeName.toLowerCase() === 'input') { 4114 //just in case the replacement element is not focusable anymore 4115 if ("undefined" != typeof newFocusElement.focus) { 4116 newFocusElement.focus(); 4117 } 4118 } 4119 if (newFocusElement && caretPosition) { 4120 //zero caret position is set automatically on focus 4121 this.setCaretPosition(newFocusElement, caretPosition); 4122 } 4123 } 4124 4125 // and remove the old item 4126 //first we have to save the node newly insert for easier access in our eval part 4127 this._eval(ret); 4128 return ret; 4129 } 4130 // and remove the old item, in case of an empty newtag and do nothing else 4131 this._removeNode(item, false); 4132 return null; 4133 } 4134 }, 4135 4136 isFunctionNative: function(func) { 4137 return /^\s*function[^{]+{\s*\[native code\]\s*}\s*$/.test(String(func)); 4138 }, 4139 4140 detectAttributes: function(element) { 4141 //test if 'hasAttribute' method is present and its native code is intact 4142 //for example, Prototype can add its own implementation if missing 4143 if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) { 4144 return function(name) { 4145 return element.hasAttribute(name); 4146 } 4147 } else { 4148 try { 4149 //when accessing .getAttribute method without arguments does not throw an error then the method is not available 4150 element.getAttribute; 4151 4152 var html = element.outerHTML; 4153 var startTag = html.match(/^<[^>]*>/)[0]; 4154 return function(name) { 4155 return startTag.indexOf(name + '=') > -1; 4156 } 4157 } catch (ex) { 4158 return function(name) { 4159 return element.getAttribute(name); 4160 } 4161 } 4162 } 4163 }, 4164 4165 /** 4166 * detaches a set of nodes from their parent elements 4167 * in a browser independend manner 4168 * @param {Object} items the items which need to be detached 4169 * @return {Array} an array of nodes with the detached dom nodes 4170 */ 4171 detach: function(items) { 4172 var ret = []; 4173 if ('undefined' != typeof items.nodeType) { 4174 if (items.parentNode) {
4175 ret.push(items.parentNode.removeChild(items)); 4176 } else { 4177 ret.push(items); 4178 } 4179 return ret; 4180 } 4181 //all ies treat node lists not as arrays so we have to take 4182 //an intermediate step 4183 var nodeArr = this._Lang.objToArray(items); 4184 for (var cnt = 0; cnt < nodeArr.length; cnt++) { 4185 ret.push(nodeArr[cnt].parentNode.removeChild(nodeArr[cnt])); 4186 } 4187 return ret; 4188 }, 4189 4190 _outerHTMLCompliant: function(item, markup) { 4191 //table element replacements like thead, tbody etc... have to be treated differently 4192 var evalNodes = this._buildEvalNodes(item, markup); 4193 4194 if (evalNodes.length == 1) { 4195 var ret = evalNodes[0]; 4196 item.parentNode.replaceChild(ret, item); 4197 return ret; 4198 } else { 4199 return this.replaceElements(item, evalNodes); 4200 } 4201 }, 4202 4203 /** 4204 * checks if the provided element is a subelement of a table element 4205 * @param item 4206 */ 4207 _isTableElement: function(item) { 4208 return !!this.TABLE_ELEMS[(item.nodeName || item.tagName).toLowerCase()]; 4209 }, 4210 4211 /** 4212 * non ie browsers do not have problems with embedded scripts or any other construct 4213 * we simply can use an innerHTML in a placeholder 4214 * 4215 * @param markup the markup to be used 4216 */ 4217 _buildNodesCompliant: function(markup) { 4218 var dummyPlaceHolder = this.getDummyPlaceHolder(); //document.createElement("div"); 4219 dummyPlaceHolder.innerHTML = markup; 4220 return this._Lang.objToArray(dummyPlaceHolder.childNodes); 4221 }, 4222 4223 4224 4225 4226 /** 4227 * builds up a correct dom subtree 4228 * if the markup is part of table nodes 4229 * The usecase for this is to allow subtable rendering 4230 * like single rows thead or tbody 4231 * 4232 * @param item 4233 * @param markup 4234 */ 4235 _buildTableNodes: function(item, markup) { 4236 var itemNodeName = (item.nodeName || item.tagName).toLowerCase(); 4237 4238 var tmpNodeName = itemNodeName; 4239 var depth = 0; 4240 while (tmpNodeName != "table") { 4241 item = item.parentNode; 4242 tmpNodeName = (item.nodeName || item.tagName).toLowerCase(); 4243 depth++; 4244 } 4245 4246 var dummyPlaceHolder = this.getDummyPlaceHolder(); 4247 if (itemNodeName == "td") { 4248 dummyPlaceHolder.innerHTML = "<table><tbody><tr>" + markup + "</tr></tbody></table>"; 4249 } else { 4250 dummyPlaceHolder.innerHTML = "<table>" + markup + "</table>"; 4251 } 4252 4253 for (var cnt = 0; cnt < depth; cnt++) { 4254 dummyPlaceHolder = dummyPlaceHolder.childNodes[0]; 4255 } 4256 4257 return this.detach(dummyPlaceHolder.childNodes); 4258 }, 4259 4260 _removeChildNodes: function(node /*, breakEventsOpen */) { 4261 if (!node) return; 4262 node.innerHTML = ""; 4263 }, 4264 4265 4266 4267 _removeNode: function(node /*, breakEventsOpen*/) { 4268 if (!node) return; 4269 var parentNode = node.parentNode; 4270 if (parentNode) //if the node has a parent 4271 parentNode.removeChild(node); 4272 }, 4273 4274 4275 /** 4276 * build up the nodes from html markup in a browser independend way 4277 * so that it also works with table nodes 4278 * 4279 * @param item the parent item upon the nodes need to be processed upon after building 4280 * @param markup the markup to be built up 4281 */ 4282 _buildEvalNodes: function(item, markup) { 4283 var evalNodes = null; 4284 if (this._isTableElement(item)) { 4285 evalNodes = this._buildTableNodes(item, markup); 4286 } else { 4287 var nonIEQuirks = (!this._RT.browser.isIE || this._RT.browser.isIE > 8); 4288 //ie8 has a special problem it still has the swallow scripts and other 4289 //elements bug, but it is mostly dom compliant so we have to give it a special 4290 //treatment, IE9 finally fixes that issue finally after 10 years 4291 evalNodes = (this.isDomCompliant() && nonIEQuirks) ? 4292 this._buildNodesCompliant(markup) : 4293 //ie8 or quirks mode browsers 4294 this._buildNodesNonCompliant(markup); 4295 } 4296 return evalNodes; 4297 }, 4298 4299 /** 4300 * we have lots of methods with just an item and a markup as params 4301 * this method builds an assertion for those methods to reduce code 4302 * 4303 * @param item the item to be tested 4304 * @param markup the markup 4305 * @param caller caller function 4306 * @param {optional} params array of assertion param names 4307 */ 4308 _assertStdParams: function(item, markup, caller, params) { 4309 //internal error 4310 if (!caller) { 4311 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "_assertStdParams", "Caller must be set for assertion"); 4312 } 4313 var _Lang = this._Lang, 4314 ERR_PROV = "ERR_MUST_BE_PROVIDED1", 4315 DOM = "myfaces._impl._util._Dom.", 4316 finalParams = params || ["item", "markup"]; 4317 4318 if (!item || !markup) { 4319 _Lang.makeException(new Error(), null, null,DOM, ""+caller, _Lang.getMe
4319ssage(ERR_PROV, null, DOM +"."+ caller, (!item) ? finalParams[0] : finalParams[1])); 4320 //throw Error(_Lang.getMessage(ERR_PROV, null, DOM + caller, (!item) ? params[0] : params[1])); 4321 } 4322 }, 4323 4324 /** 4325 * internal eval handler used by various functions 4326 * @param _nodeArr 4327 */ 4328 _eval: function(_nodeArr) { 4329 if (this.isManualScriptEval()) { 4330 var isArr = _nodeArr instanceof Array; 4331 if (isArr && _nodeArr.length) { 4332 for (var cnt = 0; cnt < _nodeArr.length; cnt++) { 4333 this.runScripts(_nodeArr[cnt]); 4334 } 4335 } else if (!isArr) { 4336 this.runScripts(_nodeArr); 4337 } 4338 } 4339 }, 4340 4341 /** 4342 * for performance reasons we work with replaceElement and replaceElements here 4343 * after measuring performance it has shown that passing down an array instead 4344 * of a single node makes replaceElement twice as slow, however 4345 * a single node case is the 95% case 4346 * 4347 * @param item 4348 * @param evalNode 4349 */ 4350 replaceElement: function(item, evalNode) { 4351 //browsers with defect garbage collection 4352 item.parentNode.insertBefore(evalNode, item); 4353 this._removeNode(item, false); 4354 }, 4355 4356 4357 /** 4358 * replaces an element with another element or a set of elements 4359 * 4360 * @param item the item to be replaced 4361 * 4362 * @param evalNodes the elements 4363 */ 4364 replaceElements: function (item, evalNodes) { 4365 var evalNodesDefined = evalNodes && 'undefined' != typeof evalNodes.length; 4366 if (!evalNodesDefined) { 4367 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "replaceElements", this._Lang.getMessage("ERR_REPLACE_EL")); 4368 } 4369 4370 var parentNode = item.parentNode, 4371 4372 sibling = item.nextSibling, 4373 resultArr = this._Lang.objToArray(evalNodes); 4374 4375 for (var cnt = 0; cnt < resultArr.length; cnt++) { 4376 if (cnt == 0) { 4377 this.replaceElement(item, resultArr[cnt]); 4378 } else { 4379 if (sibling) { 4380 parentNode.insertBefore(resultArr[cnt], sibling); 4381 } else { 4382 parentNode.appendChild(resultArr[cnt]); 4383 } 4384 } 4385 } 4386 return resultArr; 4387 }, 4388 4389 /** 4390 * optimized search for an array of tag names 4391 * deep scan will always be performed. 4392 * @param fragment the fragment which should be searched for 4393 * @param tagNames an map indx of tag names which have to be found 4394 * 4395 */ 4396 findByTagNames: function(fragment, tagNames) { 4397 this._assertStdParams(fragment, tagNames, "findByTagNames", ["fragment", "tagNames"]); 4398 4399 var nodeType = fragment.nodeType; 4400 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4401 4402 //we can use the shortcut 4403 if (fragment.querySelectorAll) { 4404 var query = []; 4405 for (var key in tagNames) { 4406 if(!tagNames.hasOwnProperty(key)) continue; 4407 query.push(key); 4408 } 4409 var res = []; 4410 if (fragment.tagName && tagNames[fragment.tagName.toLowerCase()]) { 4411 res.push(fragment); 4412 } 4413 return res.concat(this._Lang.objToArray(fragment.querySelectorAll(query.join(", ")))); 4414 } 4415 4416 //now the filter function checks case insensitively for the tag names needed 4417 var filter = function(node) { 4418 return node.tagName && tagNames[node.tagName.toLowerCase()]; 4419 }; 4420 4421 //now we run an optimized find all on it 4422 try { 4423 return this.findAll(fragment, filter, true); 4424 } finally { 4425 //the usual IE6 is broken, fix code 4426 filter = null; 4427 } 4428 }, 4429 4430 /** 4431 * determines the number of nodes according to their tagType 4432 * 4433 * @param {Node} fragment (Node or fragment) the fragment to be investigated 4434 * @param {String} tagName the tag name (lowercase) 4435 * (the normal usecase is false, which means if the element is found only its 4436 * adjacent elements will be scanned, due to the recursive descension 4437 * this should work out with elements with different nesting depths but not being 4438 * parent and child to each other 4439 * 4440 * @return the child elements as array or null if nothing is found 4441 * 4442 */ 4443 findByTagName : function(fragment, tagName) { 4444 this._assertStdParams(fragment, tagName, "findByTagName", ["fragment", "tagName"]); 4445 var _Lang = this._Lang, 4446 nodeType = fragment.nodeType; 4447 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4448 4449 //remapping to save a few bytes 4450 4451 var ret = _Lang.objToArray(fragment.getElementsByTagName(tagName)); 4452 if (fragment.tagName && _Lang.equalsIgnoreCase(fragment.tagName, tagName)) ret.unshift(fragment); 4453 return ret; 4454 }, 4455 4456 findByName : function(fragment, name) { 4457 this._assertStdParams(fragment, name, "findByName", ["fragment", "name"]); 4458 4459 var nodeType = fragment.nodeType; 4460 if (nodeType != 1 && nodeType != 9 && nodeType != 11) return null; 4461 4462 var ret = this._Lang.objToArray(fragment.getElementsByName(name)); 4463 if (fragment.name == name) ret.unshift(fragment); 4464 return ret; 4465 }, 4466 4467 /** 4468 * a filtered findAll for subdom treewalking 4469 * (which uses browser optimizations wherever possible) 4470 * 4471 * @param {|Node|} rootNode the rootNode so start the scan 4472 * @param filter filter closure with the syntax {boolean} filter({Node} node) 4473 * @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) 4474 */ 4475 findAll : function(rootNode, filter, deepScan) { 4476 this._Lang.assertType(filter, "function"); 4477 deepScan = !!deepScan; 4478 4479 if (document.createTreeWalker && NodeFilter) { 4480 return this._iteratorSearchAll(rootNode, filter, deepScan); 4481 } else { 4482 //will not be called in dom level3 compliant browsers 4483 return this._recursionSearchAll(rootNode, filter, deepScan); 4484 } 4485 }, 4486 4487 /** 4488 * the faster dom iterator based search, works on all newer browsers 4489 * except ie8 which already have implemented the dom iterator functions 4490 * of html 5 (which is pretty all standard compliant browsers) 4491 * 4492 * The advantage of this method is a faster tree iteration compared 4493 * to the normal recursive tree walking. 4494 * 4495 * @param rootNode the root node to be iterated over 4496 * @param filter the iteration filter 4497 * @param deepScan if set to true a deep scan is performed 4498 */ 4499 _iteratorSearchAll: function(rootNode, filter, deepScan) { 4500 var retVal = []; 4501 //Works on firefox and webkit, opera and ie have to use the slower fallback mechanis 4502 //we have a tree walker in place this allows for an optimized deep scan 4503 if (filter(rootNode)) { 4504 4505 retVal.push(rootNode); 4506 if (!deepScan) { 4507 return retVal; 4508 } 4509 } 4510 //we use the reject mechanism to prevent a deep scan reject means any 4511 //child elements will be omitted from the scan 4512 var FILTER_ACCEPT = NodeFilter.FILTER_ACCEPT, 4513 FILTER_SKIP = NodeFilter.FILTER_SKIP, 4514 FILTER_REJECT = NodeFilter.FILTER_REJECT; 4515 4516 var walkerFilter = function (node) { 4517 var retCode = (filter(node)) ? FILTER_ACCEPT : FILTER_SKIP; 4518 retCode = (!deepScan && retCode == FILTER_ACCEPT) ? FILTER_REJECT : retCode; 4519 if (retCode == FILTER_ACCEPT || retCode == FILTER_REJECT) { 4520 retVal.push(node); 4521 } 4522 return retCode; 4523 }; 4524 4525 var treeWalker = document.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT, walkerFilter, false); 4526 //noinspection StatementWithEmptyBodyJS 4527 while (treeWalker.nextNode()); 4528 return retVal; 4529 }, 4530 4531 /** 4532 * bugfixing for ie6 which does not cope properly with setAttribute 4533 */ 4534 setAttribute : function(node, attr, val) { 4535 this._assertStdParams(node, attr, "setAttribute", ["fragment", "name"]); 4536 if (!node.setAttribute) { 4537 return; 4538 } 4539 4540 if (attr === 'disabled') { 4541 node.disabled = val === 'disabled' || val === 'true'; 4542 } else if (attr === 'checked') { 4543 node.checked = val === 'checked' || val === 'on' || val === 'true'; 4544 } else if (attr == 'readonly') { 4545 node.readOnly = val === 'readonly' || val === 'true'; 4546 } else { 4547 node.setAttribute(attr, val); 4548 } 4549 }, 4550 4551 /** 4552 * fuzzy form detection which tries to determine the form 4553 * an item has been detached. 4554 * 4555 * The problem is some Javascript libraries simply try to 4556 * detach controls by reusing the names 4557 * of the detached input controls. Most of the times, 4558 * the name is unique in a jsf scenario, due to the inherent form mapping. 4559 * One way or the other, we will try to fix that by 4560 * identifying the proper form over the name 4561 * 4562 * We do it in several ways, in case of no form null is returned 4563 * in case of multiple forms we check all elements with a given name (which we determine 4564 * out of a name or id of the detached element) and then iterate over them 4565 * to find whether they are in a form or not. 4566 * 4567 * If only one element within a form and a given identifier found then we can pull out 4568 * and move on 4569 * 4570 * We cannot do much further because in case of two identical named elements 4571 * all checks must fail and the first elements form is served. 4572 * 4573 * Note, this method is only triggered in case of the issuer or an ajax request 4574 * is a detached element, otherwise already existing code has served the correct form. 4575 * 4576 * This method was added because of 4577 * https://issues.apache.org/jira/browse/MYFACES-2599 4578 * to support the integration of existing ajax libraries which do heavy dom manipulation on the 4579 * controls side (Dojos Dijit library for instance). 4580 * 4581 * @param {Node} elem - element as source, can be detached, undefined or null 4582 * 4583 * @return either null or a form node if it could be determined 4584 * 4585 * TODO move this into extended and replace it with a simpler algorithm 4586 */ 4587 fuzzyFormDetection : function(elem) { 4588 var forms = document.forms, _Lang = this._Lang; 4589 4590 if (!forms || !forms.length) { 4591 return null; 4592 } 4593 4594 // This will not work well on portlet case, because we cannot be sure 4595 // the returned form is right one. 4596 //we can cover that case by simply adding one of our config params 4597 //the default is the weaker, but more correct portlet code 4598 //you can override it with myfaces_config.no_portlet_env = true globally 4599 else if (1 == forms.length && this._RT.getGlobalConfig("no_portlet_env", false)) { 4600 return forms[0]; 4601 } 4602 4603 //before going into the more complicated stuff we try the simple approach 4604 var finalElem = this.byId(elem); 4605 var fetchForm = _Lang.hitch(this, function(elem) { 4606 //element of type form then we are already 4607 //at form level for the issuing element 4608 //https://issues.apache.org/jira/browse/MYFACES-2793 4609 4610 return (_Lang.equalsIgnoreCase(elem.tagName, "form")) ? elem : 4611 ( this.html5FormDetection(elem) || this.getParent(elem, "form")); 4612 }); 4613 4614 if (finalElem) { 4615 var elemForm = fetchForm(finalElem); 4616 if (elemForm) return elemForm; 4617 } 4618 4619 /** 4620 * name check 4621 */ 4622 var foundElements = []; 4623 var name = (_Lang.isString(elem)) ? elem : elem.name; 4624 //id detection did not work 4625 if (!name) return null; 4626 /** 4627 * the lesser chance is the elements which have the same name 4628 * (which is the more likely case in case of a brute dom replacement) 4629 */ 4630 var nameElems = document.getElementsByName(name); 4631 if (nameElems) { 4632 for (var cnt = 0;
4632 cnt < nameElems.length && foundElements.length < 2; cnt++) { 4633 // we already have covered the identifier case hence we only can deal with names, 4634 var foundForm = fetchForm(nameElems[cnt]); 4635 if (foundForm) { 4636 foundElements.push(foundForm); 4637 } 4638 } 4639 } 4640 4641 return (1 == foundElements.length ) ? foundElements[0] : null; 4642 }, 4643 4644 html5FormDetection: function(/*item*/) { 4645 return null; 4646 }, 4647 4648 4649 /** 4650 * gets a parent of an item with a given tagname 4651 * @param {Node} item - child element 4652 * @param {String} tagName - TagName of parent element 4653 */ 4654 getParent : function(item, tagName) { 4655 4656 if (!item) { 4657 throw this._Lang.makeException(new Error(), null, null, this._nameSpace, "getParent", 4658 this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}")); 4659 } 4660 4661 var _Lang = this._Lang; 4662 var searchClosure = function(parentItem) { 4663 return parentItem && parentItem.tagName 4664 && _Lang.equalsIgnoreCase(parentItem.tagName, tagName); 4665 }; 4666 try { 4667 return this.getFilteredParent(item, searchClosure); 4668 } finally { 4669 searchClosure = null; 4670 _Lang = null; 4671 } 4672 }, 4673 4674 /** 4675 * A parent walker which uses 4676 * a filter closure for filtering 4677 * 4678 * @param {Node} item the root item to ascend from 4679 * @param {function} filter the filter closure 4680 */ 4681 getFilteredParent : function(item, filter) { 4682 this._assertStdParams(item, filter, "getFilteredParent", ["item", "filter"]); 4683 4684 //search parent tag parentName 4685 var parentItem = (item.parentNode) ? item.parentNode : null; 4686 4687 while (parentItem && !filter(parentItem)) { 4688 parentItem = parentItem.parentNode; 4689 } 4690 return (parentItem) ? parentItem : null; 4691 }, 4692 4693 /** 4694 * cross ported from dojo 4695 * fetches an attribute from a node 4696 * 4697 * @param {String} node the node 4698 * @param {String} attr the attribute 4699 * @return the attributes value or null 4700 */ 4701 getAttribute : function(/* HTMLElement */node, /* string */attr) { 4702 return node.getAttribute(attr); 4703 }, 4704 4705 /** 4706 * checks whether the given node has an attribute attached 4707 * 4708 * @param {String|Object} node the node to search for 4709 * @param {String} attr the attribute to search for 4710 * @true if the attribute was found 4711 */ 4712 hasAttribute : function(/* HTMLElement */node, /* string */attr) { 4713 // summary 4714 // Determines whether or not the specified node carries a value for the attribute in question. 4715 return this.getAttribute(node, attr) ? true : false; // boolean 4716 }, 4717 4718 /** 4719 * concatenation routine which concats all childnodes of a node which 4720 * contains a set of CDATA blocks to one big string 4721 * @param {Node} node the node to concat its blocks for 4722 */ 4723 concatCDATABlocks : function(/*Node*/ node) { 4724 var cDataBlock = []; 4725 // response may contain several blocks 4726 for (var i = 0; i < node.childNodes.length; i++) { 4727 cDataBlock.push(node.childNodes[i].data); 4728 } 4729 return cDataBlock.join(''); 4730 }, 4731 4732 //all modern browsers evaluate the scripts 4733 //manually this is a w3d recommendation 4734 isManualScriptEval: function() { 4735 return true; 4736 }, 4737 4738 /** 4739 * jsf2.2 4740 * checks if there is a fileupload element within 4741 * the executes list 4742 * 4743 * @param executes the executes list 4744 * @return {Boolean} true if there is a fileupload element 4745 */ 4746 isMultipartCandidate:function (executes) { 4747 if (this._Lang.isString(executes)) { 4748 executes = this._Lang.strToArray(executes, /\s+/); 4749 } 4750 4751 for (var cnt = 0, len = executes.length; cnt < len ; cnt ++) { 4752 var element = this.byId(executes[cnt]); 4753 var inputs = this.findByTagName(element, "input", true); 4754 for (var cnt2 = 0, len2 = inputs.length; cnt2 < len2 ; cnt2++) { 4755 if (this.getAttribute(inputs[cnt2], "type") == "file") return true; 4756 } 4757 } 4758 return false;
4759 }, 4760 4761 insertFirst: function(newNode) { 4762 var body = document.body; 4763 if (body.childNodes.length > 0) { 4764 body.insertBefore(newNode, body.firstChild); 4765 } else { 4766 body.appendChild(newNode); 4767 } 4768 }, 4769 4770 byId: function(id) { 4771 return this._Lang.byId(id); 4772 }, 4773 4774 getDummyPlaceHolder: function() { 4775 this._dummyPlaceHolder = this._dummyPlaceHolder ||this.createElement("div"); 4776 return this._dummyPlaceHolder; 4777 }, 4778 4779 getNamedElementFromForm: function(form, elementId) { 4780 return form[elementId]; 4781 } 4782}); 4783 4784 4785 4786/* Licensed to the Apache Software Foundation (ASF) under one or more 4787 * contributor license agreements. See the NOTICE file distributed with 4788 * this work for additional information regarding copyright ownership. 4789 * The ASF licenses this file to you under the Apache License, Version 2.0 4790 * (the "License"); you may not use this file except in compliance with 4791 * the License. You may obtain a copy of the License at 4792 * 4793 * http://www.apache.org/licenses/LICENSE-2.0 4794 * 4795 * Unless required by applicable law or agreed to in writing, software 4796 * distributed under the License is distributed on an "AS IS" BASIS, 4797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4798 * See the License for the specific language governing permissions and 4799 * limitations under the License. 4800 */ 4801if (_MF_SINGLTN) { 4802 _MF_SINGLTN(_PFX_UTIL + "_DomExperimental", myfaces._impl._util._Dom, /** @lends myfaces._impl._util._Dom.prototype */ { 4803 constructor_:function () { 4804 this._callSuper("constructor_"); 4805 myfaces._impl._util._Dom = this; 4806 }, 4807 4808 html5FormDetection:function (item) { 4809 var browser = this._RT.browser; 4810 //ie shortcut, not really needed but speeds things up 4811 if (browser.isIEMobile && browser.isIEMobile <= 8) { 4812 return null; 4813 } 4814 var elemForm = this.getAttribute(item, "form"); 4815 return (elemForm) ? this.byId(elemForm) : null; 4816 }, 4817 4818 getNamedElementFromForm: function(form, elementId) { 4819 return form[elementId]; 4820 } 4821 }); 4822} 4823 4824/* Licensed to the Apache Software Foundation (ASF) under one or more 4825 * contributor license agreements. See the NOTICE file distributed with 4826 * this work for additional information regarding copyright ownership. 4827 * The ASF licenses this file to you under the Apache License, Version 2.0 4828 * (the "License"); you may not use this file except in compliance with 4829 * the License. You may obtain a copy of the License at 4830 * 4831 * http://www.apache.org/licenses/LICENSE-2.0 4832 * 4833 * Unless required by applicable law or agreed to in writing, software 4834 * distributed under the License is distributed on an "AS IS" BASIS, 4835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4836 * See the License for the specific language governing permissions and 4837 * limitations under the License. 4838 */ 4839if (_MF_SINGLTN) { 4840 /*** 4841 Dom.js version for non html5 browsers 4842 */ 4843 _MF_SINGLTN(_PFX_UTIL + "DomQuirks", myfaces._impl._util._Dom, /** @lends myfaces._impl._util._DomQuirks.prototype */ { 4844 4845 IE_QUIRKS_EVENTS:{ 4846 "onabort":true, 4847 "onload":true, 4848 "onunload":true, 4849 "onchange":true, 4850 "onsubmit":true, 4851 "onreset":true, 4852 "onselect":true, 4853 "onblur":true, 4854 "onfocus":true, 4855 "onkeydown":true, 4856 "onkeypress":true, 4857 "onkeyup":true, 4858 "onclick":true, 4859 "ondblclick":true, 4860 "onmousedown":true, 4861 "onmousemove":true, 4862 "onmouseout":true, 4863 "onmouseover":true, 4864 "onmouseup":true 4865 }, 4866 4867 constructor_:function () { 4868 4869 var b = myfaces._impl.core._Runtime.browser; 4870 4871 if (b.isIEMobile && b.isIE <= 6) { 4872 //winmobile hates add onLoad, and checks on the construct 4873 //it does not eval scripts anyway 4874 myfaces.config = myfaces.config || {}; 4875 myfaces.config._autoeval = false;
4876 return; 4877 } else { 4878 //for whatever reason autoeval is set here on Firefox 3.5 only 4879 // could be a firebug problem, by setting setters 4880 //and getters no assignment was revealed. 4881 if ('undefined' != typeof myfaces.config && 'undefined' != typeof myfaces.config._autoeval) { 4882 delete myfaces.config._autoeval; 4883 } 4884 } 4885 this._callSuper("constructor_"); 4886 myfaces._impl._util._Dom = this; 4887 4888 var _Lang = this._Lang; 4889 //by w3c spec the script eval is turned off it is only 4890 //on on legacy browsers 4891 var scriptEval = _Lang.hitch(this, this.isManualScriptEval); 4892 4893 if (window) { 4894 this._RT.addOnLoad(window, scriptEval); 4895 } 4896 //safety fallback if the window onload handler is overwritten and not chained 4897 if (document.body) { 4898 this._RT.addOnLoad(document.body, scriptEval); 4899 } 4900 4901 //we register ourselves into the existing classes lazily 4902 var _T = this; 4903 if (myfaces._impl.core.Impl) { 4904 this._RT.iterateClasses(function (proto) { 4905 if (proto._Dom) proto._Dom = _T; 4906 }); 4907 } 4908 }, 4909 4910 /** 4911 * Checks whether the browser is dom compliant. 4912 * Dom compliant means that it performs the basic dom operations safely 4913 * without leaking and also is able to perform a native setAttribute 4914 * operation without freaking out 4915 * 4916 * 4917 * Not dom compliant browsers are all microsoft browsers in quirks mode 4918 * and ie6 and ie7 to some degree in standards mode 4919 * and pretty much every browser who cannot create ranges 4920 * (older mobile browsers etc...) 4921 * 4922 * We dont do a full browser detection here because it probably is safer 4923 * to test for existing features to make an assumption about the 4924 * browsers capabilities 4925 */ 4926 isDomCompliant:function () { 4927 if ('undefined' == typeof this._isCompliantBrowser) { 4928 this._isCompliantBrowser = !!((window.Range 4929 && typeof Range.prototype.createContextualFragment == 'function') 4930 //createContextualFragment hints to a no quirks browser but we need more fallbacks 4931 || document.querySelectoryAll //query selector all hints to html5 capabilities 4932 || document.createTreeWalker); //treewalker is either firefox 3.5+ or ie9 standards mode 4933 } 4934 return this._isCompliantBrowser; 4935 }, 4936 4937 /** 4938 * now to the evil browsers 4939 * of what we are dealing with is various bugs 4940 * first a simple replaceElement leaks memory 4941 * secondly embedded scripts can be swallowed upon 4942 * innerHTML, we probably could also use direct outerHTML 4943 * but then we would run into the script swallow bug 4944 * 4945 * the entire mess is called IE6 and IE7 4946 * 4947 * @param item 4948 * @param markup 4949 */ 4950 _outerHTMLNonCompliant:function (item, markup) { 4951 4952 var b = this._RT.browser; 4953 4954 try { 4955 //check for a subtable rendering case 4956 4957 var evalNodes = this._buildEvalNodes(item, markup); 4958 4959 if (evalNodes.length == 1) { 4960 var ret = evalNodes[0]; 4961 this.replaceElement(item, evalNodes[0]); 4962 return ret; 4963 } else { 4964 return this.replaceElements(item, evalNodes); 4965 } 4966 4967 } finally { 4968 4969 var dummyPlaceHolder = this.getDummyPlaceHolder(); 4970 //now that Microsoft has finally given 4971 //ie a working gc in 8 we can skip the costly operation 4972 if (b.isIE && b.isIE < 8) { 4973 this._removeChildNodes(dummyPlaceHolder, false); 4974 } 4975 dummyPlaceHolder.innerHTML = ""; 4976 } 4977 4978 }, 4979 4980 replaceElement:function (item, evalNode) { 4981 4982 var _Browser = this._RT.browser; 4983 if (!_Browser.isIE || _Browser.isIE >= 8) { 4984 //standards conform no leaking browser 4985 item.parentNode.replaceChild(evalNode, item); 4986 } else { 4987 this._callSuper("replaceElement", item, evalNode); 4988 } 4989 }, 4990 4991 /** 4992 * builds the ie nodes properly in a placeholder 4993 * and bypasses a non script insert bug that way 4994 * @param markup the marku code 4995 */ 4996 _buildNodesNonCompliant:function (markup) { 4997 4998 //now to the non w3c compliant browsers 4999 //http://blogs.perl.org/users/clinton_gormley/2010/02/forcing-ie-to-accept-script-tags-in-innerhtml.html 5000 //we have to cope with deficiencies between ie and its simulations in this case 5001 var probe = this.getDummyPlaceHolder();//document.createElement("div"); 5002 5003 probe.innerHTML = "<table><tbody><tr><td><div></div></td></tr></tbody></table>"; 5004 5005 //we have customers using html unit, this has a bug in the table resolution 5006 //hence we determine the depth dynamically 5007 var depth = this._determineDepth(probe); 5008 5009 this._removeChildNodes(probe, false); 5010 probe.innerHTML = ""; 5011 5012 var dummyPlaceHolder = this.getDummyPlaceHolder();//document.createElement("div"); 5013 5014 //fortunately a table element also works which is less critical than form elements regarding 5015 //the inner content 5016 dummyPlaceHolder.innerHTML = "<table><tbody><tr><td>" + markup + "</td></tr></tbody></table>"; 5017 var evalNodes = dummyPlaceHolder; 5018 5019 for (var cnt = 0; cnt < depth; cnt++) { 5020 evalNodes = evalNodes.childNodes[0]; 5021 } 5022 var ret = (evalNodes.parentNode) ? this.detach(evalNodes.parentNode.childNodes) : null; 5023 5024 if ('undefined' == typeof evalNodes || null == evalNodes) { 5025 //fallback for htmlunit which should be good enough 5026 //to run the tests, maybe we have to wrap it as well 5027 dummyPlaceHolder.innerHTML = "<div>" + markup + "</div>"; 5028 //note this is triggered only in htmlunit no other browser 5029 //so we are save here 5030 //TODO Fix this (probaby ret is needed here, check the history) 5031 evalNodes = this.detach(dummyPlaceHolder.childNodes[0].childNodes); 5032 } 5033 5034 this._removeChildNodes(dummyPlaceHolder, false); 5035 //ie fix any version, ie does not return true javascript arrays so we have to perform 5036 //a cross conversion 5037 return ret; 5038 5039 }, 5040 5041 _determineDepth:function (probe) { 5042 var depth = 0; 5043 var newProbe = probe; 5044 for (; newProbe && 5045 newProbe.childNodes && 5046 newProbe.childNodes.length && 5047 newProbe.nodeType == 1; depth++) { 5048 newProbe = newProbe.childNodes[0]; 5049 } 5050 return depth; 5051 }, 5052 5053 //now to another nasty issue: 5054 //for ie we have to walk recursively over all nodes:
5055 //http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx 5056 //http://weblogs.java.net/blog/driscoll/archive/2009/11/13/ie-memory-management-and-you 5057 //http://home.orange.nl/jsrosman/ 5058 //http://www.quirksmode.org/blog/archives/2005/10/memory_leaks_li.html 5059 //http://www.josh-davis.org/node/7 5060 _removeNode:function (node, breakEventsOpen) { 5061 if (!node) return; 5062 var b = this._RT.browser; 5063 if (this.isDomCompliant()) { 5064 //recursive descension only needed for old ie versions 5065 //all newer browsers cleanup the garbage just fine without it 5066 //thank you 5067 if ('undefined' != typeof node.parentNode && null != node.parentNode) //if the node has a parent 5068 node.parentNode.removeChild(node); 5069 return; 5070 } 5071 5072 //now to the browsers with non working garbage collection 5073 this._removeChildNodes(node, breakEventsOpen); 5074 5075 try { 5076 //outer HTML setting is only possible in earlier IE versions all modern browsers throw an exception here 5077 //again to speed things up we precheck first 5078 if (!this._isTableElement(node)) { 5079 //we do not do a table structure innnerhtml on table elements except td 5080 //htmlunit rightfully complains that we should not do it 5081 node.innerHTML = ""; 5082 } 5083 if (b.isIE && 'undefined' != typeof node.outerHTML) {//ie8+ check done earlier we skip it here 5084 node.outerHTML = ''; 5085 } else { 5086 node = this.detach(node)[0]; 5087 } 5088 if (!b.isIEMobile) { 5089 delete node; 5090 } 5091 } catch (e) { 5092 //on some elements we might not have covered by our table check on the outerHTML 5093 // can fail we skip those in favor of stability 5094 try { 5095 // both innerHTML and outerHTML fails when <tr> is the node, but in that case 5096 // we need to force node removal, otherwise it will be on the tree (IE 7 IE 6) 5097 this.detach(node); 5098 if (!b.isIEMobile) { 5099 delete node; 5100 } 5101 } catch (e1) { 5102 } 5103 } 5104 }, 5105 5106 /** 5107 * recursive delete child nodes 5108 * node, this method only makes sense in the context of IE6 + 7 hence 5109 * it is not exposed to the public API, modern browsers 5110 * can garbage collect the nodes just fine by doing the standard removeNode method 5111 * from the dom API! 5112 * 5113 * @param node the node from which the childnodes have to be deletd 5114 * @param breakEventsOpen if set to true a standard events breaking is performed 5115 */ 5116 _removeChildNodes:function (node, breakEventsOpen) { 5117 if (!node) return; 5118 5119 //node types which cannot be cleared up by normal means 5120 var disallowedNodes = this.TABLE_ELEMS; 5121 5122 //for now we do not enable it due to speed reasons 5123 //normally the framework has to do some event detection 5124 //which we cannot do yet, I will dig for options 5125 //to enable it in a speedly manner 5126 //ie7 fixes this area anyway 5127 //this.breakEvents(node); 5128 5129 var b = this._RT.browser; 5130 if (breakEventsOpen) { 5131 this.breakEvents(node); 5132 } 5133 5134 for (var cnt = node.childNodes.length - 1; cnt >= 0; cnt -= 1) { 5135 var childNode = node.childNodes[cnt]; 5136 //we cannot use our generic recursive tree walking due to the needed head recursion 5137 //to clean it up bottom up, the tail recursion we were using in the search either would use more time 5138 //because we had to walk and then clean bottom up, so we are going for a direct head recusion here 5139 if ('undefined' != typeof childNode.childNodes && node.childNodes.length) 5140 this._removeChildNodes(childNode); 5141 try { 5142 var nodeName = (childNode.nodeName || childNode.tagName) ? (childNode.nodeName || childNode.tagName).toLowerCase() : null; 5143 //ie chokes on clearing out table inner elements, this is also covered by our empty 5144 //catch block, but to speed things up it makes more sense to precheck that 5145 if (!disallowedNodes[nodeName]) { 5146 //outer HTML setting is only possible in earlier IE versions all modern browsers throw an exception here 5147 //again to speed things up we precheck first 5148 if (!this._isTableElement(childNode)) { //table elements cannot be deleted 5149 childNode.innerHTML = ""; 5150 } 5151 if (b.isIE && b.isIE < 8 && 'undefined' != typeof childNode.outerHTML) { 5152 childNode.outerHTML = ''; 5153 } else { 5154 node.removeChild(childNode); 5155 } 5156 if (!b.isIEMobile) { 5157 delete childNode; 5158 } 5159 } 5160 } catch (e) { 5161 //on some elements the outerHTML can fail we skip those in favor 5162 //of stability 5163 5164 } 5165 } 5166 }, 5167 /** 5168 * cross ported from dojo 5169 * fetches an attribute from a node 5170 * 5171 * @param {String}
5171 node the node 5172 * @param {String} attr the attribute 5173 * @return the attributes value or null 5174 */ 5175 getAttribute:function (/* HTMLElement */node, /* string */attr) { 5176 // summary 5177 // Returns the value of attribute attr from node. 5178 node = this.byId(node); 5179 // FIXME: need to add support for attr-specific accessors 5180 if ((!node) || (!node.getAttribute)) { 5181 // if(attr !== 'nwType'){ 5182 // alert("getAttr of '" + attr + "' with bad node"); 5183 // } 5184 return null; 5185 } 5186 var ta = typeof attr == 'string' ? attr : new String(attr); 5187 5188 // first try the approach most likely to succeed 5189 var v = node.getAttribute(ta.toUpperCase()); 5190 if ((v) && (typeof v == 'string') && (v != "")) { 5191 return v; // string 5192 } 5193 5194 // try returning the attributes value, if we couldn't get it as a string 5195 if (v && v.value) { 5196 return v.value; // string 5197 } 5198 5199 // this should work on Opera 7, but it's a little on the crashy side 5200 if ((node.getAttributeNode) && (node.getAttributeNode(ta))) { 5201 return (node.getAttributeNode(ta)).value; // string 5202 } else if (node.getAttribute(ta)) { 5203 return node.getAttribute(ta); // string 5204 } else if (node.getAttribute(ta.toLowerCase())) { 5205 return node.getAttribute(ta.toLowerCase()); // string 5206 } 5207 return null; // string 5208 }, 5209 5210 /** 5211 * bugfixing for ie6 which does not cope properly with setAttribute 5212 */ 5213 setAttribute:function (node, attr, val) { 5214 5215 this._assertStdParams(node, attr, "setAttribute"); 5216 5217 //quirks mode and ie7 mode has the attributes problems ie8 standards mode behaves like 5218 //a good citizen 5219 var _Browser = this._RT.browser; 5220 //in case of ie > ie7 we have to check for a quirks mode setting 5221 if (!_Browser.isIE || _Browser.isIE > 7 && this.isDomCompliant()) { 5222 this._callSuper("setAttribute", node, attr, val); 5223 return; 5224 } 5225 5226 /* 5227 Now to the broken browsers IE6+.... ie7 and ie8 quirks mode 5228 5229 we deal mainly with three problems here 5230 class and for are not handled correctly 5231 styles are arrays and cannot be set directly 5232 and javascript events cannot be set via setAttribute as well! 5233 5234 or in original words of quirksmode.org ... this is a mess! 5235 5236 Btw. thank you Microsoft for providing all necessary tools for free 5237 for being able to debug this entire mess in the ie rendering engine out 5238 (which is the Microsoft ie vms, developers toolbar, Visual Web Developer 2008 express 5239 and the ie8 8 developers toolset!) 5240 5241 also thank you http://www.quirksmode.org/ 5242 dojotoolkit.org and //http://delete.me.uk/2004/09/ieproto.html 5243 for additional information on this mess! 5244 5245 The lowest common denominator tested within this code 5246 is IE6, older browsers for now are legacy! 5247 */ 5248 attr = attr.toLowerCase(); 5249 5250 if (attr === "class") { 5251 //setAttribute does not work for winmobile browsers 5252 //firect calls work 5253 node.className = val; 5254 } else if (attr === "name") { 5255 //the ie debugger fails to assign the name via setAttr 5256 //in quirks mode 5257 node[attr] = val; 5258 } else if (attr === "for") { 5259 if (!_Browser.isIEMobile || _Browser.isIEMobile >= 7) { 5260 node.setAttribute("htmlFor", val); 5261 } else { 5262 node.htmlFor = val; 5263 } 5264 } else if (attr === "style") { 5265 node.style.cssText = val; 5266 } else { 5267 //check if the attribute is an event, since this applies only 5268 //to quirks mode of ie anyway we can live with the standard html4/xhtml 5269 //ie supported events 5270 if (this.IE_QUIRKS_EVENTS[attr]) { 5271 if (this._Lang.isString(attr)) { 5272 var c = document.body.appendChild(document.createElement('span')); 5273 try { 5274 c.innerHTML = '<span ' + attr + '="' + val + '"/>'; 5275 node[attr] = c.firstChild[attr]; 5276 } finally { 5277 document.body.removeChild(c); 5278 } 5279 } 5280 } else { 5281 //unknown cases we try to catch them via standard setAttributes 5282 if (!_Browser.isIEMobile || _Browser.isIEMobile >= 7) { 5283 node.setAttribute(attr, val); 5284 } else { 5285 node[attr] = val; 5286 } 5287 } 5288 } 5289 }, 5290 5291 getDummyPlaceHolder:function () { 5292 this._callSuper("getDummyPlaceHolder"); 5293 5294 //ieMobile in its 6.1-- incarnation cannot handle innerHTML detached objects so we have 5295 //to attach the dummy placeholder, we try to avoid it for 5296 //better browsers so that we do not have unecessary dom operations 5297 if (this._RT.browser.isIEMobile && created) { 5298 this.insertFirst(this._dummyPlaceHolder); 5299 5300 this.setAttribute(this._dummyPlaceHolder, "style", "display: none"); 5301 5302 } 5303 5304 return this._dummyPlaceHolder; 5305 }, 5306 5307 /** 5308 * classical recursive way which definitely will work on all browsers 5309 * including the IE6 5310 * 5311 * @param rootNode the root node 5312 * @param filter the filter to be applied to 5313 * @param deepScan if set to true a deep scan is performed 5314 */ 5315 _recursionSearchAll:function (rootNode, filter, deepScan) { 5316 var ret = []; 5317 //fix the value to prevent undefined errors 5318 5319 if (filter(rootNode)) {
5320 ret.push(rootNode); 5321 if (!deepScan) return ret; 5322 } 5323 5324 // 5325 if (!rootNode.childNodes) { 5326 return ret; 5327 } 5328 5329 //subfragment usecases 5330 5331 var retLen = ret.length; 5332 var childLen = rootNode.childNodes.length; 5333 for (var cnt = 0; (deepScan || retLen == 0) && cnt < childLen; cnt++) { 5334 ret = ret.concat(this._recursionSearchAll(rootNode.childNodes[cnt], filter, deepScan)); 5335 } 5336 return ret; 5337 }, 5338 5339 /** 5340 * break the standard events from an existing dom node 5341 * (note this method is not yet used, but can be used 5342 * by framework authors to get rid of ie circular event references) 5343 * 5344 * another way probably would be to check all attributes of a node 5345 * for a function and if one is present break it by nulling it 5346 * I have to do some further investigation on this. 5347 * 5348 * The final fix is to move away from ie6 at all which is the root cause of 5349 * this. 5350 * 5351 * @param node the node which has to be broken off its events 5352 */ 5353 breakEvents:function (node) { 5354 if (!node) return; 5355 var evtArr = this.IE_QUIRKS_EVENTS; 5356 for (var key in evtArr) { 5357 if (!evtArr.hasOwnProperty(key)) continue; 5358 if (key != "onunload" && node[key]) { 5359 node[key] = null; 5360 } 5361 } 5362 }, 5363 5364 isManualScriptEval:function () { 5365 5366 if (!this._Lang.exists(myfaces, "config._autoeval")) { 5367 5368 //now we rely on the document being processed if called for the first time 5369 var evalDiv = document.createElement("div"); 5370 this._Lang.reserveNamespace("myfaces.config._autoeval"); 5371 //null not swallowed 5372 myfaces.config._autoeval = false; 5373 5374 var markup = "<script type='text/javascript'> myfaces.config._autoeval = true; </script>"; 5375 //now we rely on the same replacement mechanisms as outerhtml because 5376 //some browsers have different behavior of embedded scripts in the contextualfragment 5377 //or innerhtml case (opera for instance), this way we make sure the 5378 //eval detection is covered correctly 5379 this.setAttribute(evalDiv, "style", "display:none"); 5380 5381 //it is less critical in some browsers (old ie versions) 5382 //to append as first element than as last 5383 //it should not make any difference layoutwise since we are on display none anyway. 5384 this.insertFirst(evalDiv); 5385 5386 //we remap it into a real boolean value 5387 if (this.isDomCompliant()) { 5388 this._outerHTMLCompliant(evalDiv, markup); 5389 } else { 5390 //will not be called placeholder for quirks class 5391 this._outerHTMLNonCompliant(evalDiv, markup); 5392 } 5393 5394 5395 } 5396 5397 return !myfaces.config._autoeval; 5398 }, 5399 5400 getNamedElementFromForm:function (form, elementName) { 5401 var browser = this._RT.browser; 5402 if(browser.isIE && browser.isIE < 8) { 5403 if(!form.elements) return null; 5404 for(var cnt = 0, l = form.elements.length; cnt < l; cnt ++) { 5405 var element = form.elements[cnt]; 5406 if(element.name == elementName) { 5407 return element; 5408 } 5409 } 5410 return null; 5411 } else { 5412 return form[elementName]; 5413 } 5414 } 5415 5416 }); 5417 5418} 5419 5420/* Licensed to the Apache Software Foundation (ASF) under one or more 5421 * contributor license agreements. See the NOTICE file distributed with 5422 * this work for additional information regarding copyright ownership. 5423 * The ASF licenses this file to you under the Apache License, Version 2.0 5424 * (the "License"); you may not use this file except in compliance with 5425 * the License. You may obtain a copy of the License at 5426 * 5427 * http://www.apache.org/licenses/LICENSE-2.0 5428 * 5429 * Unless required by applicable law or agreed to in writing, softw
5429are 5430 * distributed under the License is distributed on an "AS IS" BASIS, 5431 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5432 * See the License for the specific language governing permissions and 5433 * limitations under the License. 5434 */ 5435 5436/** 5437 * @class 5438 * @name _HtmlStripper 5439 * @memberOf myfaces._impl._util 5440 * @extends myfaces._impl.core._Runtime 5441 * @description 5442 * Fallback routine if the browser embedded xml parser fails on the document 5443 * This fallback is not failsafe but should give enough cover to handle all cases 5444 */ 5445 5446/** @namespace myfaces._impl._util._HtmlStripper */ 5447_MF_CLS(_PFX_UTIL + "_HtmlStripper", _MF_OBJECT, /** @lends myfaces._impl._util._HtmlStripper.prototype */ { 5448 5449 /** 5450 * main parse routine parses the document for a given tag name 5451 * 5452 * 5453 * @param theString the markup string to be parsed 5454 * @param tagNameStart the tag name to be parsed for 5455 */ 5456 parse : function(theString, tagNameStart) { 5457 5458 var BEGIN_TAG = "html", 5459 _tagStart = -1, 5460 _tagEnd = -1, 5461 _contentStart = -1, 5462 _contentEnd = -1, 5463 _tokenPos = 0, 5464 _tokenForward = 1, 5465 tagNameStart = (!tagNameStart) ? BEGIN_TAG : tagNameStart; 5466 5467 var proposedTagStartPos = theString.indexOf("<" + tagNameStart); 5468 var _T = this; 5469 5470 //we use closures instead of private methods to improve the compressability 5471 5472 var isValidPositionCombination = function(pos1, pos2, pos3, pos4) { 5473 return pos1 <= pos2 && pos3 <= pos4; 5474 }; 5475 5476 /** 5477 * trace for a forward comment 5478 * 5479 * @param theStr the string to be checked 5480 * @param tagPos the tag position from which the check onwards has to be perfomed 5481 * @return true in case a comment is found 5482 */ 5483 var checkForwardForComment = function(theStr, tagPos) { 5484 var toCheck = theStr.substring(tagPos), 5485 indexOf = _T._Lang.hitch(toCheck, toCheck.indexOf), 5486 firstBeginComment = indexOf("<!--"), 5487 firstEndComment = indexOf("-->"), 5488 5489 firstBeginCDATA = indexOf("<[CDATA["), 5490 firstEndCDATA = indexOf("]]>"); 5491 5492 if (isValidPositionCombination(firstBeginComment, firstEndComment, firstBeginCDATA, firstEndCDATA)) { 5493 return true; 5494 } 5495 5496 return firstBeginComment <= firstEndComment && firstBeginCDATA <= firstEndCDATA; 5497 }; 5498 5499 /** 5500 * check backwards for a comment 5501 * 5502 * @param theStr the check string 5503 * @param tagPos the tag position from which the check should be performed 5504 * @return true in case a comment is found 5505 */ 5506 var checkBackForComment = function(theStr, tagPos) { 5507 var toCheck = theStr.substring(tagPos), 5508 indexOf = _T._Lang.hitch(toCheck, toCheck.indexOf), 5509 lastBeginComment = indexOf("<!--"), 5510 lastEndComment = indexOf("-->"), 5511 lastBeginCDATA = indexOf("<[CDATA["), 5512 lastEndCDATA = indexOf("]]>"); 5513 5514 if (isValidPositionCombination(lastBeginComment, lastEndComment, lastBeginCDATA, lastEndCDATA)) { 5515 //TODO we have to handle the embedded cases, for now we leave them out 5516 return true; 5517 } 5518 }; 5519 5520 //no need for ll parsing a handful of indexofs instead of slower regepx suffices 5521 var theSubStr = this._Lang.hitch(theString, theString.substring); 5522 while (_contentStart == -1 && proposedTagStartPos != -1) { 5523 if (checkBackForComment(theString, proposedTagStartPos)) { 5524 _tagStart = proposedTagStartPos; 5525 _contentStart = proposedTagStartPos + theSubStr(proposedTagStartPos).indexOf(">") + 1; 5526 } 5527 proposedTagStartPos = theSubStr(proposedTagStartPos + tagNameStart.length + 2).indexOf("<" + tagNameStart); 5528 } 5529 5530 var proposedEndTagPos = theString.lastIndexOf("</" + tagNameStart); 5531 while (_contentEnd == -1 && proposedEndTagPos > 0) { 5532 if (checkForwardForComment(theString, proposedEndTagPos)) { 5533 _tagEnd = proposedEndTagPos; 5534 _contentEnd = proposedEndTagPos; 5535 } 5536 proposedTagStartPos = theSubStr(proposedTagStartPos - tagNameStart.length - 2).lastIndexOf("</" + tagNameStart); 5537 } 5538 if (_contentStart != -1 && _contentEnd != -1) { 5539 return theSubStr(_contentStart, _contentEnd); 5540 } 5541 return null; 5542 } 5543}); 5544 5545 5546 5547 5548/* Licensed to the Apache Software Foundation (ASF) under one or more 5549 * contributor license agreements. See the NOTICE file distributed with 5550 * this work for additional information regarding copyright ownership. 5551 * The ASF licenses this file to you under the Apache License, Version 2.0 5552 * (the "License");
5552 you may not use this file except in compliance with 5553 * the License. You may obtain a copy of the License at 5554 * 5555 * http://www.apache.org/licenses/LICENSE-2.0 5556 * 5557 * Unless required by applicable law or agreed to in writing, software 5558 * distributed under the License is distributed on an "AS IS" BASIS, 5559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5560 * See the License for the specific language governing permissions and 5561 * limitations under the License. 5562 */ 5563 5564 5565/** 5566 * legacy code to enable various aspects 5567 * of myfaces, used to be rendered inline 5568 * for jsf 2.0 we can externalized it into its own custom resource 5569 */ 5570 5571(!window.myfaces) ? window.myfaces = {} : null; 5572if (!myfaces.oam) { 5573 myfaces.oam = new function() { 5574 5575 /** 5576 * sets a hidden input field 5577 * @param formname the formName 5578 * @param name the hidden field 5579 * @param value the value to be rendered 5580 */ 5581 this.setHiddenInput = function(formname, name, value) { 5582 var form = document.forms[formname]; 5583 if (typeof form == 'undefined') { 5584 form = document.getElementById(formname); 5585 } 5586 5587 if (typeof form.elements[name] != 'undefined' && (form.elements[name].nodeName == 'INPUT' || form.elements[name].nodeName == 'input')) { 5588 form.elements[name].value = value; 5589 } 5590 else { 5591 var newInput = document.createElement('input'); 5592 newInput.setAttribute('type', 'hidden'); 5593 newInput.setAttribute('id', name); 5594 newInput.setAttribute('name', name); 5595 newInput.setAttribute('value', value); 5596 form.appendChild(newInput); 5597 } 5598 }; 5599 5600 /** 5601 * clears a hidden input field 5602 * 5603 * @param formname formName for the input 5604 * @param name the name of the input field 5605 * @param value the value to be cleared 5606 */ 5607 this.clearHiddenInput = function(formname, name, value) { 5608 var form = document.forms[formname]; 5609 5610 if (typeof form == 'undefined') { 5611 form = document.getElementById(formname); 5612 } 5613 5614 var hInput = form.elements[name]; 5615 if (typeof hInput != 'undefined') { 5616 form.removeChild(hInput); 5617 } 5618 }; 5619 5620 /** 5621 * does special form submit remapping 5622 * remaps the issuing command link into something 5623 * the decode of the command link on the server can understand 5624 * 5625 * @param formName 5626 * @param linkId 5627 * @param target 5628 * @param params 5629 */ 5630 this.submitForm = function(formName, linkId, target, params) { 5631 5632 var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_'); 5633 if (typeof window[clearFn] == 'function') { 5634 window[clearFn](formName); 5635 } 5636 5637 var form = document.forms[formName]; 5638 if (typeof form == 'undefined') { 5639 form = document.getElementById(formName); 5640 } 5641 5642 //autoscroll code 5643 if (myfaces.core.config.autoScroll && typeof window.getScrolling != 'undefined') { 5644 myfaces.oam.setHiddenInput(formName, 'autoScroll', getScrolling()); 5645 } 5646 5647 if (myfaces.core.config.ieAutoSave) { 5648 var agentString = navigator.userAgent.toLowerCase(); 5649 var version = navigator.appVersion; 5650 if (agentString.indexOf('msie') != -1) { 5651 if (!(agentString.indexOf('ppc') != -1 && agentString.indexOf('windows ce') != -1 && version >= 4.0)) { 5652 window.external.AutoCompleteSaveForm(form); 5653 } 5654 } 5655 } 5656 5657 var oldTarget = form.target; 5658 if (target != null) { 5659 form.target = target; 5660 } 5661 if ((typeof params != 'undefined') && params != null) { 5662 for (var i = 0, param; (param = params[i]); i++) { 5663 myfaces.oam.setHiddenInput(formName, param[0], param[1]); 5664 } 5665 5666 } 5667 5668 myfaces.oam.setHiddenInput(formName, formName + ':' + '_idcl', linkId); 5669 5670 if (form.onsubmit) { 5671 var result = form.onsubmit(); 5672 if ((typeof result == 'undefined') || result) { 5673 try { 5674 form.submit(); 5675 } 5676 catch(e) { 5677 } 5678 } 5679 5680 } 5681 else { 5682 try { 5683 form.submit(); 5684 } 5685 catch(e) { 5686 } 5687 } 5688 5689 form.target = oldTarget; 5690 if ((typeof params != 'undefined') && params != null) { 5691 5692 for (var i = 0, param; (param = params[i]); i++) { 5693 myfaces.oam.clearHiddenInput(formName, param[0], param[1]); 5694 } 5695 5696 } 5697 5698 myfaces.oam.clearHiddenInput(formName, formName + ':' + '_idcl', linkId); 5699 return false;
5700 }; 5701 } 5702} 5703 5704//reserve a cofig namespace for impl related stuff 5705(!myfaces.core) ? myfaces.core = {} : null; 5706(!myfaces.core.config) ? myfaces.core.config = {} : null; 5707 5708 5709/* Licensed to the Apache Software Foundation (ASF) under one or more 5710 * contributor license agreements. See the NOTICE file distributed with 5711 * this work for additional information regarding copyright ownership. 5712 * The ASF licenses this file to you under the Apache License, Version 2.0 5713 * (the "License"); you may not use this file except in compliance with 5714 * the License. You may obtain a copy of the License at 5715 * 5716 * http://www.apache.org/licenses/LICENSE-2.0 5717 * 5718 * Unless required by applicable law or agreed to in writing, software 5719 * distributed under the License is distributed on an "AS IS" BASIS, 5720 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5721 * See the License for the specific language governing permissions and 5722 * limitations under the License. 5723 */ 5724/** 5725 * @class 5726 * @name _AjaxUtils 5727 * @memberOf myfaces._impl.xhrCore 5728 * @description 5729 * 5730 * A set of helper routines which are utilized within our Ajax subsystem and nowhere else 5731 * 5732 * TODO move this into a singleton, the current structure is 5733 * still a j4fry legacy we need to get rid of it in the long run 5734 */ 5735_MF_SINGLTN(_PFX_XHR+"_AjaxUtils", _MF_OBJECT, 5736/** @lends myfaces._impl.xhrCore._AjaxUtils.prototype */ 5737{ 5738 5739 5740 /** 5741 * determines fields to submit 5742 * @param {Object} targetBuf - the target form buffer receiving the data 5743 * @param {Node} parentItem - form element item is nested in 5744 * @param {Array} partialIds - ids fo PPS 5745 */ 5746 encodeSubmittableFields : function(targetBuf, 5747 parentItem, partialIds) { 5748 if (!parentItem) throw "NO_PARITEM"; 5749 if (partialIds ) { 5750 this.encodePartialSubmit(parentItem, false, partialIds, targetBuf); 5751 } else { 5752 // add all nodes 5753 var eLen = parentItem.elements.length; 5754 for (var e = 0; e < eLen; e++) { 5755 this.encodeElement(parentItem.elements[e], targetBuf); 5756 } // end of for (formElements) 5757 } 5758 5759 }, 5760 5761 /** 5762 * appends the issuing item if not given already 5763 * @param item 5764 * @param targetBuf 5765 */ 5766 appendIssuingItem: function (item, targetBuf) { 5767 // if triggered by a Button send it along 5768 var identifier = item.id || item.name; 5769 var type = ((item && item.type) || "").toLowerCase(); 5770 5771 if((targetBuf.hasKey && targetBuf.hasKey(identifier)) || 5772 //change of api since this code was written, the official FormData nowadays 5773 //uses has instead of hasKey, back then it was not finalized 5774 //we now program a fallback in, to cover FormData for this case 5775 (targetBuf.has && targetBuf.has(identifier))) { //already processed within the values 5776 return; 5777 } 5778 5779 //MYFACES-4606 we cannot send a value on an unchecked box as issuing element 5780 var isCheckboxRadio = "checkbox" == type || "radio" == type; 5781 if(isCheckboxRadio && !item.checked) { 5782 return; 5783 } else if (isCheckboxRadio) { 5784 var value = ("undefined" == typeof item.value || null == item.value) ? true : item.value; 5785 targetBuf.append(identifier, value); 5786 //item must have a valid value to be able to be appended, without it no dice! 5787 } else if(!(("undefined" == typeof item.value) || (null == item.value))) { 5788 var itemValue = item.value; 5789 targetBuf.append(identifier, itemValue); 5790 } 5791 }, 5792 5793 5794 /** 5795 * encodes a single input element for submission 5796 * 5797 * @param {Node} element - to be encoded 5798 * @param {} targetBuf - a target array buffer receiving the encoded strings 5799 */ 5800 encodeElement : function(element, targetBuf) { 5801 5802 //browser behavior no element name no encoding (normal submit fails in that case) 5803 //https://issues.apache.org/jira/browse/MYFACES-2847 5804 if (!element.name) { 5805 return; 5806 } 5807 5808 var _RT = this._RT; 5809 var name = element.name; 5810 var tagName = element.tagName.toLowerCase(); 5811 var elemType = element.type; 5812 if (elemType != null) { 5813 elemType = elemType.toLowerCase(); 5814 } 5815 5816 // routine for all elements 5817 // rules:
5818 // - process only inputs, textareas and selects 5819 // - elements muest have attribute "name" 5820 // - elements must not be disabled 5821 if (((tagName == "input" || tagName == "textarea" || tagName == "select") && 5822 (name != null && name != "")) && !element.disabled) { 5823 5824 // routine for select elements 5825 // rules: 5826 // - if select-one and value-Attribute exist => "name=value" 5827 // (also if value empty => "name=") 5828 // - if select-one and value-Attribute don't exist => 5829 // "name=DisplayValue" 5830 // - if select multi and multple selected => "name=value1&name=value2" 5831 // - if select and selectedIndex=-1 don't submit 5832 if (tagName == "select") { 5833 // selectedIndex must be >= 0 sein to be submittet 5834 if (element.selectedIndex >= 0) { 5835 var uLen = element.options.length; 5836 for (var u = 0; u < uLen; u++) { 5837 // find all selected options 5838 //var subBuf = []; 5839 if (element.options[u].selected) { 5840 var elementOption = element.options[u]; 5841 targetBuf.append(name, (elementOption.getAttribute("value") != null) ? 5842 elementOption.value : elementOption.text); 5843 } 5844 } 5845 } 5846 } 5847 5848 // routine for remaining elements 5849 // rules: 5850 // - don't submit no selects (processed above), buttons, reset buttons, submit buttons, 5851 // - submit checkboxes and radio inputs only if checked 5852 if ((tagName != "select" && elemType != "button" 5853 && elemType != "reset" && elemType != "submit" && elemType != "image") 5854 && ((elemType != "checkbox" && elemType != "radio") || element.checked)) { 5855 if ('undefined' != typeof element.files && element.files != null && _RT.getXHRLvl() >= 2 && element.files.length) { 5856 //xhr level2 5857 targetBuf.append(name, element.files[0]); 5858 } else { 5859 targetBuf.append(name, element.value); 5860 } 5861 } 5862 5863 } 5864 } 5865}); 5866 5867/* Licensed to the Apache Software Foundation (ASF) under one or more 5868 * contributor license agreements. See the NOTICE file distributed with 5869 * this work for additional information regarding copyright ownership. 5870 * The ASF licenses this file to you under the Apache License, Version 2.0 5871 * (the "License"); you may not use this file except in compliance with 5872 * the License. You may obtain a copy of the License at 5873 * 5874 * http://www.apache.org/licenses/LICENSE-2.0 5875 * 5876 * Unless required by applicable law or agreed to in writing, software 5877 * distributed under the License is distributed on an "AS IS" BASIS, 5878 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5879 * See the License for the specific language governing permissions and 5880 * limitations under the License. 5881 */ 5882/** @namespace myfaces._impl.xhrCore._AjaxRequestQueue */ 5883_MF_CLS(_PFX_XHR + "_AjaxRequestQueue", myfaces._impl._util._Queue, /** @lends myfaces._impl.xhrCore._AjaxRequestQueue.prototype */ { 5884 5885 /** 5886 * a pointer towards the currently processed 5887 * request in our queue 5888 */ 5889 _curReq : null, 5890 5891 /** 5892 * delay request, then call enqueue 5893 * @param {Object} request (myfaces._impl.xhrCore._AjaxRequest) request to send 5894 */ 5895 enqueue : function(request) { 5896 5897 if (this._curReq == null) { 5898 this._curReq = request; 5899 this._curReq.send(); 5900 } else { 5901 this._callSuper("enqueue", request); 5902 if (request._queueSize != this._size) { 5903 this.setQueueSize(request._queueSize); 5904 } 5905 } 5906 5907 }, 5908 5909 /** 5910 * process queue, send request, if exists 5911 */ 5912 processQueue: function() { 5913 this._curReq = this.dequeue(); 5914 if (this._curReq) { 5915 this._curReq.send(); 5916 } 5917 }, 5918 5919 /** 5920 * cleanup queue 5921 */ 5922 cleanup: function() { 5923 this._curReq = null; 5924 this._callSuper("cleanup"); 5925 } 5926}); 5927 5928 5929/* Licensed to the Apache Software Foundation (ASF) under one or more 5930 * contributor license agreements. See the NOTICE file distributed with 5931 * this work for additional information regarding copyright ownership. 5932 * The ASF licenses this file to you under the Apache License, Version 2.0 5933 * (the "License");
5933 you may not use this file except in compliance with 5934 * the License. You may obtain a copy of the License at 5935 * 5936 * http://www.apache.org/licenses/LICENSE-2.0 5937 * 5938 * Unless required by applicable law or agreed to in writing, software 5939 * distributed under the License is distributed on an "AS IS" BASIS, 5940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5941 * See the License for the specific language governing permissions and 5942 * limitations under the License. 5943 */ 5944/** 5945 * @memberOf myfaces._impl.xhrCore 5946 * @namespace 5947 * @name engine 5948 */ 5949 5950/** 5951 * @class 5952 * @name XhrConst 5953 * @memberOf myfaces._impl.xhrCore.engine 5954 */ 5955_MF_SINGLTN(_PFX_XHR+"engine.XhrConst", Object, 5956 /** @lends myfaces._impl.xhrCore.engine.XhrConst.prototype */ 5957 { 5958 READY_STATE_UNSENT: 0, 5959 READY_STATE_OPENED: 1, 5960 READY_STATE_HEADERS_RECEIVED: 2, 5961 READY_STATE_LOADING: 3, 5962 READY_STATE_DONE: 4, 5963 5964 STATUS_OK_MINOR: 200, 5965 STATUS_OK_MAJOR: 300, 5966 5967 constructor_: function() { 5968 } 5969 }); 5970/* Licensed to the Apache Software Foundation (ASF) under one or more 5971 * contributor license agreements. See the NOTICE file distributed with 5972 * this work for additional information regarding copyright ownership. 5973 * The ASF licenses this file to you under the Apache License, Version 2.0 5974 * (the "License"); you may not use this file except in compliance with 5975 * the License. You may obtain a copy of the License at 5976 * 5977 * http://www.apache.org/licenses/LICENSE-2.0 5978 * 5979 * Unless required by applicable law or agreed to in writing, software 5980 * distributed under the License is distributed on an "AS IS" BASIS, 5981 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5982 * See the License for the specific language governing permissions and 5983 * limitations under the License. 5984 */ 5985 5986/** 5987 * @class 5988 * @name FormData 5989 * @memberOf myfaces._impl.xhrCore.engine 5990 * @description 5991 * 5992 * html5 formdata object emulation for the iframe 5993 */ 5994_MF_CLS(_PFX_XHR+"engine.FormData", Object, 5995 /** @lends myfaces._impl.xhrCore.engine.FormData.prototype */ 5996 { 5997 form: null, 5998 viewstate: null, 5999 _appendedParams: {}, 6000 6001 constructor_: function(form) { 6002 this.form = form; 6003 }, 6004 6005 append: function(key, value) { 6006 this._appendedParams[key] = true; 6007 if (this.form) { 6008 this._appendHiddenValue(key, value); 6009 } 6010 }, 6011 6012 _finalize: function() { 6013 this._removeAppendedParams(); 6014 }, 6015 6016 _appendHiddenValue: function(key, value) { 6017 if ('undefined' == typeof value) { 6018 return; 6019 } 6020 var _Dom = myfaces._impl._util._Dom; 6021 var input = _Dom.createElement("input", { 6022 "type": "hidden", "name": key, "style": "display:none", "value": value 6023 }); 6024 6025 this.form.appendChild(input); 6026 }, 6027 6028 _removeAppendedParams: function() { 6029 if (!this.form) return; 6030 for (var cnt = this.form.elements.length - 1; cnt >= 0; cnt--) { 6031 var elem = this.form.elements[cnt]; 6032 if (this._appendedParams[elem.name] && elem.type == "hidden") { 6033 elem.parentNode.removeChild(elem); 6034 delete elem; 6035 } 6036 } 6037 this._appendedParams = {}; 6038 } 6039 6040 }); 6041/* Licensed to the Apache Software Foundation (ASF) under one or more 6042 * contributor license agreements. See the NOTICE file distributed with 6043 * this work for additional information regarding copyright ownership. 6044 * The ASF licenses this file to you under the Apache License, Version 2.0 6045 * (the "License"); you may not use this file except in compliance with 6046 * the License. You may obtain a copy of the License at 6047 * 6048 * http://www.apache.org/licenses/LICENSE-2.0 6049 * 6050 * Unless required by applicable law or agreed to in writing, softw
6050are 6051 * distributed under the License is distributed on an "AS IS" BASIS, 6052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6053 * See the License for the specific language governing permissions and 6054 * limitations under the License. 6055 */ 6056 6057/** 6058 * @class 6059 * @name BaseRequest 6060 * @memberOf myfaces._impl.xhrCore.engine 6061 * @extends myfaces._impl.core.Object 6062 * @description 6063 * Abstract Base for all classes which simulate the xhr level2 object 6064 * with a different transport 6065 * 6066 * <h3>Every class inheriting the interface must expose following methods and attributes</h3> 6067 * 6068 * <ul> 6069 * <li>open(method, url, async)</li> 6070 * <li>send(formData)</li> 6071 * <li>setRequestHeader(key, value)</li> 6072 * <li>abort()</li> 6073 * <li>onloadstart()</li> 6074 * <li>onprogress()</li> 6075 * <li>onabort()</li> 6076 * <li>onerror()</li> 6077 * <li>onload()</li> 6078 * <li>ontimeout()</li> 6079 * <li>onloadend()</li> 6080 * <li>onreadystatechange()</li> 6081 * </ul> 6082 * <h3>following attributes are supported</h3> 6083 * <ul> 6084 * <li>async</li> 6085 * <li>url</li> 6086 * <li>method</li> 6087 * <li>timeout</li> 6088 * <li>response</li> 6089 * <li>responseText</li> 6090 * <li>responseXML</li> 6091 * <li>status</li> 6092 * <li>statusText</li> 6093 * </ul> 6094 */ 6095_MF_CLS(_PFX_XHR + "engine.BaseRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore.engine.BaseRequest.prototype */ { 6096 /*standard attributes*/ 6097 6098 /** 6099 * timeout attribute with a timeout for the request in miliseconds 6100 */ 6101 timeout:0, 6102 /** 6103 * readonly ready stte attribute 6104 */ 6105 readyState:0, 6106 /** 6107 * send method, allowed values POST and GET 6108 */ 6109 method:"POST", 6110 /** 6111 * the url for the call 6112 */ 6113 url:null, 6114 /** 6115 * asynchronous request, if set to true then the request happens 6116 * asynchronously, if possible. 6117 */ 6118 async:true, 6119 /** 6120 * read only response object, containing the response as json/dom representation 6121 */ 6122 response:null, 6123 /** 6124 * read only plain text representation of the response 6125 */ 6126 responseText:null, 6127 /** 6128 * xml dom readonly representation of the response 6129 */ 6130 responseXML:null, 6131 /** 6132 * readonly status code of the response 6133 */ 6134 status:null, 6135 /** 6136 * readonly status text of the response 6137 */ 6138 statusText:null, 6139 6140 constructor_:function (params) { 6141 this._callSuper("constructor_", params); 6142 this._initDefaultFinalizableFields(); 6143 6144 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6145 this._Lang.applyArgs(this, params); 6146 }, 6147 6148 //open send, abort etc... abstract 6149 /** 6150 * opens the transport element 6151 * @param {String} method transport method allowed values <i>POST</i> and <i>GET</i> 6152 * @param {String} url optional url 6153 * @param {Boolean}Â async optional param asynchronous transmission if set to true 6154 */ 6155 open:function (method, url, async) { 6156 this._implementThis(); 6157 }, 6158 /** 6159 * send method 6160 * @param {Object} formData data to be posted within the request 6161 */ 6162 send:function (formData) { 6163 this._implementThis(); 6164 }, 6165 /** 6166 * appends a key value pair to the request header if possible 6167 * @param {String}Â key the key of the request header entry 6168 * @param {String}Â value the value for the key 6169 */ 6170 setRequestHeader:function (key, value) { 6171 this._implementThis(); 6172 }, 6173 /** 6174 * aborts the transmission 6175 */ 6176 abort:function () { 6177 this._implementThis(); 6178 }, 6179 6180 //empty implementations for the callback handlers 6181 /** 6182 * callback once the transmission has started 6183 * @param evt 6184 */ 6185 onloadstart:function (evt) { 6186 }, 6187 onprogress:function (evt) { 6188 }, 6189 onabort:function (evt) { 6190 }, 6191 onerror:function (evt) { 6192 }, 6193 onload:function (evt) { 6194 }, 6195 ontimeout:function (evt) { 6196 }, 6197 onloadend:function (evt) { 6198 }, 6199 onreadystatechange:function (evt) { 6200 }, 6201 6202 _implementThis:function () { 6203 throw Error("the function needs to be implemented"); 6204 } 6205}); 6206/* Licensed to the Apache Software Foundation (ASF) under one or more 6207 * contributor license agreements. See the NOTICE file distributed with 6208 * this work for additional information regarding copyright ownership. 6209 * The ASF licenses this file to you under the Apache License, Version 2.0 6210 * (the "License");
6210 you may not use this file except in compliance with 6211 * the License. You may obtain a copy of the License at 6212 * 6213 * http://www.apache.org/licenses/LICENSE-2.0 6214 * 6215 * Unless required by applicable law or agreed to in writing, software 6216 * distributed under the License is distributed on an "AS IS" BASIS, 6217 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6218 * See the License for the specific language governing permissions and 6219 * limitations under the License. 6220 */ 6221 6222 6223/** 6224 * @class 6225 * @name Xhr1 6226 * @memberOf myfaces._impl.xhrCore.engine 6227 * @extends myfaces._impl.xhrCore.engine.BaseRequest 6228 * @description 6229 * 6230 * wrapper for an xhr level1 object with all its differences 6231 * it emulates the xhr level2 api which is way simpler than the level1 api 6232 */ 6233 6234_MF_CLS(_PFX_XHR + "engine.Xhr1", myfaces._impl.xhrCore.engine.BaseRequest, /** @lends myfaces._impl.xhrCore.engine.Xhr1.prototype */ { 6235 6236 _xhrObject: null, 6237 _timeoutTimer: null, 6238 6239 constructor_: function(params) { 6240 //the constructor is empty due to the original xhr object not having anything 6241 6242 this._callSuper("constructor_", params); 6243 this._initDefaultFinalizableFields(); 6244 6245 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6246 this._Lang.applyArgs(this, params); 6247 }, 6248 6249 // void open(DOMString method, DOMString url, boolean async); 6250 open: function(method, url, async) { 6251 6252 var xhr = this._xhrObject; 6253 xhr.onreadystatechange = this._Lang.hitch(this, this.onreadystatechange); 6254 this.method = method || this.method; 6255 this.url = url || this.url; 6256 this.async = ('undefined' != typeof async) ? async : this.async; 6257 xhr.open(this.method, this.url, this.async); 6258 }, 6259 6260 send: function(formData) { 6261 6262 var myevt = {}; 6263 6264 this._addProgressAttributes(myevt, 20, 100); 6265 this.onloadstart(myevt); 6266 this.onprogress(myevt); 6267 this._startTimeout(); 6268 this._xhrObject.send(formData); 6269 }, 6270 6271 setRequestHeader: function(key, value) { 6272 this._xhrObject.setRequestHeader(key, value); 6273 }, 6274 6275 abort: function() { 6276 6277 this._xhrObject.abort(); 6278 this.onabort({}); 6279 }, 6280 6281 _addProgressAttributes: function(evt, percent, total) { 6282 //http://www.w3.org/TR/progress-events/#progressevent 6283 evt.lengthComputable = true; 6284 evt.loaded = percent; 6285 evt.total = total; 6286 6287 }, 6288 6289 onreadystatechange: function(evt) { 6290 var myevt = evt || {}; 6291 //we have to simulate the attributes as well 6292 var xhr = this._xhrObject; 6293 var XHRConst = this._XHRConst; 6294 try { 6295 this.readyState = xhr.readyState; 6296 this.status = ""+xhr.status; 6297 } catch(e) { 6298 //IE 6 has an internal error 6299 } 6300 6301 switch (this.readyState) { 6302 6303 case XHRConst.READY_STATE_OPENED: 6304 this._addProgressAttributes(myevt, 10, 100); 6305 6306 this.onprogress(myevt); 6307 break; 6308 6309 case XHRConst.READY_STATE_HEADERS_RECEIVED: 6310 this._addProgressAttributes(myevt, 25, 100); 6311 6312 this.onprogress(myevt); 6313 break; 6314 6315 case XHRConst.READY_STATE_LOADING: 6316 if (this._loadingCalled) break; 6317 this._loadingCalled = true; 6318 this._addProgressAttributes(myevt, 50, 100); 6319 6320 this.onprogress(myevt); 6321 break; 6322 6323 case XHRConst.READY_STATE_DONE: 6324 this._addProgressAttributes(myevt, 100, 100); 6325 //xhr level1 does not have timeout handler 6326 if (this._timeoutTimer) { 6327 //normally the timeout should not cause anything anymore 6328 //but just to make sure 6329 window.clearTimeout(this._timeoutTimer); 6330 this._timeoutTimer = null; 6331 } 6332 this._transferRequestValues(); 6333 this.onprogress(myevt); 6334 try { 6335 var status = xhr.status; 6336 if (status >= XHRConst.STATUS_OK_MINOR && status < XHRConst.STATUS_OK_MAJOR) { 6337 this.onload(myevt); 6338 } else { 6339 myevt.type = "error";
6340 this.onerror(myevt); 6341 } 6342 } finally { 6343 //remove for xhr level2 support 6344 this.onloadend(myevt); 6345 } 6346 } 6347 }, 6348 6349 _transferRequestValues: function() { 6350 //this._Lang.mixMaps(this, this._xhrObject, true, null, 6351 // {responseText:1,responseXML:1,status:1,statusText:1,response:1}); 6352 var UDEF = "undefined"; 6353 var xhr = this._xhrObject; 6354 6355 this.responseText = (UDEF != typeof xhr.responseText)?xhr.responseText: null; 6356 this.responseXML = (UDEF != typeof xhr.responseXML)?xhr.responseXML: null; 6357 this.status = (UDEF != typeof xhr.status)?xhr.status: null; 6358 this.statusText = (UDEF != typeof xhr.statusText)?xhr.statusText: null; 6359 this.response = (UDEF != typeof xhr.response)?xhr.response: null; 6360 }, 6361 6362 _startTimeout: function() { 6363 if (this.timeout == 0) return; 6364 6365 var xhr = this._xhrObject; 6366 //some browsers have timeouts in their xhr level 1.x objects implemented 6367 //we leverage them whenever they exist 6368 try { 6369 if ('undefined' != typeof xhr.timeout) { 6370 xhr.timeout = this.timeout; 6371 xhr.ontimeout = this.ontimeout; 6372 return; 6373 } 6374 } catch (e) { 6375 //firefox 12 has a bug here 6376 } 6377 6378 6379 this._timeoutTimer = setTimeout(this._Lang.hitch(this, function() { 6380 if (xhr.readyState != this._XHRConst.READY_STATE_DONE) { 6381 6382 xhr.onreadystatechange = function() { 6383 }; 6384 clearTimeout(this._timeoutTimer); 6385 xhr.abort(); 6386 this.ontimeout({}); 6387 } 6388 }), this.timeout); 6389 }, 6390 6391 getXHRObject: function() { 6392 return this._xhrObject; 6393 } 6394 6395 6396}); 6397/* Licensed to the Apache Software Foundation (ASF) under one or more 6398 * contributor license agreements. See the NOTICE file distributed with 6399 * this work for additional information regarding copyright ownership. 6400 * The ASF licenses this file to you under the Apache License, Version 2.0 6401 * (the "License"); you may not use this file except in compliance with 6402 * the License. You may obtain a copy of the License at 6403 * 6404 * http://www.apache.org/licenses/LICENSE-2.0 6405 * 6406 * Unless required by applicable law or agreed to in writing, software 6407 * distributed under the License is distributed on an "AS IS" BASIS, 6408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6409 * See the License for the specific language governing permissions and 6410 * limitations under the License. 6411 */ 6412 6413/** 6414 * @class 6415 * @name IFrame 6416 * @memberOf myfaces._impl.xhrCore.engine 6417 * @extends myfaces._impl.xhrCore.engine.BaseRequest 6418 * @description 6419 * 6420 * wrapper for an iframe transport object with all its differences 6421 * it emulates the xhr level2 api 6422 */ 6423_MF_CLS(_PFX_XHR + "engine.IFrame", myfaces._impl.xhrCore.engine.BaseRequest, 6424 /** @lends myfaces._impl.xhrCore.engine.IFrame.prototype */ 6425 { 6426 6427 _finalized: false, 6428 6429 /*the target frame responsible for the communication*/ 6430 _frame: null, 6431 //_requestHeader: null, 6432 _aborted: false, 6433 6434 CLS_NAME: "myfaces._impl.xhrCore._IFrameRequest", 6435 _FRAME_ID: "_mf_comm_frm", 6436 6437 /** 6438 * constructor which shifts the arguments 6439 * to the protected properties of this clas 6440 * 6441 * @param arguments 6442 */ 6443 constructor_: function (arguments) { 6444 //we fetch in the standard arguments 6445 6446 this._callSuper("constructor", arguments); 6447 6448 this._initDefaultFinalizableFields(); 6449 //this._requestHeader = {}; 6450 6451 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 6452 6453 this._Lang.applyArgs(this, arguments); 6454 this.readyState = this._XHRConst.READY_STATE_UNSENT; 6455 this._startTimeout(); 6456 }, 6457 6458 setRequestHeader: function (key, value) { 6459 //this._requestHeader[key] = value; 6460 }, 6461 6462 open: function (method, url, async) { 6463 6464 this.readyState = this._XHRConst.READY_STATE_OPENED; 6465 6466 var _RT = myfaces._impl.core._Runtime; 6467 var _Lang = this._Lang; 6468 6469 this._frame = this._createTransportFrame(); 6470 6471 //we append an onload handler to the frame 6472 //to cover the starting and loading events, 6473 //timeouts cannot be covered in a cross browser way 6474 6475 //we point our onload handler to the frame, we do not use addOnLoad 6476 //because the frame should not have other onload handlers in place 6477 if (!_RT.browser.isIE || this._Dom.isDomCompliant()) { 6478 this._frame.onload = _Lang.hitch(this, this._callback); 6479 } else { 6480 //ie has a bug, onload is not settable outside of innerHTML on iframes 6481 this._frame.onload_IE = _Lang.hitch(this, this._callback); 6482 } 6483 6484 this.method = method || this.method; 6485 this.url = url || this.url; 6486 this.async = ('undefined' != typeof async) ? async : this.async; 6487 6488 var myevt = {}; 6489 this._addProgressAttributes(myevt, 10, 100); 6490 this.onprogress(myevt); 6491 }, 6492 6493 send: function (formData) { 6494 6495 var myevt = {}; 6496 this._addProgressAttributes(myevt, 20, 100); 6497 this.onloadstart(myevt); 6498 this.onprogress(myevt); 6499 6500 var formDataForm = formData.form, 6501 oldTarget = formDataForm.target, 6502 oldMethod = formDataForm.method, 6503 oldAction = formDataForm.action; 6504 6505 try { 6506 //_t._initAjaxParams(); 6507 //for (var key in this._requestHeader) { 6508 // formData.append(key, this._requestHeader[key]); 6509 //} 6510 6511 formDataForm.target = this._frame.name; 6512 formDataForm.method = this.method; 6513 if (this.url) { 6514 formDataForm.action = this.url; 6515 } 6516 this.readyState = this._XHRConst.READY_STATE_LOADING; 6517 this.onreadystatechange(myevt); 6518 formDataForm.submit(); 6519 } finally { 6520 formDataForm.action = oldAction; 6521 formDataForm.target = oldTarget; 6522 formDataForm.method = oldMethod; 6523 6524 formData._finalize(); 6525 //alert("finalizing"); 6526 this._finalized = true; 6527 } 6528 }, 6529 6530 /*we can implement it, but it will work only on browsers 6531 * which have asynchronous iframe loading*/ 6532 abort: function () { 6533 this._aborted = true; 6534 this.onabort({}); 6535 }, 6536 6537 _addProgressAttributes: function (evt, percent, total) { 6538 //http://www.w3.org/TR/progress-events/#progressevent 6539 evt.lengthComputable = true; 6540 evt.loaded = percent; 6541 evt.total = total; 6542 6543 }, 6544 6545 _callback: function () { 6546 //------------------------------------ 6547 // we are asynchronous which means we 6548 // have to check wether our code 6549 // is finalized or not 6550 //------------------------------------ 6551 if (this._aborted) return; 6552 if (this._timeoutTimer) { 6553 clearTimeout(this._timeoutTimer); 6554 } 6555 if (!this._finalized) { 6556 setTimeout(this._Lang.hitch(this, this._callback), 10); 6557 return; 6558 } 6559 //aborted no further processing 6560 6561 try { 6562 var myevt = {}; 6563 6564 this._addProgressAttributes(myevt, 100, 100); 6565 //this.readyState = this._XHRConst.READY_STATE_DONE; 6566 //this.onreadystatechange(myevt); 6567 6568 this.responseText = this._getFrameText(); 6569 this.responseXML = this._getFrameXml(); 6570 this.readyState = this._XHRConst.READY_STATE_DONE; 6571 6572 //TODO status and statusText 6573 6574 this.onreadystatechange(myevt); 6575 this.onloadend(); 6576 6577 if (!this._Lang.isXMLParseError(this.responseXML)) { 6578 this.status = 201; 6579 this.onload(); 6580 } else { 6581 this.status = 0; 6582 //we simulate the request for our xhr call
6583 this.onerror(); 6584 } 6585 6586 } finally { 6587 this._frame = null; 6588 } 6589 }, 6590 6591 /** 6592 * returns the frame text in a browser independend manner 6593 */ 6594 _getFrameDocument: function () { 6595 6596 //we cover various browsers here, because almost all browsers keep the document in a different 6597 //position 6598 return this._frame.contentWindow.document || this._frame.contentDocument || this._frame.document; 6599 }, 6600 6601 _getFrameText: function () { 6602 var framedoc = this._getFrameDocument(); 6603 //also ie keeps the body in framedoc.body the rest in documentElement 6604 var body = framedoc.body || framedoc.documentElement; 6605 return body.innerHTML; 6606 }, 6607 6608 _clearFrame: function () { 6609 6610 var framedoc = this._getFrameDocument(); 6611 var body = framedoc.documentElement || framedoc.body; 6612 //ie8 in 7 mode chokes on the innerHTML method 6613 //direct dom removal is less flakey and works 6614 //over all browsers, but is slower 6615 if (myfaces._impl.core._Runtime.browser.isIE) { 6616 this._Dom._removeChildNodes(body, false); 6617 } else { 6618 body.innerHTML = ""; 6619 } 6620 }, 6621 6622 /** 6623 * returns the processed xml from the frame 6624 */ 6625 _getFrameXml: function () { 6626 var framedoc = this._getFrameDocument(); 6627 //same situation here, the xml is hosted either in xmlDocument or 6628 //is located directly under the frame document 6629 return framedoc.XMLDocument || framedoc; 6630 }, 6631 6632 _createTransportFrame: function () { 6633 6634 var _FRM_ID = this._FRAME_ID; 6635 var frame = document.getElementById(_FRM_ID); 6636 if (frame) return frame; 6637 //normally this code should not be called 6638 //but just to be sure 6639 6640 if (this._Dom.isDomCompliant()) { 6641 frame = this._Dom.createElement('iframe', { 6642 "src": "about:blank", 6643 "id": _FRM_ID, 6644 "name": _FRM_ID, 6645 "type": "content", 6646 "collapsed": "true", 6647 "style": "display:none" 6648 }); 6649 6650 //probably the ie method would work on all browsers 6651 //but this code is the safe bet it works on all standards 6652 //compliant browsers in a clean manner 6653 6654 document.body.appendChild(frame); 6655 } else { //Now to the non compliant browsers 6656 var node = this._Dom.createElement("div", { 6657 "style": "display:none" 6658 }); 6659 6660 //we are dealing with two well known iframe ie bugs here 6661 //first the iframe has to be set via innerHTML to be present 6662 //secondly the onload handler is immutable on ie, we have to 6663 //use a dummy onload handler in this case and call this one 6664 //from the onload handler 6665 node.innerHTML = "<iframe id='" + _FRM_ID + "' name='" + _FRM_ID + "' style='display:none;' src='about:blank' type='content' onload='this.onload_IE();' ></iframe>"; 6666 6667 //avoid the ie open tag problem 6668 var body = document.body; 6669 if (body.firstChild) { 6670 body.insertBefore(node, document.body.firstChild); 6671 } else { 6672 body.appendChild(node); 6673 } 6674 } 6675 6676 //helps to for the onload handlers and innerhtml to be in sync again 6677 return document.getElementById(_FRM_ID); 6678 }, 6679 6680 _startTimeout: function () { 6681 6682 if (this.timeout == 0) return; 6683 this._timeoutTimer = setTimeout(this._Lang.hitch(this, function () { 6684 if (this._xhrObject.readyState != this._XHRConst.READY_STATE_DONE) { 6685 6686 this._aborted = true; 6687 clearTimeout(this._timeoutTimer); 6688 //we cannot abort an iframe request 6689 this.ontimeout({}); 6690 this._timeoutTimer = null; 6691 } 6692 }), this.timeout); 6693 } 6694 }); 6695 6696/* Licensed to the Apache Software Foundation (ASF) under one or more 6697 * contributor license agreements. See the NOTICE file distributed with 6698 * this work for additional information regarding copyright ownership. 6699 * The ASF licenses this file to you under the Apache License, Version 2.0 6700 * (the "License");
6700 you may not use this file except in compliance with 6701 * the License. You may obtain a copy of the License at 6702 * 6703 * http://www.apache.org/licenses/LICENSE-2.0 6704 * 6705 * Unless required by applicable law or agreed to in writing, software 6706 * distributed under the License is distributed on an "AS IS" BASIS, 6707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6708 * See the License for the specific language governing permissions and 6709 * limitations under the License. 6710 */ 6711 6712/** 6713 * An implementation of an xhr request object 6714 * with partial page submit functionality, and jsf 6715 * ppr request and timeout handling capabilities 6716 * 6717 * Author: Werner Punz (latest modification by $Author: ganeshpuri $) 6718 * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $ 6719 */ 6720 6721/** 6722 * @class 6723 * @name _AjaxRequest 6724 * @memberOf myfaces._impl.xhrCore 6725 * @extends myfaces._impl.core.Object 6726 */ 6727_MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxRequest.prototype */ { 6728 6729 _contentType:"application/x-www-form-urlencoded", 6730 /** source element issuing the request */ 6731 _source:null, 6732 /** context passed down from the caller */ 6733 _context:null, 6734 /** source form issuing the request */ 6735 _sourceForm:null, 6736 /** passthrough parameters */ 6737 _passThrough:null, 6738 6739 /** queue control */ 6740 _timeout:null, 6741 /** enqueuing delay */ 6742 //_delay:null, 6743 /** queue size */ 6744 _queueSize:-1, 6745 6746 /** 6747 back reference to the xhr queue, 6748 only set if the object really is queued 6749 */ 6750 _xhrQueue:null, 6751 6752 /** pps an array of identifiers which should be part of the submit, the form is ignored */ 6753 _partialIdsArray:null, 6754 6755 /** xhr object, internal param */ 6756 _xhr:null, 6757 6758 /** predefined method */ 6759 _ajaxType:"POST", 6760 6761 //CONSTANTS 6762 ENCODED_URL:"javax.faces.encodedURL", 6763 /* 6764 * constants used internally 6765 */ 6766 _CONTENT_TYPE:"Content-Type", 6767 _HEAD_FACES_REQ:"Faces-Request", 6768 _VAL_AJAX:"partial/ajax", 6769 _XHR_CONST:myfaces._impl.xhrCore.engine.XhrConst, 6770 6771 // _exception: null, 6772 // _requestParameters: null, 6773 /** 6774 * Constructor 6775 * <p /> 6776 * note there is a load of common properties 6777 * inherited by the base class which define the corner 6778 * parameters and the general internal behavior 6779 * like _onError etc... 6780 * @param {Object} args an arguments map which an override any of the given protected 6781 * instance variables, by a simple name value pair combination 6782 */ 6783 constructor_:function (args) { 6784 6785 try { 6786 this._callSuper("constructor_", args); 6787 6788 this._initDefaultFinalizableFields(); 6789 delete this._resettableContent["_xhrQueue"]; 6790 6791 this.applyArgs(args); 6792 6793 /*namespace remapping for readability*/ 6794 //we fetch in the standard arguments 6795 //and apply them to our protected attributes 6796 //we do not gc the entry hence it is not defined on top 6797 var xhrCore = myfaces._impl.xhrCore; 6798 this._AJAXUTIL = xhrCore._AjaxUtils; 6799 6800 } catch (e) { 6801 //_onError 6802 this._stdErrorHandler(this._xhr, this._context, e); 6803 } 6804 }, 6805 6806 /** 6807 * Sends an Ajax request 6808 */ 6809 send:function () { 6810 6811 var _Lang = this._Lang; 6812 var _RT = this._RT; 6813 var _Dom = this._Dom; 6814 try { 6815 6816 var scopeThis = _Lang.hitch(this, function (functionName) { 6817 return _Lang.hitch(this, this[functionName]); 6818 }); 6819 this._xhr = _Lang.mixMaps(this._getTransport(), { 6820 onprogress:scopeThis("onprogress"), 6821 ontimeout:scopeThis("ontimeout"), 6822 //remove for xhr level2 support (chrome has problems with it) 6823 //for chrome we have to emulate the onloadend by calling it explicitely 6824 //and leave the onload out 6825 //onloadend: scopeThis("ondone"), 6826 onload:scopeThis("onsuccess"), 6827 onerror:scopeThis("onerror") 6828 6829 }, true); 6830 6831 this._applyClientWindowId(); 6832 var xhr = this._xhr, 6833 sourceForm = this._sourceForm, 6834 targetURL = (typeof sourceForm.elements[this.ENCODED_URL] == 'undefined') ? 6835 sourceForm.action : 6836 sourceForm.elements[this.ENCODED_URL].value, 6837 formData = this.getFormData(); 6838 6839 for (var key in this._passThrough) { 6840 if (!this._passThrough.hasOwnProperty(key)) continue; 6841 formData.append(key, this._passThrough[key]); 6842 } 6843 6844 xhr.open(this._ajaxType, targetURL + 6845 ((this._ajaxType == "GET") ? "?" + this._formDataToURI(formData) : "") 6846 , true); 6847 6848 xhr.timeout = this._timeout || 0; 6849 6850 this._applyContentType(xhr); 6851 xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX); 6852 6853 //some webkit based mobile browsers do not follow the w3c spec of 6854 // setting the accept headers automatically 6855 if (this._RT.browser.isWebKit) { 6856 xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 6857 } 6858 this._sendEvent("BEGIN"); 6859 //Check if it is a custom form data object 6860 //if yes we use makefinal for the final handling 6861 if (formData && formData.makeFinal) { 6862 formData = formData.makeFinal() 6863 } 6864 xhr.send((this._ajaxType != "GET") ? formData : null); 6865 6866 } catch (e) { 6867 //_onError//_onError 6868 e = (e._mfInternal) ? e : this._Lang.makeException(new Error(), "sendError", "sendError", this._nameSpace, "send", e.message); 6869 this._stdErrorHandler(this._xhr, this._context, e); 6870 } finally { 6871 //no finally possible since the iframe uses real asynchronousity 6872 } 6873 }, 6874 6875 _applyClientWindowId:function () { 6876 var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow"); 6877 //pass through if exists already set by _Impl 6878 if ('undefined' != typeof this._context._mfInternal._clientWindow) { 6879 this._context._mfInternal._clientWindowOld = clientWindow.value; 6880 clientWindow.value = this._context._mfInternal._clientWindow; 6881 } else { 6882 if(clientWindow) { 6883 this._context._mfInternal._clientWindowDisabled = !! clientWindow.disabled; 6884 clientWindow.disabled = true; 6885 } 6886 } 6887 }, 6888 6889 _restoreClientWindowId:function () { 6890 //we have to reset the client window back to its original state 6891 6892 var clientWindow = this._Dom.getNamedElementFromForm(this._sourceForm, "javax.faces.ClientWindow"); 6893 if(!clientWindow) { 6894 return; 6895 } 6896 if ('undefined' != typeof this._context._mfInternal._clientWindowOld) { 6897 clientWindow.value = this._context._mfInternal._clientWindow; 6898 } 6899 if('undefined' != typeof this._context._mfInternal._clientWindowDisabled) { 6900 //we reset it to the old value 6901 clientWindow.disabled = this._context._mfInternal._clientWindowDisabled; 6902 } 6903 }, 6904 6905 /** 6906 * applies the content type, this needs to be done only for xhr 6907 * level1 6908 * @param xhr 6909 * @private 6910 */ 6911 _applyContentType:function (xhr) { 6912 var contentType = this._contentType + "; charset=utf-8"; 6913 xhr.setRequestHeader(this._CONTENT_TYPE, contentType); 6914 }, 6915 6916 ondone:function () { 6917 this._requestDone(); 6918 }, 6919 6920 onsuccess:function (/*evt*/) { 6921 this._restoreClientWindowId(); 6922 var context = this._context; 6923 var xhr = this._xhr; 6924 try { 6925 this._sendEvent("COMPLETE"); 6926 //now we have to reroute into our official api 6927 //because users might want to decorate it, we will split it apart afterwards 6928 6929 context._mfInternal = context._mfInternal || {}; 6930 jsf.ajax.response((xhr.getXHRObject) ? xhr.getXHRObject() : xhr, context); 6931 6932 } catch (e) { 6933 this._stdErrorHandler(this._xhr, this._context, e); 6934 6935 //add for xhr level2 support 6936 } finally { 6937 //W3C spec onloadend must be called no matter if success or not 6938 this.ondone(); 6939 } 6940 }, 6941 6942 onerror:function (/*evt*/) { 6943 this._restoreClientWindowId(); 6944 //TODO improve the error code detection here regarding server errors etc... 6945 //and push it into our general error handling subframework 6946 var context = this._context; 6947 var xhr = this._xhr; 6948 var _Lang = this._Lang; 6949 6950 var errorText = ""; 6951 this._sendEvent("COMPLETE"); 6952 try {
6953 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 6954 //status can be 0 and statusText can be "" 6955 var status = ('undefined' != xhr.status && null != xhr.status) ? xhr.status : UNKNOWN; 6956 var statusText = ('undefined' != xhr.statusText && null != xhr.statusText) ? xhr.statusText : UNKNOWN; 6957 errorText = _Lang.getMessage("ERR_REQU_FAILED", null, status, statusText); 6958 6959 } catch (e) { 6960 errorText = _Lang.getMessage("ERR_REQ_FAILED_UNKNOWN", null); 6961 } finally { 6962 try { 6963 var _Impl = this.attr("impl"); 6964 _Impl.sendError(xhr, context, _Impl.HTTPERROR, 6965 _Impl.HTTPERROR, errorText, "", "myfaces._impl.xhrCore._AjaxRequest", "onerror"); 6966 } finally { 6967 //add for xhr level2 support 6968 //since chrome does not call properly the onloadend we have to do it manually 6969 //to eliminate xhr level1 for the compile profile modern 6970 //W3C spec onloadend must be called no matter if success or not 6971 this.ondone(); 6972 } 6973 } 6974 //_onError 6975 }, 6976 6977 onprogress:function (/*evt*/) { 6978 //do nothing for now 6979 }, 6980 6981 ontimeout:function (/*evt*/) { 6982 try { 6983 this._restoreClientWindowId(); 6984 //we issue an event not an error here before killing the xhr process 6985 this._sendEvent("TIMEOUT_EVENT"); 6986 //timeout done we process the next in the queue 6987 } finally { 6988 this._requestDone(); 6989 } 6990 }, 6991 6992 _formDataToURI:function (formData) { 6993 if (formData && formData.makeFinal) { 6994 formData = formData.makeFinal() 6995 } 6996 return formData; 6997 }, 6998 6999 _getTransport:function () { 7000 7001 var xhr = this._RT.getXHRObject(); 7002 //the current xhr level2 timeout w3c spec is not implemented by the browsers yet 7003 //we have to do a fallback to our custom routines 7004 7005 //add for xhr level2 support 7006 //Chrome fails in the current builds, on our loadend, we disable the xhr 7007 //level2 optimisations for now 7008 if (/*('undefined' == typeof this._timeout || null == this._timeout) &&*/ this._RT.getXHRLvl() >= 2) { 7009 //no timeout we can skip the emulation layer 7010 return xhr; 7011 } 7012 return new myfaces._impl.xhrCore.engine.Xhr1({xhrObject:xhr}); 7013 }, 7014 7015 //----------------- backported from the base request -------------------------------- 7016 //non abstract ones 7017 /** 7018 * Spec. 13.3.1 7019 * Collect and encode input elements. 7020 * Additionally the hidden element javax.faces.ViewState 7021 * 7022 * 7023 * @return an element of formDataWrapper 7024 * which keeps the final Send Representation of the 7025 */ 7026 getFormData:function () { 7027 var formDataDecorator = this._Lang.createFormDataDecorator(jsf.getViewState(this._sourceForm)); 7028 if (this._source && !this._isBehaviorEvent()) { 7029 this._AJAXUTIL.appendIssuingItem(this._source, formDataDecorator); 7030 } 7031 return formDataDecorator; 7032 }, 7033 7034 _isBehaviorEvent: function() { 7035 var eventType = this._passThrough[this.attr("impl").P_BEHAVIOR_EVENT] || null; 7036 var isBehaviorEvent = (!!eventType) && eventType != 'click'; 7037 return isBehaviorEvent; 7038 }, 7039 7040 /** 7041 * Client error handlers which also in the long run route into our error queue 7042 * but also are able to deliver more meaningful messages 7043 * note, in case of an error all subsequent xhr requests are dropped 7044 * to get a clean state on things 7045 * 7046 * @param request the xhr request object 7047 * @param context the context holding all values for further processing 7048 * @param exception the embedded exception 7049 */ 7050 _stdErrorHandler:function (request, context, exception) { 7051 var xhrQueue = this._xhrQueue; 7052 try { 7053 this.attr("impl").stdErrorHandler(request, context, exception); 7054 } finally { 7055 if (xhrQueue) { 7056 xhrQueue.cleanup(); 7057 } 7058 } 7059 }, 7060 7061 _sendEvent:function (evtType) { 7062 var _Impl = this.attr("impl"); 7063 _Impl.sendEvent(this._xhr, this._context, _Impl[evtType]); 7064 }, 7065 7066 _requestDone:function () { 7067 var queue = this._xhrQueue; 7068 if (queue) { 7069 queue.processQueue(); 7070 } 7071 //ie6 helper cleanup 7072 delete this._context.source; 7073 this._finalize(); 7074 }, 7075 7076 //cleanup 7077 _finalize:function () { 7078 if (this._xhr.readyState == this._XHR_CONST.READY_STATE_DONE) { 7079 this._callSuper("_finalize"); 7080 } 7081 } 7082}); 7083 7084 7085/* Licensed to the Apache Software Foundation (ASF) under one or more 7086 * contributor license agreements. See the NOTICE file distributed with 7087 * this work for additional information regarding copyright ownership. 7088 * The ASF licenses this file to you under the Apache License, Version 2.0 7089 * (the "License");
7089 you may not use this file except in compliance with 7090 * the License. You may obtain a copy of the License at 7091 * 7092 * http://www.apache.org/licenses/LICENSE-2.0 7093 * 7094 * Unless required by applicable law or agreed to in writing, software 7095 * distributed under the License is distributed on an "AS IS" BASIS, 7096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7097 * See the License for the specific language governing permissions and 7098 * limitations under the License. 7099 */ 7100/** 7101 * this method is used only for pure multipart form parts 7102 * otherwise the normal method is used 7103 * IT is a specialized request which uses the form data 7104 * element for the handling of forms 7105 */ 7106_MF_CLS(_PFX_XHR + "_MultipartAjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, { 7107 7108 _sourceForm:null, 7109 7110 constructor_:function (arguments) { 7111 this._callSuper("constructor_", arguments); 7112 //TODO xhr level2 can deal with real props 7113 7114 }, 7115 7116 getFormData:function () { 7117 var ret; 7118 //in case of a multipart form post we savely can use the FormData object 7119 if (this._context._mfInternal.xhrOp === "multipartQueuedPost") { 7120 ret = new FormData(this._sourceForm); 7121 if(this._source && !this._isBehaviorEvent()) { 7122 this._AJAXUTIL.appendIssuingItem(this._source, ret); 7123 } 7124 } else { 7125 //we switch back to the encode submittable fields system 7126 this._AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, null); 7127 if(this._source && !this._isBehaviorEvent()) { 7128 this._AJAXUTIL.appendIssuingItem(this._source, ret); 7129 } 7130 } 7131 return ret; 7132 }, 7133 7134 7135 /** 7136 * applies the content type, this needs to be done only for xhr 7137 * level1 7138 * @param xhr 7139 * @private 7140 */ 7141 _applyContentType:function (xhr) { 7142 //content type is not set in case of xhr level2 because 7143 //the form data object does it itself 7144 }, 7145 7146 _formDataToURI:function (formData) { 7147 //in xhr level2 form data takes care of the http get parametrisation 7148 return ""; 7149 }, 7150 7151 _getTransport:function () { 7152 return new XMLHttpRequest(); 7153 } 7154}); 7155 7156/** 7157 * for normal requests we basically use 7158 * only the xhr level2 object but 7159 */ 7160_MF_CLS(_PFX_XHR + "_AjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, { 7161 7162 _sourceForm:null, 7163 7164 constructor_:function (arguments) { 7165 this._callSuper("constructor_", arguments); 7166 //TODO xhr level2 can deal with real props 7167 7168 }, 7169 7170 _getTransport:function () { 7171 return new XMLHttpRequest(); 7172 } 7173}); 7174 7175 7176 7177 7178 7179/* Licensed to the Apache Software Foundation (ASF) under one or more 7180 * contributor license agreements. See the NOTICE file distributed with 7181 * this work for additional information regarding copyright ownership. 7182 * The ASF licenses this file to you under the Apache License, Version 2.0 7183 * (the "License"); you may not use this file except in compliance with 7184 * the License. You may obtain a copy of the License at 7185 * 7186 * http://www.apache.org/licenses/LICENSE-2.0 7187 * 7188 * Unless required by applicable law or agreed to in writing, software 7189 * distributed under the License is distributed on an "AS IS" BASIS, 7190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7191 * See the License for the specific language governing permissions and 7192 * limitations under the License. 7193 */ 7194 7195 7196/** 7197 * @class 7198 * @name _IFrameRequest 7199 * @memberOf myfaces._impl.xhrCore 7200 * @extends myfaces._impl.xhrCore._AjaxRequest 7201 * @description specialized implementation of the jsf js ajax request class 7202 * which utilizes an iframe transport for communications to the server 7203 */ 7204_MF_CLS(_PFX_XHR+"_IFrameRequest", myfaces._impl.xhrCore._AjaxRequest, 7205 /** @lends myfaces._impl.xhrCore._IFrameRequest.prototype */ 7206 { 7207 7208 /** 7209 * @constant 7210 * @description request marker that the request is an iframe based request 7211 */ 7212 //JX_PART_IFRAME: "javax.faces.partial.iframe", 7213 /** 7214 * @constant 7215 * @description request marker that the request is an apache myfaces iframe request based request 7216 */ 7217 MF_PART_IFRAME: "javax.faces.transport.iframe", 7218 7219 MF_PART_FACES_REQUEST: "javax.faces.request", 7220 7221 7222 constructor_: function(arguments) { 7223 this._callSuper("constructor_", arguments); 7224 }, 7225 7226 getFormData: function() { 7227 var ret = new myfaces._impl.xhrCore.engine.FormData(this._sourceForm); 7228 //marker that this is an ajax iframe request 7229 //ret.append(this.JX_PART_IFRAME, "true"); 7230 ret.append(this.MF_PART_IFRAME, "true"); 7231 ret.append(this.MF_PART_FACES_REQUEST, "partial/ajax"); 7232 7233 var viewState = decodeURIComponent(jsf.getViewState(this._sourceForm)); 7234 viewState = viewState.split("&"); 7235 7236 //we append all viewstate values which are not part of the original form 7237 //just in case getViewState is decorated 7238 for(var cnt = 0, len = viewState.length; cnt < len; cnt++) { 7239 var currViewState = viewState[cnt]; 7240 var keyVal = currViewState.split("="); 7241 var name = keyVal[0]; 7242 if(!this._Dom.getNamedElementFromForm(this._sourceForm, name)) { 7243 ret.append(name, keyVal[1]); 7244 } 7245 } 7246 7247 return ret; 7248 }, 7249 7250 _formDataToURI: function(/*formData*/) { 7251 //http get alwyays sends the form data 7252 return ""; 7253 }, 7254 7255 _getTransport: function() { 7256 return new myfaces._impl.xhrCore.engine.IFrame(); 7257 } 7258 7259}); 7260/* Licensed to the Apache Software Foundation (ASF) under one or more 7261 * contributor license agreements. See the NOTICE file distributed with 7262 * this work for additional information regarding copyright ownership. 7263 * The ASF licenses this file to you under the Apache License, Version 2.0 7264 * (the "License");
7264 you may not use this file except in compliance with 7265 * the License. You may obtain a copy of the License at 7266 * 7267 * http://www.apache.org/licenses/LICENSE-2.0 7268 * 7269 * Unless required by applicable law or agreed to in writing, software 7270 * distributed under the License is distributed on an "AS IS" BASIS, 7271 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7272 * See the License for the specific language governing permissions and 7273 * limitations under the License. 7274 */ 7275 7276/** 7277 * @class 7278 * @name _AjaxResponse 7279 * @memberOf myfaces._impl.xhrCore 7280 * @extends myfaces._impl.core.Object 7281 * @description 7282 * This singleton is responsible for handling the standardized xml ajax response 7283 * Note: since the semantic processing can be handled about 90% in a functional 7284 * style we make this class stateless. Every state information is stored 7285 * temporarily in the context. 7286 * 7287 * The singleton approach also improves performance 7288 * due to less object gc compared to the old instance approach. 7289 * 7290 */ 7291_MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhrCore._AjaxResponse.prototype */ { 7292 7293 /*partial response types*/ 7294 RESP_PARTIAL:"partial-response", 7295 RESP_TYPE_ERROR:"error", 7296 RESP_TYPE_REDIRECT:"redirect", 7297 RESP_TYPE_CHANGES:"changes", 7298 7299 /*partial commands*/ 7300 CMD_CHANGES:"changes", 7301 CMD_UPDATE:"update", 7302 CMD_DELETE:"delete", 7303 CMD_INSERT:"insert", 7304 CMD_EVAL:"eval", 7305 CMD_ERROR:"error", 7306 CMD_ATTRIBUTES:"attributes", 7307 CMD_EXTENSION:"extension", 7308 CMD_REDIRECT:"redirect", 7309 7310 /*other constants*/ 7311 P_VIEWSTATE:"javax.faces.ViewState", 7312 P_CLIENTWINDOW: "javax.faces.ClientWindow", 7313 P_VIEWROOT:"javax.faces.ViewRoot", 7314 P_VIEWHEAD:"javax.faces.ViewHead", 7315 P_VIEWBODY:"javax.faces.ViewBody", 7316 7317 /** 7318 * uses response to start Html element replacement 7319 * 7320 * @param {Object} request (xhrRequest) - xhr request object 7321 * @param {Object} context (Map) - AJAX context 7322 * 7323 * A special handling has to be added to the update cycle 7324 * according to the JSDoc specs if the CDATA block contains html tags the outer rim must be stripped 7325 * if the CDATA block contains a head section the document head must be replaced 7326 * and if the CDATA block contains a body section the document body must be replaced! 7327 * 7328 */ 7329 processResponse:function (request, context) { 7330 //mfinternal handling, note, the mfinternal is only optional 7331 //according to the spec 7332 context._mfInternal = context._mfInternal || {}; 7333 var mfInternal = context._mfInternal; 7334 7335 //the temporary data is hosted here 7336 mfInternal._updateElems = []; 7337 mfInternal._updateForms = []; 7338 mfInternal.appliedViewState = null; 7339 mfInternal.appliedClientWindow = null; 7340 7341 try { 7342 var _Impl = this.attr("impl"), _Lang = this._Lang; 7343 // TODO: 7344 // Solution from 7345 // http://www.codingforums.com/archive/index.php/t-47018.html 7346 // to solve IE error 1072896658 when a Java server sends iso88591 7347 // istead of ISO-8859-1 7348 7349 if (!request || !_Lang.exists(request, "responseXML")) { 7350 throw this.makeException(new Error(), _Impl.EMPTY_RESPONSE, _Impl.EMPTY_RESPONSE, this._nameSpace, "processResponse", ""); 7351 } 7352 //check for a parseError under certain browsers 7353 7354 var xmlContent = request.responseXML; 7355 //ie6+ keeps the parsing response under xmlContent.parserError 7356 //while the rest of the world keeps it as element under the first node 7357 var xmlErr = _Lang.fetchXMLErrorMessage(request.responseText || request.response, xmlContent) 7358 if (xmlErr) { 7359 throw this._raiseError(new Error(), xmlErr.errorMessage + "\n" + xmlErr.sourceText + "\n" + xmlErr.visualError + "\n", "processResponse"); 7360 } 7361 var partials = xmlContent.childNodes[0]; 7362 if ('undefined' == typeof partials || partials == null) { 7363 throw this._raiseError(new Error(), "No child nodes for response", "processResponse"); 7364 7365 } else { 7366 if (partials.tagName != this.RESP_PARTIAL) { 7367 // IE 8 sees XML Header as first sibling ... 7368 partials = partials.nextSibling; 7369 if (!partials || partials.tagName != this.RESP_PARTIAL) { 7370 throw this._raiseError(new Error(), "Partial response not set", "processResponse"); 7371 } 7372 } 7373 } 7374 7375 var childNodesLength = partials.childNodes.length; 7376 7377 for (var loop = 0; loop < childNodesLength; loop++) { 7378 var childNode = partials.childNodes[loop]; 7379 var tagName = childNode.tagName; 7380 /** 7381 * <eval> 7382 * <![CDATA[javascript]]> 7383 * </eval> 7384 */ 7385 7386 //this ought to be enough for eval 7387 //however the run scripts still makes sense 7388 //in the update and insert area for components 7389 //which do not use the response writer properly 7390 //we might add this one as custom option in update and 7391 //insert!
7392 if (tagName == this.CMD_ERROR) { 7393 this.processError(request, context, childNode); 7394 } else if (tagName == this.CMD_REDIRECT) { 7395 this.processRedirect(request, context, childNode); 7396 } else if (tagName == this.CMD_CHANGES) { 7397 this.processChanges(request, context, childNode); 7398 } 7399 } 7400 7401 //fixup missing viewStates due to spec deficiencies 7402 if(mfInternal.appliedViewState) { 7403 this.fixViewStates(context); 7404 } 7405 if(mfInternal.appliedClientWindow) { 7406 this.fixClientWindows(context); 7407 } 7408 7409 //spec jsdoc, the success event must be sent from response 7410 _Impl.sendEvent(request, context, _Impl["SUCCESS"]); 7411 7412 } finally { 7413 delete mfInternal._updateElems; 7414 delete mfInternal._updateForms; 7415 delete mfInternal.appliedViewState; 7416 delete mfInternal.appliedClientWindow; 7417 } 7418 }, 7419 7420 /** 7421 * fixes the viewstates in the current page 7422 * 7423 * @param context 7424 */ 7425 fixViewStates:function (context) { 7426 var _Lang = this._Lang; 7427 var mfInternal = context._mfInternal; 7428 7429 if (null == mfInternal.appliedViewState) { 7430 return; 7431 } 7432 7433 //if we set our no portlet env we safely can update all forms with 7434 //the new viewstate 7435 if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) { 7436 for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) { 7437 this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedViewState, this.P_VIEWSTATE); 7438 } 7439 return; 7440 } 7441 7442 // Now update the forms that were not replaced but forced to be updated, because contains child ajax tags 7443 // we should only update forms with view state hidden field. If by some reason, the form was set to be 7444 // updated but the form was replaced, it does not have hidden view state, so later in changeTrace processing the 7445 // view state is updated. 7446 7447 //set the viewstates of all outer forms parents of our updated elements 7448 7449 _Lang.arrForEach(mfInternal._updateForms, function (elem) { 7450 this._setVSTCWForm(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE); 7451 }, 0, this); 7452 7453 //set the viewstate of all forms within our updated elements 7454 _Lang.arrForEach(mfInternal._updateElems, function (elem) { 7455 this._setVSTCWInnerForms(context, elem, mfInternal.appliedViewState, this.P_VIEWSTATE); 7456 }, 0, this); 7457 }, 7458 7459 fixClientWindows:function (context, theForm) { 7460 var _Lang = this._Lang; 7461 var mfInternal = context._mfInternal; 7462 7463 if (null == mfInternal.appliedClientWindow) { 7464 return; 7465 } 7466 //if we set our no portlet env we safely can update all forms with 7467 //the new viewstate 7468 if (this._RT.getLocalOrGlobalConfig(context, "no_portlet_env", false)) { 7469 for (var cnt = document.forms.length - 1; cnt >= 0; cnt--) { 7470 this._setVSTCWForm(context, document.forms[cnt], mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7471 } 7472 return; 7473 } 7474 //set the client window of all outer form of updated elements 7475 7476 _Lang.arrForEach(mfInternal._updateForms, function (elem) { 7477 this._setVSTCWForm(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7478 }, 0, this); 7479 7480 //set the client window of all forms within our updated elements 7481 _Lang.arrForEach(mfInternal._updateElems, function (elem) { 7482 this._setVSTCWInnerForms(context, elem, mfInternal.appliedClientWindow, this.P_CLIENTWINDOW); 7483 }, 0, this); 7484 }, 7485 7486 /** 7487 * sets the viewstate element in a given form 7488 * 7489 * @param theForm the form to which the element has to be set to 7490 * @param context the current request context 7491 */ 7492 _setVSTCWForm:function (context, theForm, value, identifier) { 7493 theForm = this._Lang.byId(theForm); 7494 var mfInternal = context._mfInternal; 7495 7496 if (!theForm) return; 7497 7498 //in IE7 looking up form elements with complex names (such as 'javax.faces.ViewState') fail
7498s in certain cases 7499 //iterate through the form elements to find the element, instead 7500 var fieldToApply = this._Dom.getNamedElementFromForm(theForm, identifier); 7501 7502 if (fieldToApply) { 7503 this._Dom.setAttribute(fieldToApply, "value", value); 7504 } else if (!fieldToApply) { 7505 var element = this._Dom.getDummyPlaceHolder(); 7506 //spec error, two elements with the same id should not be there, TODO recheck the space if the name does not suffice alone 7507 element.innerHTML = ["<input type='hidden'", "id='", identifier+jsf.separatorchar+Math.random() , "' name='", identifier , "' value='" , value , "' />"].join(""); 7508 //now we go to proper dom handling after having to deal with another ie screwup 7509 try { 7510 theForm.appendChild(element.childNodes[0]); 7511 } finally { 7512 element.innerHTML = ""; 7513 } 7514 } 7515 }, 7516 7517 _setVSTCWInnerForms:function (context, elem, value, identifier) { 7518 7519 var _Lang = this._Lang, _Dom = this._Dom; 7520 elem = _Dom.byIdOrName(elem); 7521 //elem not found for whatever reason 7522 //https://issues.apache.org/jira/browse/MYFACES-3544 7523 if (!elem) return; 7524 7525 var replacedForms = _Dom.findByTagName(elem, "form", false); 7526 7527 var applyVST = _Lang.hitch(this, function (elem) { 7528 this._setVSTCWForm(context, elem, value, identifier); 7529 }); 7530 7531 try { 7532 _Lang.arrForEach(replacedForms, applyVST, 0, this); 7533 } finally { 7534 applyVST = null; 7535 } 7536 }, 7537 7538 /** 7539 * processes an incoming error from the response 7540 * which is hosted under the <error> tag 7541 * @param request the current request 7542 * @param context the contect object 7543 * @param node the node in the xml hosting the error message 7544 */ 7545 processError:function (request, context, node) { 7546 /** 7547 * <error> 7548 * <error-name>String</error-name> 7549 * <error-message><![CDATA[message]]></error-message> 7550 * <error> 7551 */ 7552 var errorName = node.firstChild.textContent || node.firstChild.text || "", 7553 errorMessage = node.childNodes[1].firstChild.data || ""; 7554 7555 this.attr("impl").sendError(request, context, this.attr("impl").SERVER_ERROR, errorName, errorMessage, "myfaces._impl.xhrCore._AjaxResponse", "processError"); 7556 }, 7557 7558 /** 7559 * processes an incoming xml redirect directive from the ajax response 7560 * @param request the request object 7561 * @param context the context 7562 * @param node the node hosting the redirect data 7563 */ 7564 processRedirect:function (request, context, node) { 7565 /** 7566 * <redirect url="url to redirect" /> 7567 */ 7568 var _Lang = this._Lang; 7569 var redirectUrl = node.getAttribute("url"); 7570 if (!redirectUrl) { 7571 throw this._raiseError(new Error(), _Lang.getMessage("ERR_RED_URL", null, "_AjaxResponse.processRedirect"), "processRedirect"); 7572 } 7573 redirectUrl = _Lang.trim(redirectUrl); 7574 if (redirectUrl == "") { 7575 return false; 7576 } 7577 window.location = redirectUrl; 7578 return true; 7579 }, 7580 7581 /** 7582 * main entry point for processing the changes 7583 * it deals with the <changes> node of the 7584 * response 7585 * 7586 * @param request the xhr request object 7587 * @param context the context map 7588 * @param node the changes node to be processed 7589 */ 7590 processChanges:function (request, context, node) { 7591 var changes = node.childNodes; 7592 var _Lang = this._Lang; 7593 //note we need to trace the changes which could affect our insert update or delete 7594 //se that we can realign our ViewStates afterwards 7595 //the realignment must happen post change processing 7596 7597 for (var i = 0; i < changes.length; i++) { 7598 7599 switch (changes[i].tagName) { 7600 7601 case this.CMD_UPDATE: 7602 this.processUpdate(request, context, changes[i]); 7603 break; 7604 case this.CMD_EVAL: 7605 _Lang.globalEval(changes[i].firstChild.data); 7606 break; 7607 case this.CMD_INSERT: 7608 this.processInsert(request, context, changes[i]); 7609 break; 7610 case this.CMD_DELETE: 7611 this.processDelete(request, context, changes[i]); 7612 break; 7613 case this.CMD_ATTRIBUTES: 7614 this.processAttributes(request, context, changes[i]); 7615 break; 7616 case this.CMD_EXTENSION: 7617 break; 7618 default: 7619 throw this._raiseError(new Error(), "_AjaxResponse.processChanges: Illegal Command Issued", "processChanges"); 7620 } 7621 } 7622 7623 return true; 7624 }, 7625 7626 /** 7627 * First sub-step process a pending update tag 7628 * 7629 * @param request the xhr request object 7630 * @param context the context map 7631 * @param node the changes node to be processed 7632 */ 7633 processUpdate:function (request, context, node) { 7634 if ( (node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) || (node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) ) { 7635 //update the submitting forms viewstate to the new value 7636 // The source form has to be pulled out of the CURRENT document first because the context object
7637 // may refer to an invalid document if an update of the entire body has occurred before this point. 7638 var mfInternal = context._mfInternal, 7639 fuzzyFormDetection = this._Lang.hitch(this._Dom, this._Dom.fuzzyFormDetection); 7640 var elemId = (mfInternal._mfSourceControlId) ? mfInternal._mfSourceControlId : 7641 ((context.source) ? context.source.id : null); 7642 7643 //theoretically a source of null can be given, then our form detection fails for 7644 //the source element case and hence updateviewstate is skipped for the source 7645 //form, but still render targets still can get the viewstate 7646 var sourceForm = (mfInternal && mfInternal["_mfSourceFormId"] && 7647 document.forms[mfInternal["_mfSourceFormId"]]) ? 7648 document.forms[mfInternal["_mfSourceFormId"]] : ((elemId) ? fuzzyFormDetection(elemId) : null); 7649 7650 if(node.getAttribute('id').indexOf(this.P_VIEWSTATE) != -1) { 7651 mfInternal.appliedViewState = this._Dom.concatCDATABlocks(node);//node.firstChild.nodeValue; 7652 } else if(node.getAttribute('id').indexOf(this.P_CLIENTWINDOW) != -1) { 7653 mfInternal.appliedClientWindow = node.firstChild.nodeValue; 7654 } 7655 //source form could not be determined either over the form identifer or the element 7656 //we now skip this phase and just add everything we need for the fixup code 7657 7658 if (!sourceForm) { 7659 //no source form found is not an error because 7660 //we might be able to recover one way or the other 7661 return true; 7662 } 7663 7664 mfInternal._updateForms.push(sourceForm.id); 7665 7666 } 7667 else { 7668 // response may contain several blocks 7669 var cDataBlock = this._Dom.concatCDATABlocks(node), 7670 resultNode = null, 7671 pushOpRes = this._Lang.hitch(this, this._pushOperationResult); 7672 7673 switch (node.getAttribute('id')) { 7674 case this.P_VIEWROOT: 7675 7676 cDataBlock = cDataBlock.substring(cDataBlock.indexOf("<html")); 7677 7678 var parsedData = this._replaceHead(request, context, cDataBlock); 7679 7680 resultNode = ('undefined' != typeof parsedData && null != parsedData) ? this._replaceBody(request, context, cDataBlock, parsedData) : this._replaceBody(request, context, cDataBlock); 7681 if (resultNode) { 7682 pushOpRes(context, resultNode); 7683 } 7684 break; 7685 case this.P_VIEWHEAD: 7686 //we cannot replace the head, almost no browser allows this, some of them throw errors 7687 //others simply ignore it or replace it and destroy the dom that way! 7688 this._replaceHead(request, context, cDataBlock); 7689 7690 break; 7691 case this.P_VIEWBODY: 7692 //we assume the cdata block is our body including the tag 7693 resultNode = this._replaceBody(request, context, cDataBlock); 7694 if (resultNode) { 7695 pushOpRes(context, resultNode); 7696 } 7697 break; 7698 7699 default: 7700 resultNode = this.replaceHtmlItem(request, context, node.getAttribute('id'), cDataBlock); 7701 if (resultNode) { 7702 pushOpRes(context, resultNode); 7703 } 7704 break; 7705 } 7706 } 7707 7708 return true; 7709 }, 7710 7711 _pushOperationResult:function (context, resultNode) { 7712 var mfInternal = context._mfInternal; 7713 var pushSubnode = this._Lang.hitch(this, function (currNode) { 7714 var parentForm = this._Dom.getParent(currNode, "form"); 7715 //if possible we work over the ids 7716 //so that elements later replaced are referenced 7717 //at the latest possibility 7718 if (null != parentForm) { 7719 mfInternal._updateForms.push(parentForm.id || parentForm); 7720 } 7721 else { 7722 mfInternal._updateElems.push(currNode.id || currNode); 7723 } 7724 }); 7725 var isArr = 'undefined' != typeof resultNode.length && 'undefined' == typeof resultNode.nodeType; 7726 if (isArr && resultNode.length) { 7727 for (var cnt = 0; cnt < resultNode.length; cnt++) { 7728 pushSubnode(resultNode[cnt]); 7729 } 7730 } else if (!isArr) { 7731 pushSubnode(resultNode); 7732 } 7733 7734 }, 7735 7736 /** 7737 * replaces a current head theoretically, 7738 * pratically only the scripts are evaled anew since nothing else 7739 * can be changed. 7740 * 7741 * @param request the current request 7742 * @param context the ajax context
7743 * @param newData the data to be processed 7744 * 7745 * @return an xml representation of the page for further processing if possible 7746 */ 7747 _replaceHead:function (request, context, newData) { 7748 7749 var _Lang = this._Lang, 7750 _Dom = this._Dom, 7751 isWebkit = this._RT.browser.isWebKit, 7752 //we have to work around an xml parsing bug in Webkit 7753 //see https://issues.apache.org/jira/browse/MYFACES-3061 7754 doc = (!isWebkit) ? _Lang.parseXML(newData) : null, 7755 newHead = null; 7756 7757 if (!isWebkit && _Lang.isXMLParseError(doc)) { 7758 doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->")); 7759 } 7760 7761 if (isWebkit || _Lang.isXMLParseError(doc)) { 7762 //the standard xml parser failed we retry with the stripper 7763 var parser = new (this._RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7764 var headData = parser.parse(newData, "head"); 7765 //We cannot avoid it here, but we have reduced the parsing now down to the bare minimum 7766 //for further processing 7767 newHead = _Lang.parseXML("<head>" + headData + "</head>"); 7768 //last and slowest option create a new head element and let the browser 7769 //do its slow job 7770 if (_Lang.isXMLParseError(newHead)) { 7771 try { 7772 newHead = _Dom.createElement("head"); 7773 newHead.innerHTML = headData; 7774 } catch (e) { 7775 //we give up no further fallbacks 7776 throw this._raiseError(new Error(), "Error head replacement failed reason:" + e.toString(), "_replaceHead"); 7777 } 7778 } 7779 } else { 7780 //parser worked we go on 7781 newHead = doc.getElementsByTagName("head")[0]; 7782 } 7783 7784 var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"link":true, "style":true}); 7785 _Dom.runCss(newHead, true); 7786 _Dom.deleteItems(oldTags); 7787 7788 //var oldTags = _Dom.findByTagNames(document.getElementsByTagName("head")[0], {"script": true}); 7789 //_Dom.deleteScripts(oldTags); 7790 _Dom.runScripts(newHead, true); 7791 7792 return doc; 7793 }, 7794 7795 /** 7796 * special method to handle the body dom manipulation, 7797 * replacing the entire body does not work fully by simply adding a second body 7798 * and by creating a range instead we have to work around that by dom creating a second 7799 * body and then filling it properly! 7800 * 7801 * @param {Object} request our request object 7802 * @param {Object} context (Map) the response context 7803 * @param {String} newData the markup which replaces the old dom node! 7804 * @param {Node} parsedData (optional) preparsed XML representation data of the current document 7805 */ 7806 _replaceBody:function (request, context, newData /*varargs*/) { 7807 var _RT = this._RT, 7808 _Dom = this._Dom, 7809 _Lang = this._Lang, 7810 7811 oldBody = document.getElementsByTagName("body")[0], 7812 placeHolder = document.createElement("div"), 7813 isWebkit = _RT.browser.isWebKit; 7814 7815 placeHolder.id = "myfaces_bodyplaceholder"; 7816 7817 _Dom._removeChildNodes(oldBody); 7818 oldBody.innerHTML = ""; 7819 oldBody.appendChild(placeHolder); 7820 7821 var bodyData, doc = null, parser; 7822 7823 //we have to work around an xml parsing bug in Webkit 7824 //see https://issues.apache.org/jira/browse/MYFACES-3061 7825 if (!isWebkit) { 7826 doc = (arguments.length > 3) ? arguments[3] : _Lang.parseXML(newData); 7827 } 7828 7829 if (!isWebkit && _Lang.isXMLParseError(doc)) { 7830 doc = _Lang.parseXML(newData.replace(/<!\-\-[\s\n]*<!\-\-/g, "<!--").replace(/\/\/-->[\s\n]*\/\/-->/g, "//-->")); 7831 } 7832 7833 if (isWebkit || _Lang.isXMLParseError(doc)) { 7834 //the standard xml parser failed we retry with the stripper 7835 7836 parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7837 7838 bodyData = parser.parse(newData, "body"); 7839 } else { 7840 //parser worked we go on 7841 var newBodyData = doc.getElementsByTagName("body")[0]; 7842 7843 //speedwise we serialize back into the code 7844 //for code reduction, speedwise we will take a small hit 7845 //there which we will clean up in the future, but for now 7846 //this is ok, I guess, since replace body only is a small subcase 7847 //bodyData = _Lang.serializeChilds(newBodyData); 7848 var browser = _RT.browser; 7849 if (!browser.isIEMobile || browser.isIEMobile >= 7) { 7850 //TODO check what is failing there 7851 for (var cnt = 0; cnt < newBodyData.attributes.length; cnt++) { 7852 var value = newBodyData.attributes[cnt].value; 7853 if (value) 7854 _Dom.setAttribute(oldBody, newBodyData.attributes[cnt].name, value); 7855 } 7856 } 7857 } 7858 //we cannot serialize here, due to escape problems 7859 //we must parse, this is somewhat unsafe but should be safe enough 7860 parser = new (_RT.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))(); 7861 bodyData = parser.parse(newData, "body"); 7862 7863 var returnedElement = this.replaceHtmlItem(request, context, placeHolder, bodyData); 7864 7865 if (returnedElement) { 7866 this._pushOperationResult(context, returnedElement); 7867 } 7868 return returnedElement; 7869 }, 7870 7871 /** 7872 * Replaces HTML elements through others and handle errors if the occur in the replacement part 7873 * 7874 * @param {Object} request (xhrRequest) 7875 * @param {Object} context (Map) 7876 * @param {Object} itemIdToReplace (String|Node) - ID of the element to replace 7877 * @param {String} markup - the new tag 7878 */ 7879 replaceHtmlItem:function (request, context, itemIdToReplace, markup) { 7880 var _Lang = this._Lang, _Dom = this._Dom; 7881 7882 var item = (!_Lang.isString(itemIdToReplace)) ? itemIdToReplace : 7883 _Dom.byIdOrName(itemIdToReplace); 7884 7885 if (!item) {
7886 throw this._raiseError(new Error(), _Lang.getMessage("ERR_ITEM_ID_NOTFOUND", null, "_AjaxResponse.replaceHtmlItem", (itemIdToReplace) ? itemIdToReplace.toString() : "undefined"), "replaceHtmlItem"); 7887 } 7888 return _Dom.outerHTML(item, markup, this._RT.getLocalOrGlobalConfig(context, "preserveFocus", false)); 7889 }, 7890 7891 /** 7892 * xml insert command handler 7893 * 7894 * @param request the ajax request element 7895 * @param context the context element holding the data 7896 * @param node the xml node holding the insert data 7897 * @return true upon successful completion, false otherwise 7898 * 7899 **/ 7900 processInsert:function (request, context, node) { 7901 /*remapping global namespaces for speed and readability reasons*/ 7902 var _Dom = this._Dom, 7903 _Lang = this._Lang, 7904 //determine which path to go: 7905 insertData = this._parseInsertData(request, context, node); 7906 7907 if (!insertData) return false; 7908 7909 var opNode = _Dom.byIdOrName(insertData.opId); 7910 if (!opNode) { 7911 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_INSERTBEFID_1", null, "_AjaxResponse.processInsert", insertData.opId), "processInsert"); 7912 } 7913 7914 //call insertBefore or insertAfter in our dom routines 7915 var replacementFragment = _Dom[insertData.insertType](opNode, insertData.cDataBlock); 7916 if (replacementFragment) { 7917 this._pushOperationResult(context, replacementFragment); 7918 } 7919 return true; 7920 }, 7921 7922 /** 7923 * determines the corner data from the insert tag parsing process 7924 * 7925 * 7926 * @param request request 7927 * @param context context 7928 * @param node the current node pointing to the insert tag 7929 * @return false if the parsing failed, otherwise a map with follwing attributes 7930 * <ul> 7931 * <li>inserType - a ponter to a constant which maps the direct function name for the insert operation </li> 7932 * <li>opId - the before or after id </li> 7933 * <li>cDataBlock - the html cdata block which needs replacement </li> 7934 * </ul> 7935 * 7936 * TODO we have to find a mechanism to replace the direct sendError calls with a javascript exception 7937 * which we then can use for cleaner error code handling 7938 */ 7939 _parseInsertData:function (request, context, node) { 7940 var _Lang = this._Lang, 7941 _Dom = this._Dom, 7942 concatCDATA = _Dom.concatCDATABlocks, 7943 7944 INSERT_TYPE_BEFORE = "insertBefore", 7945 INSERT_TYPE_AFTER = "insertAfter", 7946 7947 id = node.getAttribute("id"), 7948 beforeId = node.getAttribute("before"), 7949 afterId = node.getAttribute("after"), 7950 ret = {}; 7951 7952 //now we have to make a distinction between two different parsing paths 7953 //due to a spec malalignment 7954 //a <insert id="... beforeId|AfterId ="... 7955 //b <insert><before id="..., <insert> <after id=".... 7956 //see https://issues.apache.org/jira/browse/MYFACES-3318 7957 //simple id, case1 7958 if (id && beforeId && !afterId) { 7959 ret.insertType = INSERT_TYPE_BEFORE; 7960 ret.opId = beforeId; 7961 ret.cDataBlock = concatCDATA(node); 7962 7963 //<insert id=".. afterId=".. 7964 } else if (id && !beforeId && afterId) { 7965 ret.insertType = INSERT_TYPE_AFTER; 7966 ret.opId = afterId; 7967 ret.cDataBlock = concatCDATA(node); 7968 7969 //<insert><before id="... <insert><after id="... 7970 } else if (!id) { 7971 var opType = node.childNodes[0].tagName; 7972 7973 if (opType != "before" && opType != "after") { 7974 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_INSERTBEFID"), "_parseInsertData"); 7975 } 7976 opType = opType.toLowerCase(); 7977 var beforeAfterId = node.childNodes[0].getAttribute("id"); 7978 ret.insertType = (opType == "before") ? INSERT_TYPE_BEFORE : INSERT_TYPE_AFTER; 7979 ret.opId = beforeAfterId; 7980 ret.cDataBlock = concatCDATA(node.childNodes[0]); 7981 } else {
7982 throw this._raiseError(new Error(), [_Lang.getMessage("ERR_PPR_IDREQ"), 7983 "\n ", 7984 _Lang.getMessage("ERR_PPR_INSERTBEFID")].join(""), "_parseInsertData"); 7985 } 7986 ret.opId = _Lang.trim(ret.opId); 7987 return ret; 7988 }, 7989 7990 processDelete:function (request, context, node) { 7991 7992 var _Lang = this._Lang, 7993 _Dom = this._Dom, 7994 deleteId = node.getAttribute('id'); 7995 7996 if (!deleteId) { 7997 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_UNKNOWNCID", null, "_AjaxResponse.processDelete", ""), "processDelete"); 7998 } 7999 8000 var item = _Dom.byIdOrName(deleteId); 8001 if (!item) { 8002 throw this._raiseError(new Error(), _Lang.getMessage("ERR_PPR_UNKNOWNCID", null, "_AjaxResponse.processDelete", deleteId), "processDelete"); 8003 } 8004 8005 var parentForm = this._Dom.getParent(item, "form"); 8006 if (null != parentForm) { 8007 context._mfInternal._updateForms.push(parentForm); 8008 } 8009 _Dom.deleteItem(item); 8010 8011 return true; 8012 }, 8013 8014 processAttributes:function (request, context, node) { 8015 //we now route into our attributes function to bypass 8016 //IE quirks mode incompatibilities to the biggest possible extent 8017 //most browsers just have to do a setAttributes but IE 8018 //behaves as usual not like the official standard 8019 //myfaces._impl._util.this._Dom.setAttribute(domNode, attribute, value; 8020 8021 var _Lang = this._Lang, 8022 //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes> 8023 elemId = node.getAttribute('id'); 8024 8025 if (!elemId) { 8026 throw this._raiseError(new Error(), "Error in attributes, id not in xml markup", "processAttributes"); 8027 } 8028 var childNodes = node.childNodes; 8029 8030 if (!childNodes) { 8031 return false; 8032 } 8033 for (var loop2 = 0; loop2 < childNodes.length; loop2++) { 8034 var attributesNode = childNodes[loop2], 8035 attrName = attributesNode.getAttribute("name"), 8036 attrValue = attributesNode.getAttribute("value"); 8037 8038 if (!attrName) { 8039 continue; 8040 } 8041 8042 attrName = _Lang.trim(attrName); 8043 /*no value means reset*/ 8044 //value can be of boolean value hence full check 8045 if ('undefined' == typeof attrValue || null == attrValue) { 8046 attrValue = ""; 8047 } 8048 8049 switch (elemId) { 8050 case this.P_VIEWROOT: 8051 throw this._raiseError(new Error(), _Lang.getMessage("ERR_NO_VIEWROOTATTR", null, "_AjaxResponse.processAttributes"), "processAttributes"); 8052 8053 case this.P_VIEWHEAD: 8054 throw this._raiseError(new Error(), _Lang.getMessage("ERR_NO_HEADATTR", null, "_AjaxResponse.processAttributes"), "processAttributes"); 8055 8056 case this.P_VIEWBODY: 8057 var element = document.getElementsByTagName("body")[0]; 8058 this._Dom.setAttribute(element, attrName, attrValue); 8059 break; 8060 8061 default: 8062 this._Dom.setAttribute(document.getElementById(elemId), attrName, attrValue); 8063 break; 8064 } 8065 } 8066 return true; 8067 }, 8068 8069 /** 8070 * internal helper which raises an error in the 8071 * format we need for further processing 8072 * 8073 * @param message the message 8074 * @param title the title of the error (optional) 8075 * @param name the name of the error (optional) 8076 */ 8077 _raiseError:function (error, message, caller, title, name) { 8078 var _Impl = this.attr("impl"); 8079 var finalTitle = title || _Impl.MALFORMEDXML; 8080 var finalName = name || _Impl.MALFORMEDXML; 8081 var finalMessage = message || ""; 8082 8083 return this._Lang.makeException(error, finalTitle, finalName, this._nameSpace, caller || ( (arguments.caller) ? arguments.caller.toString() : "_raiseError"), finalMe
8083ssage); 8084 } 8085}); 8086 8087/* Licensed to the Apache Software Foundation (ASF) under one or more 8088 * contributor license agreements. See the NOTICE file distributed with 8089 * this work for additional information regarding copyright ownership. 8090 * The ASF licenses this file to you under the Apache License, Version 2.0 8091 * (the "License"); you may not use this file except in compliance with 8092 * the License. You may obtain a copy of the License at 8093 * 8094 * http://www.apache.org/licenses/LICENSE-2.0 8095 * 8096 * Unless required by applicable law or agreed to in writing, software 8097 * distributed under the License is distributed on an "AS IS" BASIS, 8098 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8099 * See the License for the specific language governing permissions and 8100 * limitations under the License. 8101 */ 8102 8103/** 8104 * @class 8105 * @name _Transports 8106 * @memberOf myfaces._impl.xhrCore 8107 * @description 8108 * 8109 * The xhr core adapter 8110 * which provides the transport mechanisms to the calling 8111 * objects, and controls the queue behavior, the error handling 8112 * and partial page submit functionality among other things 8113 * <p /> 8114 * The idea behind this is to make the ajax request object as barebones 8115 * as possible and shift the extra functionality like queuing 8116 * parameter handling etc... to this class so that our transports become more easily 8117 * pluggable. This should keep the path open to iframe submits and other transport layers 8118 * <p /> 8119 * the call to the corresponding transport just should be a 8120 * transport.xhrQueuedPost <br /> 8121 * or transport.xhrPost,transport.xhrGet etc... in the future 8122 * <p /> 8123 * Note we have taken a pattern lesson or two from the dojo toolkit and its excellent handling 8124 * of transports by our patterns here (which is mainly a centralized transport singleton which routes 8125 * to different transport implementations and the auto passing of parameters into their 8126 * corresponding protected attributes on class level in the transports themselves) 8127 */ 8128_MF_SINGLTN(_PFX_XHR + "_Transports", _MF_OBJECT, 8129 /** @lends myfaces._impl.xhrCore._Transports.prototype */ { 8130 8131 _PAR_ERRORLEVEL:"errorlevel", 8132 _PAR_QUEUESIZE:"queuesize", 8133 _PAR_PPS:"pps", 8134 _PAR_TIMEOUT:"timeout", 8135 _PAR_DELAY:"delay", 8136 8137 8138 /** 8139 * a singleton queue 8140 * note the structure of our inheritance 8141 * is that that _queue is attached to prototype 8142 * and hence the pointer to the request qeue 8143 * is shared over all instances 8144 * 8145 * if you need to have it per instance for complex objects 8146 * you have to initialize in the constructor 8147 * 8148 * (This is the same limitation dojo class inheritance 8149 * where our inheritance pattern is derived from has) 8150 */ 8151 _q: new myfaces._impl.xhrCore._AjaxRequestQueue(), 8152 8153 /** 8154 * xhr post with enqueuing as defined by the jsf 2.0 specification 8155 * 8156 * mapped options already have the exec and view properly in place 8157 * myfaces specifics can be found under mappedOptions.myFaces 8158 * @param {Node} source the source of this call 8159 * @param {Node} sourceForm the html form which is the source of this call 8160 * @param {Object} context (Map) the internal pass through context 8161 * @param {Object} passThrgh (Map) values to be passed through 8162 **/ 8163 xhrQueuedPost : function(source, sourceForm, context, passThrgh) { 8164 context._mfInternal.xhrOp = "xhrQueuedPost"; 8165 this._q.enqueue( 8166 new (this._getAjaxReqClass(context))(this._getArguments(source, sourceForm, context, passThrgh))); 8167 }, 8168 8169 /** 8170 * iframe queued post 8171 * 8172 * mapped options already have the exec and view properly in place 8173 * myfaces specifics can be found under mappedOptions.myFaces 8174 * @param {Node} source the source of this call 8175 * @param {Node} sourceForm the html form which is the source of this call 8176 * @param {Object} context (Map) the internal pass through context 8177 * @param {Object} passThrgh (Map) values to be passed through 8178 **/ 8179 multipartQueuedPost : function(source, sourceForm, context, passThrgh) { 8180 context._mfInternal.xhrOp = "multipartQueuedPost"; 8181 var args = this._getArguments(source, sourceForm, context, passThrgh); 8182 // note in get the timeout is not working delay however is and queue size as well 8183 // since there are no cross browser ways to resolve a timeout on xhr level 8184 this._q.enqueue( 8185 new (this._getMultipartReqClass(context))(args)); 8186 }, 8187 8188 8189 /** 8190 * creates the arguments map and 8191 * fetches the config params in a proper way in to 8192 * deal with them in a flat way (from the nested context way) 8193 * 8194 * @param source the source of the request 8195 * @param sourceForm the sourceform 8196 * @param context the context holding all values 8197 * @param passThrgh the passThrough values to be blended into the response 8198 */ 8199 _getArguments: function(source, sourceForm, context, passThrgh) { 8200 var _RT = myfaces._impl.core._Runtime, 8201 /** @ignore */ 8202 _Lang = myfaces._impl._util._Lang, 8203 applyCfg = _Lang.hitch(this, this._applyConfig), 8204 //RT does not have this references, hence no hitch needed 8205 getCfg = _RT.getLocalOrGlobalConfig, 8206 8207 8208 ret = { 8209 "source": source, 8210 "sourceForm": sourceForm, 8211 "context": context, 8212 "passThrough": passThrgh, 8213 "xhrQueue": this._q 8214 }; 8215 8216 //we now mix in the config settings which might either be set globally 8217 //or pushed in under the context myfaces.<contextValue> into the current request 8218 applyCfg(ret, context, "alarmThreshold", this._PAR_ERRORLEVEL); 8219 applyCfg(ret, context, "queueSize", this._PAR_QUEUESIZE); 8220 //TODO timeout probably not needed anymore 8221 applyCfg(ret, context, "timeout", this._PAR_TIMEOUT); 8222 //applyCfg(ret, context, "delay", this._PAR_DELAY); 8223 8224 //now partial page submit needs a different treatment 8225 //since pps == execute strings 8226 if (getCfg(context, this._PAR_PPS, false) 8227 && _Lang.exists(passThrgh, myfaces._impl.core.Impl.P_EXECUTE) 8228 && passThrgh[myfaces._impl.core.Impl.P_EXECUTE].length > 0) { 8229 ret['partialIdsArray'] = passThrgh[myfaces._impl.core.Impl.P_EXECUTE].split(" "); 8230 } 8231 return ret; 8232 }, 8233 8234 /** 8235 * helper method to apply a config setting to our varargs param list 8236 * 8237 * @param destination the destination map to receive the setting 8238 * @param context the current context 8239 * @param destParm the destination param of the destination map 8240 * @param srcParm the source param which is the key to our config setting 8241 */ 8242 _applyConfig: function(destination, context, destParm, srcParm) { 8243 var _RT = myfaces._impl.core._Runtime; 8244 /** @ignore */ 8245 var _getConfig = _RT.getLocalOrGlobalConfig; 8246 if (_getConfig(context, srcParm, null) != null) { 8247 destination[destParm] = _getConfig(context, srcParm, null); 8248 } 8249 }, 8250 8251 /** 8252 * centralized transport switching helper 8253 * for the multipart submit case 8254 * 8255 * @param context the context which is passed down 8256 */ 8257 _getMultipartReqClass: function(context) { 8258 if (this._RT.getXHRLvl() >= 2) { 8259 return myfaces._impl.xhrCore._MultipartAjaxRequestLevel2; 8260 } else { 8261 return myfaces._impl.xhrCore._IFrameRequest; 8262 } 8263 }, 8264 8265 8266 _getAjaxReqClass: function(context) { 8267 // var _RT = myfaces._impl.core._Runtime; 8268 if(this._RT.getXHRLvl() < 2) { 8269 return myfaces._impl.xhrCore._AjaxRequest; 8270 } else { 8271 return myfaces._impl.xhrCore._AjaxRequestLevel2; 8272 } 8273 } 8274 8275}); 8276 8277/* Licensed to the Apache Software Foundation (ASF) under one or more 8278 * contributor license agreements. See the NOTICE file distributed with 8279 * this work for additional information regarding copyright ownership. 8280 * The ASF licenses this file to you under the Apache License, Version 2.0 8281 * (the "License");
8281 you may not use this file except in compliance with 8282 * the License. You may obtain a copy of the License at 8283 * 8284 * http://www.apache.org/licenses/LICENSE-2.0 8285 * 8286 * Unless required by applicable law or agreed to in writing, software 8287 * distributed under the License is distributed on an "AS IS" BASIS, 8288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8289 * See the License for the specific language governing permissions and 8290 * limitations under the License. 8291 */ 8292 8293/** 8294 * @class 8295 * @name _Transports 8296 * @memberOf myfaces._impl.xhrCore 8297 * @description 8298 * 8299 * The xhr core adapter 8300 * which provides the transport mechanisms to the calling 8301 * objects, and controls the queue behavior, the error handling 8302 * and partial page submit functionality among other things 8303 * <p /> 8304 * The idea behind this is to make the ajax request object as barebones 8305 * as possible and shift the extra functionality like queuing 8306 * parameter handling etc... to this class so that our transports become more easily 8307 * pluggable. This should keep the path open to iframe submits and other transport layers 8308 * <p /> 8309 * the call to the corresponding transport just should be a 8310 * transport.xhrQueuedPost <br /> 8311 * or transport.xhrPost,transport.xhrGet etc... in the future 8312 * <p /> 8313 * Note we have taken a pattern lesson or two from the dojo toolkit and its excellent handling 8314 * of transports by our patterns here (which is mainly a centralized transport singleton which routes 8315 * to different transport implementations and the auto passing of parameters into their 8316 * corresponding protected attributes on class level in the transports themselves) 8317 */ 8318_MF_SINGLTN(_PFX_XHR+"_ExtTransports" , myfaces._impl.xhrCore._Transports, 8319 /** @lends myfaces._impl.xhrCore._Transports.prototype */ { 8320 8321 8322 constructor_: function() { 8323 this._callSuper("constructor_"); 8324 myfaces._impl.xhrCore._Transports = this; 8325 //we change the transport to our new implementation 8326 this.updateSingletons("transport", this); 8327 }, 8328 8329 /** 8330 * a simple not enqueued xhr post 8331 * 8332 * mapped options already have the exec and view properly in place 8333 * myfaces specifics can be found under mappedOptions.myFaces 8334 * @param {Node} source the source of this call 8335 * @param {Node} sourceForm the html form which is the source of this call 8336 * @param {Object} context (Map) the internal pass through context 8337 * @param {Object} passThrgh (Map) values to be passed through 8338 **/ 8339 xhrPost : function(source, sourceForm, context, passThrgh) { 8340 context._mfInternal.xhrOp = "xhrPost"; 8341 var args = this._getArguments(source, sourceForm, context, passThrgh); 8342 delete args.xhrQueue; 8343 (new (this._getAjaxReqClass(context))(args)).send(); 8344 }, 8345 8346 8347 /** 8348 * xhr get without enqueuing 8349 * 8350 * mapped options already have the exec and view properly in place 8351 * myfaces specifics can be found under mappedOptions.myFaces 8352 * @param {Node} source the source of this call 8353 * @param {Node} sourceForm the html form which is the source of this call 8354 * @param {Object} context (Map) the internal pass through context 8355 * @param {Object} passThrgh (Map) values to be passed through 8356 **/ 8357 xhrGet : function(source, sourceForm, context, passThrgh) { 8358 context._mfInternal.xhrOp = "xhrGet"; 8359 var args = this._getArguments(source, sourceForm, context, passThrgh); 8360 // note in get the timeout is not working delay however is and queue size as well 8361 // since there are no cross browser ways to resolve a timeout on xhr level 8362 // we have to live with it 8363 args.ajaxType = "GET"; 8364 delete args.xhrQueue; 8365 (new (this._getAjaxReqClass(context))(args)).send(); 8366 }, 8367 8368 /** 8369 * xhr get which takes the existing queue into consideration to by synchronized 8370 * to previous queued post requests 8371 * 8372 * mapped options already have the exec and view properly in place 8373 * myfaces specifics can be found under mappedOptions.myFaces 8374 * @param {Node} source the source of this call 8375 * @param {Node} sourceForm the html form which is the source of this call 8376 * @param {Object} context (Map) the internal pass through context 8377 * @param {Object} passThrgh (Map) values to be passed through 8378 **/ 8379 xhrQueuedGet : function(source, sourceForm, context, passThrgh) { 8380 context._mfInternal.xhrOp = "xhrQueuedGet"; 8381 var args = this._getArguments(source, sourceForm, context, passThrgh); 8382 // note in get the timeout is not working delay however is and queue size as well 8383 // since there are no cross browser ways to resolve a timeout on xhr level 8384 // we have to live with it 8385 args.ajaxType = "GET"; 8386 this._q.enqueue( 8387 new (this._getAjaxReqClass(context))(args)); 8388 }, 8389 8390 8391 /** 8392 * iframe post without queueing 8393 * 8394 * mapped options already have the exec and view properly in place 8395 * myfaces specifics can be found under mappedOptions.myFaces 8396 * @param {Node} source the source of this call 8397 * @param {Node} sourceForm the html form which is the source of this call 8398 * @param {Object} context (Map) the internal pass through context 8399 * @param {Object} passThrgh (Map) values to be passed through 8400 **/ 8401 multipartPost : function(source, sourceForm, context, passThrgh) { 8402 context._mfInternal.xhrOp = "multipartPost"; 8403 var args = this._getArguments(source, sourceForm, context, passThrgh); 8404 // note in get the timeout is not working delay however is and queue size as well 8405 // since there are no cross browser ways to resolve a timeout on xhr level 8406 // we have to live with it 8407 delete args.xhrQueue; 8408 (new (this._getMultipartReqClass(context))(args)).send(); 8409 }, 8410 8411 8412 /** 8413 * iframe get without queueing 8414 * 8415 * mapped options already have the exec and view properly in place 8416 * myfaces specifics can be found under mappedOptions.myFaces 8417 * @param {Node} source the source of this call 8418 * @param {Node} sourceForm the html form which is the source of this call 8419 * @param {Object} context (Map) the internal pass through context 8420 * @param {Object} passThrgh (Map) values to be passed through 8421 **/ 8422 multipartGet : function(source, sourceForm, context, passThrgh) { 8423 context._mfInternal.xhrOp = "multiPartGet"; 8424 var args = this._getArguments(source, sourceForm, context, passThrgh); 8425 // note in get the timeout is not working delay however is and queue size as well 8426 // since there are no cross browser ways to resolve a timeout on xhr level 8427 // we have to live with it 8428 args.ajaxType = "GET"; 8429 delete args.xhrQueue; 8430 (new (this._getMultipartReqClass(context))(args)).send(); 8431 }, 8432 8433 /** 8434 * iframe queued http get 8435 * 8436 * mapped options already have the exec and view properly in place 8437 * myfaces specifics can be found under mappedOptions.myFaces 8438 * @param {Node} source the source of this call 8439 * @param {Node} sourceForm the html form which is the source of this call 8440 * @param {Object} context (Map) the internal pass through context 8441 * @param {Object} passThrgh (Map) values to be passed through 8442 **/ 8443 multipartQueuedGet : function(source, sourceForm, context, passThrgh) { 8444 context._mfInternal.xhrOp = "multipartQueuedGet"; 8445 var args = this._getArguments(source, sourceForm, context, passThrgh); 8446 // note in get the timeout is not working delay however is and queue size as well 8447 // since there are no cross browser ways to resolve a timeout on xhr level 8448 args.ajaxType = "GET"; 8449 this._q.enqueue( 8450 new (this._getMultipartReqClass(context))(args)); 8451 } 8452}); 8453 8454/* Licensed to the Apache Software Foundation (ASF) under one or more 8455 * contributor license agreements. See the NOTICE file distributed with 8456 * this work for additional information regarding copyright ownership. 8457 * The ASF licenses this file to you under the Apache License, Version 2.0 8458 * (the "License");
8458 you may not use this file except in compliance with 8459 * the License. You may obtain a copy of the License at 8460 * 8461 * http://www.apache.org/licenses/LICENSE-2.0 8462 * 8463 * Unless required by applicable law or agreed to in writing, software 8464 * distributed under the License is distributed on an "AS IS" BASIS, 8465 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8466 * See the License for the specific language governing permissions and 8467 * limitations under the License. 8468 */ 8469 8470/** 8471 * @class 8472 * @name Impl 8473 * @memberOf myfaces._impl.core 8474 * @description Implementation singleton which implements all interface method 8475 * defined by our jsf.js API 8476 * */ 8477_MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJECT, /** @lends myfaces._impl.core.Impl.prototype */ { 8478 8479 //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now 8480 _transport:myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Transports), 8481 8482 /** 8483 * external event listener queue! 8484 */ 8485 _evtListeners:new (myfaces._impl.core._Runtime.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))(), 8486 8487 /** 8488 * external error listener queue! 8489 */ 8490 _errListeners:new (myfaces._impl.core._Runtime.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))(), 8491 8492 /*CONSTANTS*/ 8493 8494 /*internal identifiers for options*/ 8495 IDENT_ALL:"@all", 8496 IDENT_NONE:"@none", 8497 IDENT_THIS:"@this", 8498 IDENT_FORM:"@form", 8499 8500 /* 8501 * [STATIC] constants 8502 */ 8503 8504 P_PARTIAL_SOURCE:"javax.faces.source", 8505 P_VIEWSTATE:"javax.faces.ViewState", 8506 P_CLIENTWINDOW:"javax.faces.ClientWindow", 8507 P_AJAX:"javax.faces.partial.ajax", 8508 P_EXECUTE:"javax.faces.partial.execute", 8509 P_RENDER:"javax.faces.partial.render", 8510 P_EVT:"javax.faces.partial.event", 8511 P_BEHAVIOR_EVENT:"javax.faces.behavior.event", 8512 P_WINDOW_ID:"javax.faces.ClientWindow", 8513 P_RESET_VALUES:"javax.faces.partial.resetValues", 8514 8515 //faces std values 8516 STD_VALUES: [this.P_PARTIAL_SOURCE, this.P_VIEWSTATE, this.P_CLIENTWINDOW, this.P_AJAX, 8517 this.P_EXECUTE, this.P_RENDER, this.P_EVT, this.P_BEHAVIOR_EVENT, this.P_WINDOW_ID, this.P_RESET_VALUES], 8518 8519 /* message types */ 8520 ERROR:"error", 8521 EVENT:"event", 8522 8523 /* event emitting stages */ 8524 BEGIN:"begin", 8525 COMPLETE:"complete", 8526 SUCCESS:"success", 8527 8528 /*ajax errors spec 14.4.2*/ 8529 HTTPERROR:"httpError", 8530 EMPTY_RESPONSE:"emptyResponse", 8531 MALFORMEDXML:"malformedXML", 8532 SERVER_ERROR:"serverError", 8533 CLIENT_ERROR:"clientError", 8534 TIMEOUT_EVENT:"timeout", 8535 8536 /*error reporting threshold*/ 8537 _threshold:"ERROR", 8538 8539 /*blockfilter for the passthrough filtering, the attributes given here 8540 * will not be transmitted from the options into the passthrough*/ 8541 _BLOCKFILTER:{onerror:1, onevent:1, render:1, execute:1, myfaces:1, delay:1, resetValues:1}, 8542 8543 /** 8544 * collect and encode data for a given form element (must be of type form) 8545 * find the javax.faces.ViewState element and encode its value as well! 8546 * return a concatenated string of the encoded values! 8547 * 8548 * @throws Error in case of the given element not being of type form! 8549 * https://issues.apache.org/jira/browse/MYFACES-2110 8550 */ 8551 getViewState:function (form) { 8552 /** 8553 * typecheck assert!, we opt for strong typing here 8554 * because it makes it easier to detect bugs 8555 */ 8556 if (form) { 8557 form = this._Lang.byId(form); 8558 } 8559 8560 if (!form 8561 || !form.nodeName 8562 || form.nodeName.toLowerCase() != "form") { 8563 throw new Error(this._Lang.getMessage("ERR_VIEWSTATE")); 8564 } 8565 8566 var ajaxUtils = myfaces._impl.xhrCore._AjaxUtils; 8567 8568 var ret = this._Lang.createFormDataDecorator([]); 8569 ajaxUtils.encodeSubmittableFields(ret, form, null); 8570 8571 return ret.makeFinal(); 8572 }, 8573 8574 /** 8575 * this function has to send the ajax requests 8576 * 8577 * following request conditions must be met: 8578 * <ul> 8579 * <li> the request must be sent asynchronously! </li> 8580 * <li> the request must be a POST!!! request </li> 8581 * <li> the request url must be the form action attribute </li> 8582 * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li> 8583 * </ul> 8584 * 8585 * @param {String|Node} elem any dom element no matter being it html or jsf, from which the event is emitted 8586 * @param {|Event|} event any javascript event supported by that object 8587 * @param {|Object|}
8587 options map of options being pushed into the ajax cycle 8588 * 8589 * 8590 * a) transformArguments out of the function 8591 * b) passThrough handling with a map copy with a filter map block map 8592 */ 8593 request:function (elem, event, options) { 8594 if (this._delayTimeout) { 8595 clearTimeout(this._delayTimeout); 8596 delete this._delayTimeout; 8597 } 8598 /*namespace remap for our local function context we mix the entire function namespace into 8599 *a local function variable so that we do not have to write the entire namespace 8600 *all the time 8601 **/ 8602 var _Lang = this._Lang, 8603 _Dom = this._Dom; 8604 /*assert if the onerror is set and once if it is set it must be of type function*/ 8605 _Lang.assertType(options.onerror, "function"); 8606 /*assert if the onevent is set and once if it is set it must be of type function*/ 8607 _Lang.assertType(options.onevent, "function"); 8608 8609 //options not set we define a default one with nothing 8610 options = options || {}; 8611 8612 /** 8613 * we cross reference statically hence the mapping here 8614 * the entire mapping between the functions is stateless 8615 */ 8616 //null definitely means no event passed down so we skip the ie specific checks 8617 if ('undefined' == typeof event) { 8618 event = window.event || null; 8619 } 8620 8621 //improve the error messages if an empty elem is passed 8622 if (!elem) { 8623 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")); 8624 } 8625 var oldElem = elem; 8626 elem = _Dom.byIdOrName(elem); 8627 if (!elem) { 8628 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)); 8629 } 8630 8631 var elementId = _Dom.nodeIdOrName(elem); 8632 8633 /* 8634 * We make a copy of our options because 8635 * we should not touch the incoming params! 8636 * this copy is also the pass through parameters 8637 * which are sent down our request 8638 */ 8639 var passThrgh = _Lang.mixMaps({}, options, true, this._BLOCKFILTER); 8640 8641 if (event) { 8642 passThrgh[this.P_EVT] = event.type; 8643 } 8644 8645 /** 8646 * ajax pass through context with the source 8647 * onevent and onerror 8648 */ 8649 var context = { 8650 source:elem, 8651 onevent:options.onevent, 8652 onerror:options.onerror, 8653 8654 //TODO move the myfaces part into the _mfInternal part 8655 myfaces:options.myfaces, 8656 _mfInternal:{} 8657 }; 8658 //additional meta information to speed things up, note internal non jsf 8659 //pass through options are stored under _mfInternal in the context 8660 var mfInternal = context._mfInternal; 8661 8662 /** 8663 * fetch the parent form 8664 * 8665 * note we also add an override possibility here 8666 * so that people can use dummy forms and work 8667 * with detached objects 8668 */ 8669 var form = (options.myfaces && options.myfaces.form) ? 8670 _Lang.byId(options.myfaces.form) : 8671 this._getForm(elem, event); 8672 8673 /** 8674 * JSF2.2 client window must be part of the issuing form so it is encoded 8675 * automatically in the request 8676 */ 8677 //we set the client window before encoding by a call to jsf.getClientWindow 8678 var clientWindow = jsf.getClientWindow(form); 8679 //in case someone decorates the getClientWindow we reset the value from 8680 //what we are getting 8681 if ('undefined' != typeof clientWindow && null != clientWindow) { 8682 var formElem = _Dom.getNamedElementFromForm(form, this.P_CLIENTWINDOW); 8683 if (formElem) { 8684 //we store the value for later processing during the ajax phase 8685 //job so that we do not get double values 8686 context._mfInternal._clientWindow = jsf.getClientWindow(form); 8687 } else { 8688 passThrgh[this.P_CLIENTWINDOW] = jsf.getClientWindow(form); 8689 } 8690 } /* spec proposal 8691 else { 8692 var formElem = _Dom.getNamedElementFromForm(form, this.P_CLIENTWINDOW); 8693 if (formElem) { 8694 context._mfInternal._clientWindow = "undefined"; 8695 } else { 8696 passThrgh[this.P_CLIENTWINDOW] = "undefined"; 8697 } 8698 } 8699 */ 8700 8701 /** 8702 * binding contract the javax.faces.source must be set 8703 */ 8704 passThrgh[this.P_PARTIAL_SOURCE] = elementId; 8705 8706 /** 8707 * javax.faces.partial.ajax must be set to true 8708 */ 8709 passThrgh[this.P_AJAX] = true; 8710 8711 /** 8712 * if resetValues is set to true 8713 * then we have to set javax.faces.resetValues as well 8714 * as pass through parameter 8715 * the value has to be explicitly true, according to 8716 * the specs jsdoc 8717 */ 8718 if(options.resetValues === true) { 8719 passThrgh[this.P_RESET_VALUES] = true; 8720 } 8721 8722 if (options.execute) { 8723 /*the options must be a blank delimited list of strings*/ 8724 /*compliance with Mojarra which automatically adds @this to an execute 8725 * the spec rev 2.0a however states, if none is issued nothing at all should be sent down 8726 */ 8727 options.execute = (options.execute.indexOf("@this") == -1) ? options.execute : options.execute; 8728 8729 this._transformList(passThrgh, this.P_EXECUTE, options.execute, form, elementId); 8730 } else { 8731 passThrgh[this.P_EXECUTE] = elementId; 8732 } 8733 8734 if (options.render) { 8735 this._transformList(passThrgh, this.P_RENDER, options.render, form, elementId); 8736 } 8737 8738 /** 8739 * multiple transports upcoming jsf 2.x feature currently allowed 8740 * default (no value) xhrQueuedPost 8741 * 8742 * xhrQueuedPost 8743 * xhrPost 8744 * xhrGet 8745 * xhrQueuedGet 8746 * iframePost 8747 * iframeQueuedPost 8748 * 8749 */ 8750 var transportType = this._getTransportType(context, passThrgh, form); 8751 8752 mfInternal["_mfSourceFormId"] = form.id; 8753 mfInternal["_mfSourceControlId"] = elementId; 8754 mfInternal["_mfTransportType"] = transportType; 8755 8756 //mojarra compatibility, mojarra is sending the form id as well 8757 //this is not documented behavior but can be determined by running 8758 //mojarra under blackbox conditions 8759 //i assume it does the same as our formId_submit=1 so leaving it out 8760 //wont hurt but for the sake of compatibility we are going to add it 8761 passThrgh[form.id] = form.id; 8762 8763 /* jsf2.2 only: options.delay || */ 8764 var delayTimeout = options.delay || this._RT.getLocalOrGlobalConfig(context, "delay", false); 8765 if (delayTimeout) { 8766 if (this._delayTimeout) { 8767 clearTimeout(this._delayTimeout); 8768 } 8769 this._delayTimeout = setTimeout(_Lang.hitch(this, function () { 8770 this._transport[transportType](elem, form, context, passThrgh); 8771 this._delayTimeout = null; 8772 }), parseInt(delayTimeout)); 8773 } else { 8774 this._transport[transportType](elem, form, context, passThrgh); 8775 } 8776 }, 8777 8778 /** 8779 * fetches the form in an unprecise manner depending 8780 * on an element or event target 8781 * 8782 * @param elem 8783 * @param event 8784 */ 8785 _getForm:function (elem, event) { 8786 var _Dom = this._Dom; 8787 var _Lang = this._Lang; 8788 var form = _Dom.fuzzyFormDetection(elem); 8789 8790 if (!form && event) { 8791 //in case of no form is given we retry over the issuing event 8792 form = _Dom.fuzzyFormDetection(_Lang.getEventTarget(event)); 8793 if (!form) { 8794 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getForm", _Lang.getMe
8794ssage("ERR_FORM")); 8795 } 8796 } else if (!form) { 8797 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getForm", _Lang.getMessage("ERR_FORM")); 8798 8799 } 8800 return form; 8801 }, 8802 8803 /** 8804 * determines the transport type to be called 8805 * for the ajax call 8806 * 8807 * @param context the context 8808 * @param passThrgh pass through values 8809 * @param form the form which issues the request 8810 */ 8811 _getTransportType:function (context, passThrgh, form) { 8812 /** 8813 * if execute or render exist 8814 * we have to pass them down as a blank delimited string representation 8815 * of an array of ids! 8816 */ 8817 //for now we turn off the transport auto selection, to enable 2.0 backwards compatibility 8818 //on protocol level, the file upload only can be turned on if the auto selection is set to true 8819 var getConfig = this._RT.getLocalOrGlobalConfig, 8820 _Lang = this._Lang, 8821 _Dom = this._Dom; 8822 8823 var transportAutoSelection = getConfig(context, "transportAutoSelection", true); 8824 /*var isMultipart = (transportAutoSelection && _Dom.getAttribute(form, "enctype") == "multipart/form-data") ? 8825 _Dom.isMultipartCandidate((!getConfig(context, "pps",false))? form : passThrgh[this.P_EXECUTE]) : 8826 false; 8827 **/ 8828 if (!transportAutoSelection) { 8829 return getConfig(context, "transportType", "xhrQueuedPost"); 8830 } 8831 var multiPartCandidate = _Dom.isMultipartCandidate((!getConfig(context, "pps", false)) ? 8832 form : passThrgh[this.P_EXECUTE]); 8833 var multipartForm = (_Dom.getAttribute(form, "enctype") || "").toLowerCase() == "multipart/form-data"; 8834 //spec section jsdoc, if we have a multipart candidate in our execute (aka fileupload) 8835 //and the form is not multipart then we have to raise an error 8836 if (multiPartCandidate && !multipartForm) { 8837 throw _Lang.makeException(new Error(), null, null, this._nameSpace, "_getTransportType", _Lang.getMessage("ERR_NO_MULTIPART_FORM", "No Multipart form", form.id)); 8838 } 8839 var isMultipart = multiPartCandidate && multipartForm; 8840 /** 8841 * multiple transports upcoming jsf 2.2 feature currently allowed 8842 * default (no value) xhrQueuedPost 8843 * 8844 * xhrQueuedPost 8845 * xhrPost 8846 * xhrGet 8847 * xhrQueuedGet 8848 * iframePost 8849 * iframeQueuedPost 8850 * 8851 */ 8852 var transportType = (!isMultipart) ? 8853 getConfig(context, "transportType", "xhrQueuedPost") : 8854 getConfig(context, "transportType", "multipartQueuedPost"); 8855 if (!this._transport[transportType]) { 8856 //throw new Error("Transport type " + transportType + " does not exist"); 8857 throw new Error(_Lang.getMessage("ERR_TRANSPORT", null, transportType)); 8858 } 8859 return transportType; 8860 8861 }, 8862 8863 /** 8864 * transforms the list to the expected one 8865 * with the proper none all form and this handling 8866 * (note we also could use a simple string replace but then 8867 * we would have had double entries under some circumstances) 8868 * 8869 * @param passThrgh 8870 * @param target 8871 * @param srcStr 8872 * @param form 8873 * @param elementId 8874 */ 8875 _transformList:function (passThrgh, target, srcStr, form, elementId) { 8876 var _Lang = this._Lang; 8877 //this is probably the fastest transformation method 8878 //it uses an array and an index to position all elements correctly 8879 //the offset variable is there to prevent 0 which results in a javascript 8880 //false 8881 srcStr = this._Lang.trim(srcStr); 8882 var offset = 1, 8883 vals = (srcStr) ? srcStr.split(/\s+/) : [], 8884 idIdx = (vals.length) ? _Lang.arrToMap(vals, offset) : {}, 8885 8886 //helpers to improve speed and compression 8887 none = idIdx[this.IDENT_NONE], 8888 all = idIdx[this.IDENT_ALL], 8889 theThis = idIdx[this.IDENT_THIS], 8890 theForm = idIdx[this.IDENT_FORM]; 8891 8892 if (none) { 8893 //in case of none nothing is returned 8894 if ('undefined' != typeof passThrgh.target) { 8895 delete passThrgh.target; 8896 } 8897 return passThrgh; 8898 } 8899 if (all) { 8900 //in case of all only one value is returned 8901 passThrgh[target] = this.IDENT_ALL; 8902 return passThrgh; 8903 } 8904 8905 if (theForm) { 8906 //the form is replaced with the proper id but the other 8907 //values are not touched 8908 vals[theForm - offset] = form.id; 8909 } 8910 if (theThis && !idIdx[elementId]) { 8911 //in case of this, the element id is set 8912 vals[theThis - offset] = elementId; 8913 } 8914 8915 //the final list must be blank separated 8916 passThrgh[target] = vals.join(" "); 8917 return passThrgh; 8918 }, 8919 8920 addOnError:function (/*function*/errorListener) { 8921 /*error handling already done in the assert of the queue*/ 8922 this._errListeners.enqueue(errorListener); 8923 }, 8924 8925 addOnEvent:function (/*function*/eventListener) { 8926 /*error handling already done in the assert of the queue*/ 8927 this._evtListeners.enqueue(eventListener); 8928 }, 8929 8930 /** 8931 * implementation triggering the error chain 8932 * 8933 * @param {Object} request the request object which comes from the xhr cycle 8934 * @param {Object} context (Map) the context object being pushed over the xhr cycle keeping additional metadata 8935 * @param {String} name the error name 8936 * @param {String} serverErrorName the server error name in case of a server error 8937 * @param {String} serverErrorMessage the server error message in case of a server error 8938 * @param {String} caller optional caller reference for extended error messages 8939 * @param {String} callFunc optional caller Function reference for extended error messages 8940 * 8941 * handles the errors, in case of an onError exists within the context the onError is called as local error handler 8942 * the registered error handlers in the queue receiv an error message to be dealt with 8943 * and if the projectStage is at development an alert box is displayed 8944 * 8945 * note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided 8946 * which changes the default output behavior from alert to something else 8947 * 8948 * 8949 */ 8950 sendError:function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage, caller, callFunc) { 8951 var _Lang = myfaces._impl._util._Lang;
8952 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 8953 8954 var eventData = {}; 8955 //we keep this in a closure because we might reuse it for our serverErrorMessage 8956 var malFormedMessage = function () { 8957 return (name && name === myfaces._impl.core.Impl.MALFORMEDXML) ? _Lang.getMessage("ERR_MALFORMEDXML") : ""; 8958 }; 8959 8960 //by setting unknown values to unknown we can handle cases 8961 //better where a simulated context is pushed into the system 8962 eventData.type = this.ERROR; 8963 8964 eventData.status = name || UNKNOWN; 8965 eventData.serverErrorName = serverErrorName || UNKNOWN; 8966 eventData.serverErrorMessage = serverErrorMessage || UNKNOWN; 8967 8968 try { 8969 eventData.source = context.source || UNKNOWN; 8970 eventData.responseCode = request.status || UNKNOWN; 8971 eventData.responseText = request.responseText || UNKNOWN; 8972 eventData.responseXML = request.responseXML || UNKNOWN; 8973 } catch (e) { 8974 // silently ignore: user can find out by examining the event data 8975 } 8976 //extended error message only in dev mode 8977 if (jsf.getProjectStage() === "Development") { 8978 eventData.serverErrorMessage = eventData.serverErrorMessage || ""; 8979 eventData.serverErrorMessage = (caller) ? eventData.serverErrorMessage + "\nCalling class: " + caller : eventData.serverErrorMessage; 8980 eventData.serverErrorMessage = (callFunc) ? eventData.serverErrorMessage + "\n Calling function: " + callFunc : eventData.serverErrorMessage; 8981 } 8982 8983 /**/ 8984 if (context["onerror"]) { 8985 context.onerror(eventData); 8986 } 8987 8988 /*now we serve the queue as well*/ 8989 this._errListeners.broadcastEvent(eventData); 8990 8991 if (jsf.getProjectStage() === "Development" && this._errListeners.length() == 0 && !context["onerror"]) { 8992 var DIVIDER = "--------------------------------------------------------", 8993 defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert), 8994 finalMessage = [], 8995 //we remap the function to achieve a better compressability 8996 pushMsg = _Lang.hitch(finalMessage, finalMessage.push); 8997 8998 (serverErrorMessage) ? pushMsg(_Lang.getMessage("MSG_ERROR_MESSAGE") + " " + serverErrorMessage + "\n") : null; 8999 9000 pushMsg(DIVIDER); 9001 9002 (caller) ? pushMsg("Calling class:" + caller) : null; 9003 (callFunc) ? pushMsg("Calling function:" + callFunc) : null; 9004 (name) ? pushMsg(_Lang.getMessage("MSG_ERROR_NAME") + " " + name) : null; 9005 (serverErrorName && name != serverErrorName) ? pushMsg("Server error name: " + serverErrorName) : null; 9006 9007 pushMsg(malFormedMessage()); 9008 pushMsg(DIVIDER); 9009 pushMsg(_Lang.getMessage("MSG_DEV_MODE")); 9010 defaultErrorOutput(finalMessage.join("\n")); 9011 } 9012 }, 9013 9014 /** 9015 * sends an event 9016 */ 9017 sendEvent:function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) { 9018 var _Lang = myfaces._impl._util._Lang; 9019 var eventData = {};
9020 var UNKNOWN = _Lang.getMessage("UNKNOWN"); 9021 9022 eventData.type = this.EVENT; 9023 9024 eventData.status = name; 9025 eventData.source = context.source; 9026 9027 if (name !== this.BEGIN) { 9028 9029 try { 9030 //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 9031 var getValue = function (value, key) { 9032 try { 9033 return value[key] 9034 } catch (e) { 9035 return UNKNOWN; 9036 } 9037 }; 9038 9039 eventData.responseCode = getValue(request, "status"); 9040 eventData.responseText = getValue(request, "responseText"); 9041 eventData.responseXML = getValue(request, "responseXML"); 9042 9043 } catch (e) { 9044 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9045 impl.sendError(request, context, this.CLIENT_ERROR, "ErrorRetrievingResponse", 9046 _Lang.getMessage("ERR_CONSTRUCT", e.toString())); 9047 9048 //client errors are not swallowed 9049 throw e; 9050 } 9051 9052 } 9053 9054 /**/ 9055 if (context.onevent) { 9056 /*calling null to preserve the original scope*/ 9057 context.onevent.call(null, eventData); 9058 } 9059 9060 /*now we serve the queue as well*/ 9061 this._evtListeners.broadcastEvent(eventData); 9062 }, 9063 9064 /** 9065 * Spec. 13.3.3 9066 * Examining the response markup and updating the DOM tree 9067 * @param {XMLHttpRequest} request - the ajax request 9068 * @param {Object} context - the ajax context 9069 */ 9070 response:function (request, context) { 9071 this._RT.getLocalOrGlobalConfig(context, "responseHandler", myfaces._impl.xhrCore._AjaxResponse).processResponse(request, context); 9072 }, 9073 9074 /** 9075 * fetches the separator char from the given script tags 9076 * 9077 * @return {char} the separator char for the given script tags 9078 */ 9079 getSeparatorChar:function () { 9080 if (this._separator) { 9081 return this.separatorchar; 9082 } 9083 var SEPARATOR_CHAR = "separatorchar", 9084 found = false, 9085 getConfig = myfaces._impl.core._Runtime.getGlobalConfig, 9086 scriptTags = document.getElementsByTagName("script"); 9087 for (var i = 0; i < scriptTags.length && !found; i++) { 9088 if (scriptTags[i].src.search(/\/javax\.faces\.resource.*\/jsf\.js.*separator/) != -1) { 9089 found = true; 9090 var result = scriptTags[i].src.match(/separator=([^&;]*)/); 9091 this._separator = decodeURIComponent(result[1]); 9092 } 9093 } 9094 this._separator = getConfig(SEPARATOR_CHAR, this._separator || ":"); 9095 return this._separator; 9096 }, 9097 9098 /** 9099 * @return the project stage also emitted by the server: 9100 * it cannot be cached and must be delivered over the server 9101 * The value for it comes from the request parameter of the jsf.js script called "stage". 9102 */ 9103 getProjectStage:function () { 9104 //since impl is a singleton we only have to do it once at first access 9105 9106 if (!this._projectStage) { 9107 var PRJ_STAGE = "projectStage", 9108 STG_PROD = "Production", 9109 9110 scriptTags = document.getElementsByTagName("script"), 9111 getConfig = myfaces._impl.core._Runtime.getGlobalConfig, 9112 projectStage = null, 9113 found = false, 9114 allowedProjectStages = {STG_PROD:1, "Development":1, "SystemTest":1, "UnitTest":1}; 9115 9116 /* run through all script tags and try to find the one that includes jsf.js */ 9117 for (var i = 0; i < scriptTags.length && !found; i++) { 9118 if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1) { 9119 var result = scriptTags[i].src.match(/stage=([^&;]*)/); 9120 found = true; 9121 if (result) { 9122 // we found stage=XXX 9123 // return only valid values of ProjectStage 9124 projectStage = (allowedProjectStages[result[1]]) ? result[1] : null; 9125 9126 } 9127 else { 9128 //we found the script, but there was no stage parameter -- Production 9129 //(we also add an override here for testing purposes, the default, however is Production) 9130 projectStage = getConfig(PRJ_STAGE, STG_PROD); 9131 } 9132 } 9133 } 9134 /* we could not find anything valid --> return the default value */ 9135 this._projectStage = getConfig(PRJ_STAGE, projectStage || STG_PROD); 9136 } 9137 return this._projectStage; 9138 }, 9139 9140 /**
9141 * implementation of the external chain function 9142 * moved into the impl 9143 * 9144 * @param {Object} source the source which also becomes 9145 * the scope for the calling function (unspecified side behavior) 9146 * the spec states here that the source can be any arbitrary code block. 9147 * Which means it either is a javascript function directly passed or a code block 9148 * which has to be evaluated separately. 9149 * 9150 * After revisiting the code additional testing against components showed that 9151 * the this parameter is only targeted at the component triggering the eval 9152 * (event) if a string code block is passed. This is behavior we have to resemble 9153 * in our function here as well, I guess. 9154 * 9155 * @param {Event} event the event object being passed down into the the chain as event origin 9156 * the spec is contradicting here, it on one hand defines event, and on the other 9157 * it says it is optional, after asking, it meant that event must be passed down 9158 * but can be undefined 9159 */ 9160 chain:function (source, event) { 9161 var len = arguments.length; 9162 var _Lang = this._Lang; 9163 var throwErr = function (msgKey) {
9164 throw Error("jsf.util.chain: " + _Lang.getMessage(msgKey)); 9165 }; 9166 /** 9167 * generic error condition checker which raises 9168 * an exception if the condition is met 9169 * @param assertion 9170 * @param message 9171 */ 9172 var errorCondition = function (assertion, message) { 9173 if (assertion === true) throwErr(message); 9174 }; 9175 var FUNC = 'function'; 9176 var ISSTR = _Lang.isString; 9177 9178 //the spec is contradicting here, it on one hand defines event, and on the other 9179 //it says it is optional, I have cleared this up now 9180 //the spec meant the param must be passed down, but can be 'undefined' 9181 9182 errorCondition(len < 2, "ERR_EV_OR_UNKNOWN"); 9183 errorCondition(len < 3 && (FUNC == typeof event || ISSTR(event)), "ERR_EVT_PASS"); 9184 if (len < 3) { 9185 //nothing to be done here, move along 9186 return true; 9187 } 9188 //now we fetch from what is given from the parameter list 9189 //we cannot work with splice here in any performant way so we do it the hard way 9190 //arguments only are give if not set to undefined even null values! 9191 9192 //assertions source either null or set as dom element: 9193 errorCondition('undefined' == typeof source, "ERR_SOURCE_DEF_NULL"); 9194 errorCondition(FUNC == typeof source, "ERR_SOURCE_FUNC"); 9195 errorCondition(ISSTR(source), "ERR_SOURCE_NOSTR"); 9196 9197 //assertion if event is a function or a string we already are in our function elements 9198 //since event either is undefined, null or a valid event object 9199 errorCondition(FUNC == typeof event || ISSTR(event), "ERR_EV_OR_UNKNOWN"); 9200 9201 for (var cnt = 2; cnt < len; cnt++) { 9202 //we do not change the scope of the incoming functions 9203 //but we reuse the argument array capabilities of apply 9204 var ret; 9205 9206 if (FUNC == typeof arguments[cnt]) { 9207 ret = arguments[cnt].call(source, event); 9208 } else { 9209 //either a function or a string can be passed in case of a string we have to wrap it into another function 9210 ret = new Function("event", arguments[cnt]).call(source, event); 9211 } 9212 //now if one function returns false in between we stop the execution of the cycle 9213 //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering 9214 if (ret === false /*undefined check implicitly done here by using a strong compare*/) { 9215 return false; 9216 } 9217 } 9218 return true; 9219 }, 9220 9221 /** 9222 * error handler behavior called internally 9223 * and only into the impl it takes care of the 9224 * internal message transformation to a myfaces internal error 9225 * and then uses the standard send error mechanisms 9226 * also a double error logging prevention is done as well 9227 * 9228 * @param request the request currently being processed 9229 * @param context the context affected by this error 9230 * @param exception the exception being thrown 9231 */ 9232 stdErrorHandler:function (request, context, exception) { 9233 //newer browsers do not allow to hold additional values on native objects like exceptions 9234 //we hence capsule it into the request, which is gced automatically 9235 //on ie as well, since the stdErrorHandler usually is called between requests 9236 //this is a valid approach 9237 if (this._threshold == "ERROR") { 9238 var mfInternal = exception._mfInternal || {}; 9239 9240 var finalMsg = []; 9241 finalMsg.push(exception.message); 9242 this.sendError(request, context, 9243 mfInternal.title || this.CLIENT_ERROR, mfInternal.name || exception.name, finalMsg.join("\n"), mfInternal.caller, mfInternal.callFunc); 9244 } 9245 }, 9246 9247 /** 9248 * @return the client window id of the current window, if one is given 9249 */ 9250 getClientWindow:function (node) { 9251 var fetchWindowIdFromForms = this._Lang.hitch(this, function (forms) { 9252 var result_idx = {}; 9253 var result; 9254 var foundCnt = 0; 9255 for (var cnt = forms.length - 1; cnt >= 0; cnt--) { 9256 9257 var currentForm = forms[cnt]; 9258 var winIdElement = this._Dom.getNamedElementFromForm(currentForm, this.P_WINDOW_ID); 9259 var windowId = (winIdElement) ? winIdElement.value : null; 9260 9261 if (windowId) { 9262 if (foundCnt > 0 && "undefined" == typeof result_idx[windowId]) throw Error("Multiple different windowIds found in document"); 9263 result = windowId; 9264 result_idx[windowId] = true; 9265 foundCnt++; 9266 } 9267 } 9268 return result; 9269 }); 9270 9271 var fetchWindowIdFromURL = function () { 9272 var href = window.location.href, windowId = "jfwid";
9273 var regex = new RegExp("[\\?&]" + windowId + "=([^&#\\;]*)"); 9274 var results = regex.exec(href); 9275 //initial trial over the url and a regexp 9276 if (results != null) return results[1]; 9277 return null; 9278 }; 9279 9280 //byId ($) 9281 var finalNode = (node) ? this._Dom.byId(node) : document.body; 9282 9283 var forms = this._Dom.findByTagName(finalNode, "form"); 9284 var result = fetchWindowIdFromForms(forms); 9285 return (null != result) ? result : fetchWindowIdFromURL(); 9286 } 9287}); 9288 9289 9290 9291/* Licensed to the Apache Software Foundation (ASF) under one or more 9292 * contributor license agreements. See the NOTICE file distributed with 9293 * this work for additional information regarding copyright ownership. 9294 * The ASF licenses this file to you under the Apache License, Version 2.0 9295 * (the "License"); you may not use this file except in compliance with 9296 * the License. You may obtain a copy of the License at 9297 * 9298 * http://www.apache.org/licenses/LICENSE-2.0 9299 * 9300 * Unless required by applicable law or agreed to in writing, software 9301 * distributed under the License is distributed on an "AS IS" BASIS, 9302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9303 * See the License for the specific language governing permissions and 9304 * limitations under the License. 9305 */ 9306/*last file loaded, must restore the state of affairs*/ 9307(function() { 9308 //some mobile browsers do not have a window object 9309 var target = window || document; 9310 9311 var resetAbbreviation = function (name) { 9312 var _temp = target.myfaces._implTemp; 9313 (!!_temp[name]) ? 9314 target[name] = _temp[name] : null; 9315 }, 9316 resetArr = ["_MF_CLS", 9317 "_MF_SINGLTN", 9318 "_MF_OBJECT", 9319 "_PFX_UTIL", 9320 "_PFX_XHR", 9321 "_PFX_CORE", 9322 "_PFX_I18N"]; 9323 for (var cnt = resetArr.length - 1; cnt >= 0; cnt--) { 9324 resetAbbreviation(resetArr[cnt]); 9325 } 9326})(); 9327 9328 9329 9330/* 9331 * Licensed to the Apache Software Foundation (ASF) under one or more 9332 * contributor license agreements. See the NOTICE file distributed with 9333 * this work for additional information regarding copyright ownership. 9334 * The ASF licenses this file to you under the Apache License, Version 2.0 9335 * (the "License"); you may not use this file except in compliance with 9336 * the License. You may obtain a copy of the License at 9337 * 9338 * http://www.apache.org/licenses/LICENSE-2.0 9339 * 9340 * Unless required by applicable law or agreed to in writing, software 9341 * distributed under the License is distributed on an "AS IS" BASIS, 9342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9343 * See the License for the specific language governing permissions and 9344 * limitations under the License. 9345*/ 9346 9347/** 9348 *MyFaces core javascripting libraries 9349 * 9350 * Those are the central public API functions in the JSF2 9351 * Ajax API! They handle the entire form submit and ajax send 9352 * and resolve cycle! 9353 */ 9354 9355/** 9356 * reserve the root namespace 9357 */ 9358if ('undefined' != typeof OpenAjax && ('undefined' == typeof jsf || null == typeof jsf)) { 9359 OpenAjax.hub.registerLibrary("jsf", "www.sun.com", "1.0", null); 9360} 9361//just in case openajax has failed (testing environment) 9362/** 9363* @ignore 9364*/ 9365if (!window.jsf) { 9366 /** 9367 * @namespace jsf 9368 */ 9369 var jsf = new function() { 9370 /* 9371 * Version of the implementation for the jsf.js. 9372 * <p /> 9373 * as specified within the jsf specifications jsf.html: 9374 * <ul> 9375 * <li>left two digits major release number</li> 9376 * <li>middle two digits minor spec release number</li> 9377 * <li>right two digits bug release number</li> 9378 * </ul> 9379 * @constant 9380 */ 9381 this.specversion = 220000; 9382 /** 9383 * Implementation version as specified within the jsf specification. 9384 * <p /> 9385 * A number increased with every implementation version 9386 * and reset by moving to a new spec release number 9387 * 9388 * @constant 9389 */ 9390 this.implversion = 0; 9391 9392 /** 9393 * SeparatorChar as defined by UINamingContainer.getNamingContainerSeparatorChar() 9394 * @type {Char} 9395 */ 9396 this.separatorchar = getSeparatorChar(); 9397 9398 /** 9399 * This method is responsible for the return of a given project stage as defined 9400 * by the jsf specification. 9401 * <p/> 9402 * Valid return values are: 9403 * <ul> 9404 * <li>"Production"</li> 9405 * <li>"Development"</li> 9406 * <li>"SystemTest"</li> 9407 * <li>"UnitTest"</li> 9408 * </li> 9409 * 9410 * @return {String} the current project state emitted by the server side method: 9411 * <i>javax.faces.application.Application.getProjectStage()</i> 9412 */ 9413 this.getProjectStage = function() { 9414 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9415 return impl.getProjectStage(); 9416 }; 9417 9418 /** 9419 * collect and encode data for a given form element (must be of type form) 9420 * find the javax.faces.ViewState element and encode its value as well! 9421 * return a concatenated string of the encoded values! 9422 * 9423 * @throws an exception in case of the given element not being of type form! 9424 * https://issues.apache.org/jira/browse/MYFACES-2110 9425 */ 9426 this.getViewState = function(formElement) { 9427 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9428 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9429 return impl.getViewState(formElement); 9430 }; 9431 9432 /** 9433 * returns the window identifier for the given node / window
9434 * @param {optional String | DomNode} the node for which the client identifier has to be determined 9435 * @return the window identifier or null if none is found 9436 */ 9437 this.getClientWindow = function() { 9438 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9439 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9440 return (arguments.length)? impl.getClientWindow(arguments[0]) : impl.getClientWindow(); 9441 } 9442 9443 //private helper functions 9444 function getSeparatorChar() { 9445 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9446 return impl.getSeparatorChar(); 9447 } 9448 9449 }; 9450 //jsdoc helper to avoid warnings, we map later 9451 window.jsf = jsf; 9452} 9453 9454/** 9455 * just to make sure no questions arise, I simply prefer here a weak 9456 * typeless comparison just in case some frameworks try to interfere 9457 * by overriding null or fiddeling around with undefined or typeof in some ways 9458 * it is safer in this case than the standard way of doing a strong comparison 9459 **/ 9460if (!jsf.ajax) { 9461 /** 9462 * @namespace jsf.ajax 9463 */ 9464 jsf.ajax = new function() { 9465 9466 9467 /** 9468 * this function has to send the ajax requests 9469 * 9470 * following request conditions must be met: 9471 * <ul> 9472 * <li> the request must be sent asynchronously! </li> 9473 * <li> the request must be a POST!!! request </li> 9474 * <li> the request url must be the form action attribute </li> 9475 * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li> 9476 * </ul> 9477 * 9478 * @param {String|Node} element: any dom element no matter being it html or jsf, from which the event is emitted 9479 * @param {EVENT} event: any javascript event supported by that object 9480 * @param {Map} options : map of options being pushed into the ajax cycle 9481 */ 9482 this.request = function(element, event, options) { 9483 if (!options) { 9484 options = {}; 9485 } 9486 /*we are not allowed to add the impl on a global scope so we have to inline the code*/ 9487 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9488 return impl.request(element, event, options); 9489 }; 9490 9491 /** 9492 * Adds an error handler to our global error queue. 9493 * the error handler must be of the format <i>function errorListener(<errorData>)</i> 9494 * with errorData being of following format: 9495 * <ul> 9496 * <li> errorData.type : "error"</li> 9497 * <li> errorData.status : the error status message</li> 9498 * <li> errorData.serverErrorName : the server error name in case of a server error</li> 9499 * <li> errorData.serverErrorMessage : the server error message in case of a server error</li> 9500 * <li> errorData.source : the issuing source element which triggered the request </li> 9501 * <li> eventData.responseCode: the response code (aka http request response code, 401 etc...) </li> 9502 * <li> eventData.responseText: the request response text </li> 9503 * <li> eventData.responseXML: the request response xml </li> 9504 * </ul> 9505 * 9506 * @param {function} errorListener error handler must be of the format <i>function errorListener(<errorData>)</i> 9507 */ 9508 this.addOnError = function(/*function*/errorListener) { 9509 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9510 return impl.addOnError(errorListener); 9511 }; 9512 9513 /** 9514 * Adds a global event listener to the ajax event queue. The event listener must be a function 9515 * of following format: <i>function eventListener(<eventData>)</i> 9516 * 9517 * @param {function} eventListener event must be of the format <i>function eventListener(<eventData>)</i> 9518 */ 9519 this.addOnEvent = function(/*function*/eventListener) { 9520 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9521 return impl.addOnEvent(eventListener); 9522 }; 9523 9524 /**
9525 * processes the ajax response if the ajax request completes successfully 9526 * @param request the ajax request! 9527 * @param context the ajax context! 9528 */ 9529 this.response = function(/*xhr request object*/request, context) { 9530 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9531 return impl.response(request, context); 9532 }; 9533 } 9534} 9535 9536if (!jsf.util) { 9537 /** 9538 * @namespace jsf.util 9539 */ 9540 jsf.util = new function() { 9541 9542 /** 9543 * varargs function which executes a chain of code (functions or any other code) 9544 * 9545 * if any of the code returns false, the execution 9546 * is terminated prematurely skipping the rest of the code! 9547 * 9548 * @param {DomNode} source, the callee object 9549 * @param {Event} event, the event object of the callee event triggering this function 9550 * @param {optional} functions to be chained, if any of those return false the chain is broken 9551 */ 9552 this.chain = function(source, event) { 9553 var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl); 9554 return impl.chain.apply(impl, arguments); 9555 }; 9556 } 9557} 9558 9559 9560
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.