dev@javaserverfaces.java.net

Review requested: version detection in jsf.js

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Fri, 05 Dec 2008 12:44:27 -0800

Roger, please check this out for me. It's basic, but it should do the
job with minimal fuss.


Add version detection to jsf.js, to allow for loading of multiple
versions correctly in a portlet environment.

SECTION: Modified Files
----------------------------
M jsf-api/resources/jsf.js


SECTION: Diffs
----------------------------
Index: jsf-api/resources/jsf.js
===================================================================
--- jsf-api/resources/jsf.js (revision 6019)
+++ jsf-api/resources/jsf.js (working copy)
@@ -66,7 +66,9 @@
     OpenAjax.hub.registerLibrary("jsf", "www.sun.com", "2.0", null);
 }
 
-// RELEASE_PENDING - add version detection.
+// Detect if this is already loaded, and if loaded, if it's a higher version
+if (!((jsf && jsf.specversion && jsf.specversion >20000 ) &&
+ (jsf.implversion && jsf.implversion > 1))) {
 
 /**
  * The top level global namespace for JavaServer Faces functionality.
@@ -81,6 +83,7 @@
  * @namespace
  * @exec
  */
+
 jsf.ajax = function() {
 
     var eventListeners = [];
@@ -1099,3 +1102,22 @@
     // RELEASE_PENDING : Still needs to be wired to the back end
     return ":";
 }();
+
+ /**
+ * An integer specifying the specification version that this file implements.
+ * It's format is: rightmost two digits, bug release number, next two digits,
+ * minor release number, leftmost digits, major release number.
+ * This number may only be incremented by a new release of the specification.
+ */
+ jsf.specversion = 20000;
+
+ /**
+ * An integer specifying the implementation version that this file implements.
+ * It's a monotonically increasing number, reset with every increment of
+ * <code>jsf.specversion</code>
+ * This number is implementation dependent.
+ */
+ jsf.implversion = 1;
+
+
+} //end if for version detection
\ No newline at end of file