myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sobr...@apache.org
Subject svn commit: r1335840 - in /myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/ java/org/apache/myfaces/trinidadinternal/resource/ javascript/META-INF/adf/jsLibs/ resourc...
Date Tue, 08 May 2012 23:59:58 GMT
Author: sobryan
Date: Tue May  8 23:59:57 2012
New Revision: 1335840

URL: http://svn.apache.org/viewvc?rev=1335840&view=rev
Log:
TRINIDAD-2100 - Trinidad's Library Scriptlet Mechansim Should Support More Selective JS Inclusion

Added:
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreFormatScriptsResourceLoader.java
Modified:
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/XhtmlScriptletFactory.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreRenderKitResourceLoader.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/LocaleElementsResourceLoader.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Locale.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/javascriptmap.properties

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/XhtmlScriptletFactory.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/XhtmlScriptletFactory.java?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/XhtmlScriptletFactory.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/XhtmlScriptletFactory.java
Tue May  8 23:59:57 2012
@@ -101,7 +101,7 @@ public class XhtmlScriptletFactory
   static
   {
     _sLocaleScriptlet =
-        new AliasedScriptlet(LOCALE_LIB, new String[]{
+        new LibraryScriptlet(LOCALE_LIB, new String[]{
                               "getUserLanguage()",
                               "getJavaLanguage()",
                               "TrConverter()", 
@@ -114,11 +114,8 @@ public class XhtmlScriptletFactory
                               "isUpperCase()",
                               "isNotUpperCase()",
                               "isLetter()",
-                              "getLocaleSymbols()"},
-                            new String[]
-                            {
-                              CORE_LIB
-                            });
+                              "getLocaleSymbols()"}
+                             );
 
     //    new LocaleInfoScriptlet();
     //new DateFormatInfoScriptlet();
@@ -140,7 +137,8 @@ public class XhtmlScriptletFactory
                            },
                            new String[]
                            {
-                             GlobalVariablesScriptlet.GLOBAL_VARIABLES_KEY
+                             GlobalVariablesScriptlet.GLOBAL_VARIABLES_KEY,
+                             LOCALE_LIB
                            })
       {
         // =-=AEW  The Core library needs to be rendered even
@@ -154,7 +152,7 @@ public class XhtmlScriptletFactory
       };
 
     _sDateFormatScriptlet =
-      new AliasedScriptlet(DATE_FORMAT_LIB,
+      new LibraryScriptlet(DATE_FORMAT_LIB,
                            new String[]
                            {
                              "TrDateTimeConverter()",
@@ -190,6 +188,7 @@ public class XhtmlScriptletFactory
                            new String[]
                            {
                              "TrValidator()",
+                             LocaleInfoScriptlet.LOCALE_INFO_KEY
                            });
 
     _sShuttleScriptlet =
@@ -217,7 +216,7 @@ public class XhtmlScriptletFactory
                              "TableProxy()",
                            });
    _sColorFormatScriptlet =
-      new AliasedScriptlet(COLOR_FORMAT_LIB,
+      new LibraryScriptlet(COLOR_FORMAT_LIB,
                            new String[]
                            {
                              "TrColor()",

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
Tue May  8 23:59:57 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.myfaces.trinidadinternal.resource;
 
+import java.io.IOException;
+
+import java.net.URL;
 import java.net.URLConnection;
 import org.apache.myfaces.trinidad.resource.AggregatingResourceLoader;
 import org.apache.myfaces.trinidad.resource.ClassLoaderResourceLoader;
@@ -29,10 +32,9 @@ import org.apache.myfaces.trinidad.resou
 public class CoreCommonScriptsResourceLoader extends AggregatingResourceLoader
 {
   public CoreCommonScriptsResourceLoader(
-    String  path,
     boolean debug)
   {
-    super(path,
+    super("",
           debug ? _DEBUG_LIBRARIES : _LIBRARIES,
           new ClassLoaderResourceLoader());
 
@@ -42,6 +44,16 @@ public class CoreCommonScriptsResourceLo
     // block comment "/*"
     setSeparator(_NEWLINE_SEPARATOR);
   }
+  
+  /**
+   * Since CoreRenderKitResourceLoader already does the matching, this method is overridden
+   * to just call getURL()
+   */
+  @Override
+  protected URL findResource(String path) throws IOException
+  {
+    return getURL(path);
+  }
 
   @Override
   protected String getContentType(
@@ -53,15 +65,8 @@ public class CoreCommonScriptsResourceLo
   // List of all libraries
   static private final String[] _LIBRARIES =
   {
-    "META-INF/adf/jsLibs/CharSets.js",
-    "META-INF/adf/jsLibs/NumberFormat.js",
-    "META-INF/adf/jsLibs/NumberConverter.js",
-    "META-INF/adf/jsLibs/CoreFormat.js",
-    "META-INF/adf/jsLibs/TrCollections.js",
     "META-INF/adf/jsLibs/DateField.js",
     "META-INF/adf/jsLibs/DateFieldFormat.js",
-    "META-INF/adf/jsLibs/DateFormat.js",
-    "META-INF/adf/jsLibs/Locale.js",
     "META-INF/adf/jsLibs/MessageBox.js",
     "META-INF/adf/jsLibs/Core.js",
     "META-INF/adf/jsLibs/Window.js",
@@ -70,7 +75,6 @@ public class CoreCommonScriptsResourceLo
     "META-INF/adf/jsLibs/Poll.js",
     "META-INF/adf/jsLibs/ColorField.js",
     "META-INF/adf/jsLibs/ColorFieldFormat.js",
-    "META-INF/adf/jsLibs/ColorFormat.js",
     "META-INF/adf/jsLibs/Shuttle.js",
     "META-INF/adf/jsLibs/PanelPopup.js",
     "META-INF/adf/jsLibs/PopupDialog.js",
@@ -86,14 +90,14 @@ public class CoreCommonScriptsResourceLo
   // List of all libraries
   static private final String[] _DEBUG_LIBRARIES =
   {
-    "META-INF/adf/jsLibsDebug/CharSets.js",
-    "META-INF/adf/jsLibsDebug/NumberFormat.js",
-    "META-INF/adf/jsLibsDebug/NumberConverter.js",
+    //"META-INF/adf/jsLibsDebug/CharSets.js",
+    //"META-INF/adf/jsLibsDebug/NumberFormat.js",
+    //"META-INF/adf/jsLibsDebug/NumberConverter.js",
     "META-INF/adf/jsLibsDebug/TrCollections.js",
-    "META-INF/adf/jsLibsDebug/CoreFormat.js",
+    //"META-INF/adf/jsLibsDebug/CoreFormat.js",
     "META-INF/adf/jsLibsDebug/DateField.js",
     "META-INF/adf/jsLibsDebug/DateFieldFormat.js",
-    "META-INF/adf/jsLibsDebug/DateFormat.js",
+    //"META-INF/adf/jsLibsDebug/DateFormat.js",
     "META-INF/adf/jsLibsDebug/Locale.js",
     "META-INF/adf/jsLibsDebug/MessageBox.js",
     "META-INF/adf/jsLibsDebug/Core.js",
@@ -103,7 +107,7 @@ public class CoreCommonScriptsResourceLo
     "META-INF/adf/jsLibsDebug/Poll.js",
     "META-INF/adf/jsLibsDebug/ColorField.js",
     "META-INF/adf/jsLibsDebug/ColorFieldFormat.js",
-    "META-INF/adf/jsLibsDebug/ColorFormat.js",
+    //"META-INF/adf/jsLibsDebug/ColorFormat.js",
     "META-INF/adf/jsLibsDebug/Shuttle.js",
     "META-INF/adf/jsLibsDebug/PanelPopup.js",
     "META-INF/adf/jsLibsDebug/PopupDialog.js",

Added: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreFormatScriptsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreFormatScriptsResourceLoader.java?rev=1335840&view=auto
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreFormatScriptsResourceLoader.java
(added)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreFormatScriptsResourceLoader.java
Tue May  8 23:59:57 2012
@@ -0,0 +1,57 @@
+package org.apache.myfaces.trinidadinternal.resource;
+
+import java.io.IOException;
+
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.myfaces.trinidad.resource.AggregatingResourceLoader;
+import org.apache.myfaces.trinidad.resource.ClassLoaderResourceLoader;
+
+public class CoreFormatScriptsResourceLoader extends AggregatingResourceLoader
+{
+  public CoreFormatScriptsResourceLoader(
+    boolean debug)
+  {
+    super("",
+          debug ? _DEBUG_LIBRARIES : _LIBRARIES,
+          new ClassLoaderResourceLoader());
+    
+    setSeparator("\n");
+  }
+  
+  /**
+   * Since CoreRenderKitResourceLoader already does the matching, this method is overridden
+   * to just call getURL()
+   */
+  @Override
+  protected URL findResource(String path) throws IOException
+  {
+    return getURL(path);
+  }
+  
+  @Override
+  protected String getContentType(
+    URLConnection conn)
+  {
+    return "text/javascript";
+  }
+  
+  static private final String[] _LIBRARIES =
+  {
+    "META-INF/adf/jsLibs/CharSets.js",
+    "META-INF/adf/jsLibs/TrCollections.js",
+    "META-INF/adf/jsLibs/NumberFormat.js",
+    "META-INF/adf/jsLibs/NumberConverter.js",
+    "META-INF/adf/jsLibs/CoreFormat.js"
+  };
+  
+  static private final String[] _DEBUG_LIBRARIES =
+  {
+    "META-INF/adf/jsLibsDebug/CharSets.js",
+    "META-INF/adf/jsLibsDebug/TrCollections.js",
+    "META-INF/adf/jsLibsDebug/NumberFormat.js",
+    "META-INF/adf/jsLibsDebug/NumberConverter.js",
+    "META-INF/adf/jsLibsDebug/CoreFormat.js"
+  };
+}

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreRenderKitResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreRenderKitResourceLoader.java?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreRenderKitResourceLoader.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreRenderKitResourceLoader.java
Tue May  8 23:59:57 2012
@@ -1,4 +1,4 @@
-/*
+ /*
  *  Licensed to the Apache Software Foundation (ASF) under one
  *  or more contributor license agreements.  See the NOTICE file
  *  distributed with this work for additional information
@@ -6,9 +6,9 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -47,27 +47,22 @@ public class CoreRenderKitResourceLoader
   public CoreRenderKitResourceLoader(ResourceLoader parent)
   {
     register("(/.*/Common.*\\.js)",
-             new CoreCommonScriptsResourceLoader(_getCommonLibraryURI(false),
-                                                 false));
+             new CoreCommonScriptsResourceLoader(false));
     register("(/.*/DebugCommon.*\\.js)",
-             new CoreCommonScriptsResourceLoader(_getCommonLibraryURI(true),
-                                                 true));
+             new CoreCommonScriptsResourceLoader(true));
+    
+    register("(/.*/CoreFmt.*\\.js)",
+             new CoreFormatScriptsResourceLoader(false));
+    register("(/.*/DebugCoreFmt.*\\.js)",
+             new CoreFormatScriptsResourceLoader(true));
+    
     register("(/.*LocaleElements.*\\.js)",
-             new LocaleElementsResourceLoader(getLocaleElementsURI("LocaleElements", true)));

+             new LocaleElementsResourceLoader()); 
 
     register("(/.*\\.(css|cur|ico|jpg|gif|png|jpeg|svg|js))",
              new CoreClassLoaderResourceLoader(parent));
   }
 
-  static private String _getCommonLibraryURI(boolean debug)
-  {
-    StringBuffer base = new StringBuffer(debug
-                                         ? "/adf/jsLibs/DebugCommon"
-                                         : "/adf/jsLibs/Common");
-    return base.append(_VERSION)
-               .append(".js")
-               .toString();
-  }
     
   static public String getLocaleElementsURI(String str, 
                                             Boolean incVersion)

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/LocaleElementsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/LocaleElementsResourceLoader.java?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/LocaleElementsResourceLoader.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/LocaleElementsResourceLoader.java
Tue May  8 23:59:57 2012
@@ -36,23 +36,26 @@ import org.apache.myfaces.trinidad.resou
  */
 public class LocaleElementsResourceLoader extends AggregatingResourceLoader
 {
-  public LocaleElementsResourceLoader(
-    String  path)
+  public LocaleElementsResourceLoader()
   {
-    super(path,
+    super("",
           _INIT_LIBRARIES,
           new ClassLoaderResourceLoader());
           
     setSeparator(_NEWLINE_SEPARATOR);
   }
   
+  /**
+   * Since CoreRenderKitResourceLoader already does the matching, this method is overridden
+   * to just call getURL()
+   */
   @Override
-  protected URL findResource(
-    String path) throws IOException
+  protected URL findResource(String path) throws IOException
   {
     return getURL(path);
   }
   
+  
   /**
    * Returns a URL which is an aggregate of all the paths.
    *

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
Tue May  8 23:59:57 2012
@@ -98,7 +98,7 @@ TrColorConverter.prototype.getAsObject  
   if (parseString == null)
     return null;
     
-  parseString = TrUIUtils.trim(parseString);
+  parseString = TrFormatUtils.trim(parseString);
   if (parseString.length == 0)
     return null
 

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Tue May  8 23:59:57 2012
@@ -2707,63 +2707,6 @@ function _multiValidate(
   return failureMap;
 }
 
-/**
- * Used for the converters and validators we provide which all have the form
- *
- * {0} - label
- * {1} - string value
- * {2} - extra param
- * {3} - extra param
- */
-function _createFacesMessage(
-  key,
-  label,
-  value,
-  param2,
-  param3
-)
-{
-  var summary = TrMessageFactory.getSummaryString(key);
-  var detail = TrMessageFactory.getDetailString(key);
-  // format the detail error string
-  if (detail != null)
-  {
-    detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
-  }
-  return new TrFacesMessage(summary,
-                          detail,
-                          TrFacesMessage.SEVERITY_ERROR);
-}
-
-/**
- * Used for the converters and validators we provide which all have the form
- *
- * {0} - label
- * {1} - string value
- * {2} - extra param
- * {3} - extra param
- */
-function _createCustomFacesMessage(
-  summary,
-  detail,
-  label,
-  value,
-  param2,
-  param3
-)
-{
-
-  // format the detail error string
-  if (detail != null)
-  {
-    detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
-  }
-
-  return new TrFacesMessage(summary,
-                          detail,
-                          TrFacesMessage.SEVERITY_ERROR);
-}
-
 
 function _getGlobalErrorString(
   input,
@@ -4786,21 +4729,6 @@ function _getEventObj()
  */
 var TrUIUtils = new Object();
 
-/**
- * Remove leading and trailing whitespace
- */
-TrUIUtils.trim = function(
-data)
-{
-  if (data != null && (typeof data) == 'string')
-    return data.replace(TrUIUtils._TRIM_ALL_RE, '');
-
-  return data;
-}
-
-// regular expression to gather whitespace at beginning and end of line
-TrUIUtils._TRIM_ALL_RE = /^\s*|\s*$/g;
-
 
 /**
  * Creates a function instance that will callback the passed in function
@@ -5025,41 +4953,3 @@ TrUIUtils._getStyle = function(element, 
   return '';
 }
 
-/**
- * Check whether a number string can be converted or not.
- *
- * javascript numbers are really doubles, and as such can accurately support 15 digits, see
- * http://en.wikipedia.org/wiki/Double_precision
- *
- * this means in certain cases a long value that will be fine on the server will be
- * rounded by the client converter. To avoid this parse the number string, and don't
- * try to convert on the client if the number of digits is greater than 15.
- *
- * Of course this is an imperfect fix, but since the vast majority of
- * numbers entered are less than 15 digits numbers are still converted on the client most
- * of the time.
- */
-TrUIUtils.isNumberConvertible = function(numberString)
-{
-  if (numberString != null)
-  {
-    var nums = 0;
-
-    for (var i = 0; i < numberString.length; i++)
-    {
-      var charCode = numberString.charCodeAt(i);
-      // the charcode for "0" is 48, the charcode for "9" is 57, so count anything between
these
-      // as a number
-      if (charCode > 47 && charCode < 58)
-      {
-        nums++;
-      }
-    }
-
-    if (nums > 15)
-      return false;
-  }
-
-  return true;
-}
-

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
Tue May  8 23:59:57 2012
@@ -101,7 +101,7 @@ TrLongConverter.prototype.getAsObject = 
   label
   )
 {
-  if(TrUIUtils.isNumberConvertible(numberString))
+  if(TrFormatUtils.isNumberConvertible(numberString))
   {
     return _decimalParse(numberString, 
                          this._message,
@@ -976,7 +976,7 @@ function _decimalParse(
   if (numberString == null)
     return null;
     
-  numberString = TrUIUtils.trim(numberString);
+  numberString = TrFormatUtils.trim(numberString);
   if (numberString.length == 0)
     return null
     

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Tue May  8 23:59:57 2012
@@ -1183,7 +1183,7 @@ TrDateTimeConverter.prototype.getAsObjec
   if (parseString == null)
     return null;
 
-  parseString = TrUIUtils.trim(parseString);
+  parseString = TrFormatUtils.trim(parseString);
   if (parseString.length == 0)
     return null;
 

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Locale.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Locale.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Locale.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Locale.js
Tue May  8 23:59:57 2012
@@ -17,6 +17,122 @@
  *  under the License.
  */
 
+/**
+ * Used for the converters and validators we provide which all have the form
+ *
+ * {0} - label
+ * {1} - string value
+ * {2} - extra param
+ * {3} - extra param
+ */
+function _createFacesMessage(
+  key,
+  label,
+  value,
+  param2,
+  param3
+)
+{
+  var summary = TrMessageFactory.getSummaryString(key);
+  var detail = TrMessageFactory.getDetailString(key);
+  // format the detail error string
+  if (detail != null)
+  {
+    detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
+  }
+  return new TrFacesMessage(summary,
+                          detail,
+                          TrFacesMessage.SEVERITY_ERROR);
+}
+
+
+/**
+ * Used for the converters and validators we provide which all have the form
+ *
+ * {0} - label
+ * {1} - string value
+ * {2} - extra param
+ * {3} - extra param
+ */
+function _createCustomFacesMessage(
+  summary,
+  detail,
+  label,
+  value,
+  param2,
+  param3
+)
+{
+
+  // format the detail error string
+  if (detail != null)
+  {
+    detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
+  }
+
+  return new TrFacesMessage(summary,
+                          detail,
+                          TrFacesMessage.SEVERITY_ERROR);
+}
+
+
+var TrFormatUtils = new Object();
+
+/**
+ * Remove leading and trailing whitespace
+ */
+TrFormatUtils.trim = function(
+data)
+{
+  if (data != null && (typeof data) == 'string')
+    return data.replace(TrFormatUtils._TRIM_ALL_RE, '');
+
+  return data;
+}
+
+// regular expression to gather whitespace at beginning and end of line
+TrFormatUtils._TRIM_ALL_RE = /^\s*|\s*$/g;
+
+/**
+ * Check whether a number string can be converted or not.
+ *
+ * javascript numbers are really doubles, and as such can accurately support 15 digits, see
+ * http://en.wikipedia.org/wiki/Double_precision
+ *
+ * this means in certain cases a long value that will be fine on the server will be
+ * rounded by the client converter. To avoid this parse the number string, and don't
+ * try to convert on the client if the number of digits is greater than 15.
+ *
+ * Of course this is an imperfect fix, but since the vast majority of
+ * numbers entered are less than 15 digits numbers are still converted on the client most
+ * of the time.
+ */
+TrFormatUtils.isNumberConvertible = function(numberString)
+{
+  if (numberString != null)
+  {
+    var nums = 0;
+
+    for (var i = 0; i < numberString.length; i++)
+    {
+      var charCode = numberString.charCodeAt(i);
+      // the charcode for "0" is 48, the charcode for "9" is 57, so count anything between
these
+      // as a number
+      if (charCode > 47 && charCode < 58)
+      {
+        nums++;
+      }
+    }
+
+    if (nums > 15)
+      return false;
+  }
+
+  return true;
+}
+
+
+
 var _digits;
 var _decimalSep;
 var _groupingSep;

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
Tue May  8 23:59:57 2012
@@ -219,7 +219,7 @@ TrNumberConverter.prototype.getAsObject 
   label
   )
 {
-  numberString = TrUIUtils.trim(numberString);
+  numberString = TrFormatUtils.trim(numberString);
   
   if(this._isConvertible(numberString))
   {
@@ -333,7 +333,7 @@ TrNumberConverter.prototype._isConvertib
     return false;
 
   // check other common criteria as well.
-  return TrUIUtils.isNumberConvertible(numberString);   
+  return TrFormatUtils.isNumberConvertible(numberString);   
 
 }
 

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/javascriptmap.properties
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/javascriptmap.properties?rev=1335840&r1=1335839&r2=1335840&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/javascriptmap.properties
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/resources/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/javascriptmap.properties
Tue May  8 23:59:57 2012
@@ -15,12 +15,12 @@
 #    specific language governing permissions and limitations
 #    under the License.
 
-CharSets=Common
-CoreFormat=Common
+CharSets=CoreFmt
+CoreFormat=CoreFmt
 DateField=Common
 DateFieldFormat=Common
-DateFormat=Common
-Locale=Common
+#DateFormat=Common
+#Locale=Common
 #LovInput=Common
 #
 #MarlinCore split into 3 javascript files
@@ -41,7 +41,7 @@ TableProxy=Common
 
 ColorField=Common
 ColorFieldFormat=Common
-ColorFormat=Common
+#ColorFormat=Common
 DiagrammerLib=Common
 Shuttle=Common
 RichTextEditor=Common



Mime
View raw message