incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r433532 - in /incubator/adffaces/trunk/trinidad: trinidad-demo/src/main/webapp/jsLibs/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/x...
Date Tue, 22 Aug 2006 05:51:01 GMT
Author: awiner
Date: Mon Aug 21 22:51:00 2006
New Revision: 433532

URL: http://svn.apache.org/viewvc?rev=433532&view=rev
Log:
Merge patches for ADFFACES-126 and ADFFACES-128: some client-side validation API cleanup from
Gabrielle Crawford

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/passwordValidator.js
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/ssnConverter.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/RegExpValidator.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CharSets.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorField.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFieldFormat.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateField.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFieldFormat.js
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/passwordValidator.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/passwordValidator.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/passwordValidator.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/passwordValidator.js
Mon Aug 21 22:51:00 2006
@@ -35,7 +35,7 @@
   }
   
   if (messageKey != null)
-    return new ValidatorException(this._messages[messageKey]);
+    throw new ValidatorException(this._messages[messageKey]);
     
   return null;
 }
@@ -45,50 +45,3 @@
 PasswordValidator.prototype = new Validator();
 PasswordValidator.prototype.validate = passwordValidate;
 PasswordValidator.NUMBER = 'N'; 
-/*
- * Copyright  2000-2006 The Apache Software Foundation.
- *
- * Licensed 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 KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-function passwordValidate(value)
-{
-  if (!value)
-    return null;
-    
-  if (value == '******')
-    return null;
-    
-  var messageKey = PasswordValidator.NUMBER;
-  
-  for (var i = 0; i < value.length; i++)
-  {
-    var subValue = value.substring(i, i+1);
-    
-    if (!isNaN(parseInt(subValue)))
-    {
-      messageKey = null;break;
-    }
-  }
-  
-  if (messageKey != null)
-    return new ValidatorException(this._messages[messageKey]);
-    
-  return null;
-}
-
-function PasswordValidator(messages)
-  {this._messages = messages;}
-PasswordValidator.prototype = new Validator();
-PasswordValidator.prototype.validate = passwordValidate;
-PasswordValidator.NUMBER = 'N'; 
\ No newline at end of file

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/ssnConverter.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/ssnConverter.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/ssnConverter.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/jsLibs/ssnConverter.js
Mon Aug 21 22:51:00 2006
@@ -42,64 +42,10 @@
   }
  if (messageKey!=null && this._messages!=null)
  {
-   return new ConverterException(this._messages[messageKey]);
+   throw new ConverterException(this._messages[messageKey]);
  }
- return null;}
-function SSNConverter(messages)
-  {this._messages = messages;}
-SSNConverter.prototype = new Converter();
-SSNConverter.prototype.getAsString = ssnGetAsString;
-SSNConverter.prototype.getAsObject = ssnGetAsObject;
-SSNConverter.SHORT = 'S';
-SSNConverter.LONG  = 'L';
-SSNConverter.NOT   = 'N';
-/*
- * Copyright  2000-2006 The Apache Software Foundation.
- *
- * Licensed 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 KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-function ssnGetAsString(value)
-{
-  return value.substring(0,3) + '-' + value.substring(3,5) + '-' + value.substring(5);
+ return null;
 }
-
-function ssnGetAsObject(value)
-{ 
-  if (!value)return null;
-  var len=value.length;
-  var messageKey = SSNConverter.NOT;
-  if (len < 9 )
-    messageKey = SSNConverter.SHORT;
-  else if (len > 11)
-    messageKey = SSNConverter.LONG;
-  else if (len == 9)
-  { if (!isNaN(value))
-      return value;
-  }
-  else if (len == 11 && value.charAt(3) == '-' && 
-            value.charAt(6) == '-')
-  {
-    var result = value.substring(0,3) + value.substring(4,6) + 
-                value.substring(7);
-    if (!isNaN(result))
-      return result;
-  }
- if (messageKey!=null && this._messages!=null)
- {
-   return new ConverterException(this._messages[messageKey]);
- }
- return null;}
 function SSNConverter(messages)
   {this._messages = messages;}
 SSNConverter.prototype = new Converter();
@@ -107,4 +53,4 @@
 SSNConverter.prototype.getAsObject = ssnGetAsObject;
 SSNConverter.SHORT = 'S';
 SSNConverter.LONG  = 'L';
-SSNConverter.NOT   = 'N';
\ No newline at end of file
+SSNConverter.NOT   = 'N';

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
Mon Aug 21 22:51:00 2006
@@ -147,6 +147,15 @@
     int size = 19 + patternsArgSize + 19;
     StringBuffer sb = new StringBuffer(size);
 
+    StringBuffer patterns = new StringBuffer();
+    String[] setPatterns = getPatterns();
+    for (int i = 0; i < setPatterns.length ; i++)
+    {
+      patterns.append(setPatterns[i]);
+      patterns.append(' ');
+    }
+    String patternsString = patterns.toString();
+
     sb.append("new RGBColorFormat(");
 
     _appendPatternsArg(sb);
@@ -162,7 +171,8 @@
     
     String msg = _getConvertMessageDetail(context);
     sb.append(XhtmlLafUtils.escapeJS(msg)); 
-
+    sb.append("','");
+    sb.append(XhtmlLafUtils.escapeJS(patternsString));
     sb.append("')");
 
     return sb.toString();
@@ -238,16 +248,9 @@
   {
     String convMsgDet = getConvertMessageDetail();
 
-    StringBuffer patterns = new StringBuffer();
-    String[] setPatterns = getPatterns();
-    for (int i = 0; i < setPatterns.length ; i++)
-    {
-      patterns.append(setPatterns[i]);
-      patterns.append(' ');
-    }
-    
+   
     // will get replaced in javascript
-    Object[] params = new Object[] {"{0}", "{1}", patterns.toString()};
+    Object[] params = new Object[] {"{0}", "{1}", "{2}"};
 
     return MessageFactory.getMessage(context, CONVERT_MESSAGE_ID,
                                            convMsgDet, params).getDetail();
@@ -255,5 +258,5 @@
   
   private static final Collection<String> _IMPORT_NAMES = Collections.singletonList(
"ColorFormat()" );
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(ColorConverter.class);
-  private static final Object _PATTERN_WRITTEN_KEY = new Object();
+  private static final Object _PATTERN_WRITTEN_KEY = "org.apache.myfaces.trinidadinternal.convert.ColorConverter._PATTERN_WRITTEN";
 }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
Mon Aug 21 22:51:00 2006
@@ -33,7 +33,6 @@
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 import org.apache.myfaces.trinidadinternal.renderkit.RenderingContext;
-import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
 import javax.faces.component.ValueHolder;
 import javax.faces.convert.Converter;
@@ -155,9 +154,6 @@
 
     if (clientId != null)
     {
-      // BUG 2024773
-      FormRenderer.addPatternMapping( clientId,
-                                      getExample(context));
       // =-=AEW Only if Javascript...
       // -= Simon Lessard =-
       // FIXME: JSF 1.2 specifies <String, Object>
@@ -218,18 +214,21 @@
 
       if (pattern == null)
         pattern = getSecondaryPattern();
-
-      Object[] params = new Object[] {"{0}", "{1}", getExample(context)};
+      Object[] params = new Object[] {"{0}", "{1}", "{2}"};
       String msg = getParseErrorMessage(context, component,
                                         pattern, params).getDetail();
       String message = XhtmlLafUtils.escapeJS(msg);
-                                                  
-      StringBuffer outBuffer = new StringBuffer(30 + jsPattern.length() +
-                                                message.length());
+      String exampleString = XhtmlLafUtils.escapeJS(getExample(context));
+      
+      StringBuffer outBuffer = new StringBuffer(33 + jsPattern.length() +
+                                                message.length() +
+                                                exampleString.length());
       outBuffer.append("new SimpleDateFormat("); // 21
       outBuffer.append(jsPattern);               // jsPattern.length
       outBuffer.append(",null,'");               // 7
-      outBuffer.append(message);                 // message.length
+      outBuffer.append(message);                 // message.length/
+      outBuffer.append("','");                   // 3
+      outBuffer.append(exampleString);           // exampleString.length
       outBuffer.append("')");                    // 2
 
       return outBuffer.toString();
@@ -511,7 +510,7 @@
 
   // RenderingContext key indicating the _dateFormat object
   // has been created
-  private static final Object _PATTERN_WRITTEN_KEY = new Object();
+  private static final Object _PATTERN_WRITTEN_KEY = "org.apache.myfaces.trinidadinternal.convert.DateTimeConverter._PATTERN_WRITTEN";
 
   // String indicating that NO_JS_PATTERN is available
   private static final String _NO_JS_PATTERN = new String();

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
Mon Aug 21 22:51:00 2006
@@ -124,35 +124,6 @@
     return _labelMap;
   }
 
-
-
-  public Map<String, String> getPatternMap(
-    boolean createIfNecessary
-    )
-  {
-    if ((_patternMap == null) && createIfNecessary)
-    {
-      _patternMap = new HashMap<String, String>();
-    }
-
-    return _patternMap;
-  }
-
-  public void addPattern(
-    String targetId,
-    String pattern
-    )
-  {
-
-    if (targetId == null || pattern == null)
-      return;
-
-    Map<String, String> patternMap = getPatternMap(true);
-
-    patternMap.put(targetId, pattern);
-  }
-
-
   /**
    *
    * @todo get rid of servletRequestParameters reference
@@ -798,10 +769,6 @@
 
   // List of reset calls
   private List<String> _resetCallsList = null;
-
-  // maps patterns to id's
-  private Map<String, String> _patternMap;
-
 
   private String _formName = null;
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
Mon Aug 21 22:51:00 2006
@@ -676,55 +676,7 @@
 
         writer.writeText("};", null);
 
-      }
-
-      // =-= jrf: optimize pattern reuse?
-      // BUG 2024773
-
-      Map<String, String> patternMap = fData.getPatternMap(false);
-
-      if (patternMap != null)
-      {
-        writer.writeText("var _", null);
-        writer.writeText(jsID, null);
-        writer.writeText("_Patterns={", null);
-
-        boolean firstPattern = true;
-
-        for (int i = 0; i < inputCount; i++)
-        {
-          String currID = inputList.get(i);
-
-          // remove the ID entry to prevent multiple labels from
-          // being written
-          String currPattern = patternMap.remove(currID);
-
-          if (currPattern != null)
-          {
-            if (firstPattern)
-            {
-              firstPattern = false;
-            }
-            else
-            {
-              // write the separator every time except the first time
-              writer.writeText(",", null);
-            }
-
-            // write the ID of the validated field as the key
-            writer.writeText("\'", null);
-            writer.writeText(currID, null);
-            writer.writeText("\':\'", null);
-
-            // write the label of the validated field as the value
-            writer.writeText(XhtmlUtils.escapeJS(currPattern), null);
-            writer.writeText("\'", null);
-          }
-        }
-
-        writer.writeText("};", null);
-
-      }
+      }    
     }
 
     //
@@ -888,23 +840,6 @@
   }
 
 
-  /**
-   * Add a mapping of an input element ID to a pattern String. If there is a
-   * client-side error regarding the form element with the given ID, the given
-   * pattern will be used in the client-side error message.
-   * @param targetID the ID of the form element
-   * @param pattern the pattern that describes the form element
-   * <code>targetID</code>
-   */
-  public static void addPatternMapping(
-    String           targetID,
-    String           pattern
-    )
-  {
-    FormData fData = RenderingContext.getCurrentInstance().getFormData();
-    fData.addPattern(targetID, pattern);
-  }
-
   public static String getDefaultCommandId(
   )
   {
@@ -1059,10 +994,8 @@
 
   /**
    * Render each "needed" FormValue that hasn't already
-   * been rendered.  Called by FormRenderer.postrender().
-   * @param formName the name of the form. Only hidden form values "needed"
-   *  by this form are rendered.
-   * @see FormRenderer#postrender(RenderingContext, UINode)
+   * been rendered.  Called by FormRenderer.postrender(). 
+   * @see FormRenderer#encodeEnd(FacesContext,RenderingContext, UIComponent, FacesBean)
    */
   static private void _renderNeededValues(
     FacesContext        context,

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/RegExpValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/RegExpValidator.java?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/RegExpValidator.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/RegExpValidator.java
Mon Aug 21 22:51:00 2006
@@ -21,11 +21,9 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.MessageFactory;
 
 import org.apache.myfaces.trinidad.validator.ClientValidator;
-import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
 
 public class RegExpValidator
@@ -48,9 +46,6 @@
    */
   public String getClientScript(FacesContext context, UIComponent component)
   {
-    // since we are instance of InternalClientValidator this method will not
-    // be invoked. see xhtml.FormRenderer#_addOnSubmitValidator(,,,,)
-    // getLibKey() will serve the purpose to load the necessary script
     return null;
   }
 
@@ -62,21 +57,13 @@
    * constructor of the javascript Validator object
    * returned by getClientScript().
    *
-   * @todo - Though component or client id could have been null in call to
-   * getClientScript() - we are still rendering the script here.
-   * Probaly we should avoid null check for components totally and allow to see
-   * how and where we get to set it rather than loggin for now.
    */
   public String getClientValidation(FacesContext context, UIComponent component)
   {
-    String clientId = component.getClientId(context);
-
-    if (clientId != null)
-    {
-      FormRenderer.addPatternMapping( clientId, getPattern());
-    }
-    
+   
     String jsPattern = XhtmlUtils.escapeJS(getPattern());
+    
+    
     String esNoMatchMsgPattern = XhtmlUtils.escapeJS(
                   _getNoMatchMessageDetail(context));
 
@@ -87,11 +74,9 @@
 
     outBuffer.append("new RegExpFormat('"); // 18
     outBuffer.append(jsPattern);
-    outBuffer.append("',");                 //  2
-    outBuffer.append("{NM:'");              //  5
+    outBuffer.append("',{NM:'");            //  7
     outBuffer.append(esNoMatchMsgPattern);
-    outBuffer.append("'}");                 //  2
-    outBuffer.append(")");                  //  1
+    outBuffer.append("'})");                // 3
 
     return outBuffer.toString();
   }
@@ -110,7 +95,7 @@
   private String _getNoMatchMessageDetail(
     FacesContext context)
   {
-    String noMatchMsg = getNoMatchMessageDetail();
+    String noMatchMsg = getNoMatchMessageDetail(); 
     Object[] params = new Object[] {"{0}", "{1}", "{2}"};
 
     String noMatchDetMsg
@@ -121,12 +106,6 @@
     return noMatchDetMsg;
   }
 
-  // -= Simon Lessard =-
-  // TODO: Nothing is logged in this class as of 2006-08-04
-  @SuppressWarnings("unused")
-  private static final TrinidadLogger _LOG  = TrinidadLogger.createTrinidadLogger(
-     RegExpValidator.class);
-     
 
   private static final Collection<String> _IMPORT_NAMES = Collections.singletonList(
"RegExpFormat()" );     
 }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CharSets.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CharSets.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CharSets.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CharSets.js
Mon Aug 21 22:51:00 2006
@@ -48,7 +48,7 @@
    
     if (length < 0)
     {
-      return new ValidatorException(this._messages[this.LF]);     
+      throw new ValidatorException(this._messages[this.LF]);     
     }
 
     i++;
@@ -96,7 +96,7 @@
 
     if (length < 0)
     {
-      return new ValidatorException(this._messages[this.LF]);            
+      throw new ValidatorException(this._messages[this.LF]);            
     }
 
     i++;
@@ -128,7 +128,7 @@
 {
   if (this._length < parseString.length)
   {
-    return new ValidatorException(this._messages[this.LF]);    
+    throw new ValidatorException(this._messages[this.LF]);    
   }
 
   return parseString;

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorField.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorField.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorField.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorField.js
Mon Aug 21 22:51:00 2006
@@ -32,17 +32,24 @@
 {
   var cff = _getColorFieldFormat(colorField);
   var swatchID = colorField.name + "$sw";
-  var value = (void 0);
+  var value = null;
   var swatch = _getElementById(document, swatchID);
 
   if (swatch != (void 0))
   {
+    var converterError = false;
     if (colorField.value != "")
-    {
-      value = cff.getAsObject(colorField.value);
+    {      
+      try
+      {
+        value = cff.getAsObject(colorField.value);
+      }
+      catch (e)
+      {
+        // no-op
+      }
     }
-
-    if (!_instanceof(value, ConverterException))
+    if (value != null)
     {
       if (value.alpha == 0)
       {
@@ -280,17 +287,23 @@
   if (colorField.value != "")
   {
     var format = _getColorFieldFormat(colorField);
-    var color = format.getAsObject(colorField.value);
-
-    if (!_instanceof(color, ConverterException))
+    try
     {
-      destination += "&value=";
+      var color = format.getAsObject(colorField.value);
+      if (color != null)
+      {
+        destination += "&value=";
 
-      // escape due to '#' in color code, or possible spaces in _cfTrans
-      if (color.alpha == 0)
-        destination += escape(_cfTrans);
-      else
-        destination += escape(new RGBColorFormat(pattern).getAsString(color));
+        // escape due to '#' in color code, or possible spaces in _cfTrans
+        if (color.alpha == 0)
+          destination += escape(_cfTrans);
+        else
+          destination += escape(new RGBColorFormat(pattern).getAsString(color));
+      }
+    }
+    catch (e)
+    {
+      // no-op 
     }
   }
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFieldFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFieldFormat.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFieldFormat.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFieldFormat.js
Mon Aug 21 22:51:00 2006
@@ -35,10 +35,15 @@
 
   if (colorField.value != "")
   {
-    var value = format.getAsObject(colorField.value);
-
-    if (!_instanceof(value, ConverterException))
-      colorField.value = format.getAsString(value);
+    try
+    {
+      var value = format.getAsObject(colorField.value);
+      if (value != null)
+        colorField.value = format.getAsString(value);
+    }
+    catch(e)
+    {
+    }      
   }
 }
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
Mon Aug 21 22:51:00 2006
@@ -24,8 +24,8 @@
   formatColor)
 {
   //pu: Return undefined string for an undefined Color.
-  if (formatColor == (void 0))
-    return (void 0);
+  if (formatColor == null)
+    return null;
 
   // return localized transparent text for transparent color
   if (formatColor.alpha == 0)
@@ -70,12 +70,19 @@
     var i;
     for (i = 0; i < pattern.length; i++)
     {
-      var color = _rgbColorParseImpl(parseString,
+      try{
+        var color = _rgbColorParseImpl(parseString,
                                      pattern[i],
                                      this._msg);
-                                     
-      if (!(_instanceof(color, ConverterException)) || i == pattern.length-1)
         return color;
+      }
+      catch (e)
+      {
+        // if we're not on the last pattern try the next one, 
+        // but if we're on the last pattern, throw the exception
+        if ( i == pattern.length-1)
+          throw e;
+      }
     }
   }
 }
@@ -100,7 +107,7 @@
   {
     if (parseString.length != parseContext.currIndex)
     {
-      return parseContext.parseException;
+      throw parseContext.parseException;
     }
 
     return parsedColor;
@@ -108,7 +115,7 @@
   else
   {
     // failure
-    return parseContext.parseException;
+    throw parseContext.parseException;
   }
 }
 
@@ -128,7 +135,7 @@
   var formatLength = formatPattern.length;
   var inQuote      = false;
   var kindCount    = 0;
-  var lastChar     = void 0;
+  var lastChar     = null;
   var startIndex   = 0;
   
   for (var i = 0; i < formatLength; i++)
@@ -163,7 +170,7 @@
         }
         
         kindCount = 0;
-        lastChar  = void 0;
+        lastChar  = null;
       }
       else
       {
@@ -192,7 +199,7 @@
           }
           
           kindCount = 0;
-          lastChar  = void 0;
+          lastChar  = null;
         }
         
         if (currChar == '\'')
@@ -328,7 +335,7 @@
     {
       case 'r': // decimal red component (0-255)
         parsedColor.red = _cfoAccumulateNumber(parseContext, charCount, 3, 10);
-        if (parsedColor.red == (void 0))
+        if (parsedColor.red == null)
         {
           return false;
         }
@@ -336,7 +343,7 @@
       
       case 'g': // decimal green component (0-255)
         parsedColor.green = _cfoAccumulateNumber(parseContext, charCount, 3, 10);
-        if (parsedColor.green == (void 0))
+        if (parsedColor.green == null)
         {
           return false;
         }
@@ -344,7 +351,7 @@
       
       case 'b': // decimal blue component (0-255)
         parsedColor.blue = _cfoAccumulateNumber(parseContext, charCount, 3, 10);
-        if (parsedColor.blue == (void 0))
+        if (parsedColor.blue == null)
         {
           return false;
         }
@@ -352,7 +359,7 @@
       
       case 'a': // decimal alpha component (0-255)
         parsedColor.alpha = _cfoAccumulateNumber(parseContext, charCount, 3, 10);
-        if (parsedColor.alpha == (void 0))
+        if (parsedColor.alpha == null)
         {
           return false;
         }
@@ -360,7 +367,7 @@
       
       case 'R': // hex red component (0x00-0xff)
         parsedColor.red = _cfoAccumulateNumber(parseContext, charCount, 2, 16);
-        if (parsedColor.red == (void 0))
+        if (parsedColor.red == null)
         {
           return false;
         }
@@ -368,7 +375,7 @@
       
       case 'G': // hex green component (0x00-0xff)
         parsedColor.green = _cfoAccumulateNumber(parseContext, charCount, 2, 16);
-        if (parsedColor.green == (void 0))
+        if (parsedColor.green == null)
         {
           return false;
         }
@@ -376,7 +383,7 @@
       
       case 'B': // hex blue component (0x00-0xff)
         parsedColor.blue = _cfoAccumulateNumber(parseContext, charCount, 2, 16);
-        if (parsedColor.blue == (void 0))
+        if (parsedColor.blue == null)
         {
           return false;
         }
@@ -384,7 +391,7 @@
       
       case 'A': // hex alpha component (0x00-0xff)
         parsedColor.alpha = _cfoAccumulateNumber(parseContext, charCount, 2, 16);
-        if (parsedColor.alpha == (void 0))
+        if (parsedColor.alpha == null)
         {
           return false;
         }
@@ -493,7 +500,7 @@
   else
   {
     // no number at this location
-    return (void 0);
+    return null;
   }
 }
 
@@ -513,7 +520,7 @@
   //
   // pad out any number strings that are too short
   //
-  if (minDigits != (void 0))
+  if (minDigits != null)
   {    
     var addedDigits = minDigits - stringNumber.length;
   
@@ -527,7 +534,7 @@
   //
   // truncate any number strings that are too long
   //
-  if (maxDigits != (void 0))
+  if (maxDigits != null)
   {
     var extraDigits = stringNumber.length - maxDigits;
     
@@ -547,14 +554,24 @@
 function RGBColorFormat(
   pattern,
   allowsTransparent,
-  msg)
+  msg,
+  patternsString)
 {
   // for debugging
   this._class = "RGBColorFormat";
   this._allowsTransparent = allowsTransparent;
-  this._msg = msg;
+  // format the error string
+  //   {2}  legal patterns
+  
+  if (msg != null)
+  {
+    this._msg = _formatErrorString(msg,
+                                   { 
+                                     "2":patternsString
+                                   });
+  }
   
-  if (pattern != (void 0))
+  if (pattern != null)
   {
     if (typeof(pattern) == "string" ) 
       pattern = [pattern];
@@ -576,7 +593,7 @@
   // for debugging
   this._class = "Color";
   
-  if (alpha == (void 0))
+  if (alpha == null)
     alpha = 0xff;
 
   this.red   = (red & 0xff);

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Mon Aug 21 22:51:00 2006
@@ -2412,12 +2412,11 @@
 
         var converterInfo = validators[i+3];
 
-        // void out the converterError var for each input, otherwise nothing
+        // set the converterError var to false for each input, otherwise nothing
         // after the first conversion error is validated
-        var converterError = (void 0);
-        var converterFormat = (void 0);
+        var converterError = false;
 
-        if ( converterInfo != (void 0))
+        if ( converterInfo != null)
         {
 
           // do the conversion if this element has a value
@@ -2426,57 +2425,44 @@
           {
             // evaluate the converter
             var converterConstructor = validations[converterInfo];
-            var converterResult = void(0);
 
             if (converterConstructor)
             {
-              var converter = void(0);
-              converter = eval(converterConstructor);
-              converterResult = converter.getAsObject(value);
-
-              if (_instanceof(converterResult,  window["ConverterException"]))
-              {
-                converterError = converterResult;
+              var converter = eval(converterConstructor);
+              try{
+                value = converter.getAsObject(value);
               }
-            }
-
-            if (converterError)
-            {
-              // move the focus back to the first failed field
-              if (firstFailure)
+              catch (e)
               {
-
-                _setFocus(currInput);
-
-                firstFailure = false;
-              }
-
-              // get the formatted error string for the current input
-              var errorString1 = _getErrorString(currInput,
-                                                 null,
-                                                converterError);
-
-              if (errorString1)
-              {                         
-                errorString1 = _getGlobalErrorString(currInput, 
-                                                     globalMessageIndex, 
-                                                     errorString1);                     
                   
-                failures += '\n' + errorString1;
+                converterError = true; 
+                // move the focus back to the first failed field
+                if (firstFailure)
+                {
+  
+                  _setFocus(currInput);
+  
+                  firstFailure = false;
+                }
+  
+                // get the formatted error string for the current input
+                var errorString1 = _getErrorString(currInput,
+                                                   null,
+                                                   e);
+  
+                if (errorString1)
+                {                         
+                  errorString1 = _getGlobalErrorString(currInput, 
+                                                       globalMessageIndex, 
+                                                       errorString1);                   
                     
+                  failures += '\n' + errorString1;
+                }
               }
             }
-            else
-            {
-              // The value passed to the validators is now the converted value
-              value = converterResult;
-
-              if (converterFormat != void(0))
-                currInput.value = converterFormat;
-            }
           }
         }
 
 
-        if ( ! converterError)
+        if ( converterError == false)
         {
           var validatorInfo = validators[i+4];
 
@@ -2491,43 +2477,37 @@
               // evaluate the validator
               var validatorConstructor = validations[validatorInfo[j]];
 
-              var validationError = (void 0);
-
               if (validatorConstructor)
               {
-                var validator = (void 0);
-                var validationResult = (void 0);
+                var validator = eval(validatorConstructor);
 
-                validator = eval(validatorConstructor);
-                validationResult = validator.validate(value);
-                if (_instanceof(validationResult,  window["ValidatorException"]))
-                  validationError = validationResult;
-
-              }
-
-              if (validationError)
-              {
-                // move the focus back to the first failed field
-                if (firstFailure)
-                {
-
-                  _setFocus(currInput);
-
-                  firstFailure = false;
+                try {
+                  validator.validate(value);
                 }
-
-                // get the formatted error string for the current input and
-                // formatIndex
-                var errorString = _getErrorString(currInput,
-                                                  null,
-                                                  validationError);
-
-                if (errorString)
-                {     
-                  errorString = _getGlobalErrorString(currInput, 
-                                                      globalMessageIndex, 
-                                                      errorString);       
-                  failures += '\n' + errorString;
+                catch (e)
+                {
+                  // move the focus back to the first failed field
+                  if (firstFailure)
+                  {
+  
+                    _setFocus(currInput);
+  
+                    firstFailure = false;
+                  }
+  
+                  // get the formatted error string for the current input and
+                  // formatIndex
+                  var errorString = _getErrorString(currInput,
+                                                    null,
+                                                    e);
+  
+                  if (errorString)
+                  {     
+                    errorString = _getGlobalErrorString(currInput, 
+                                                        globalMessageIndex, 
+                                                        errorString);       
+                    failures += '\n' + errorString;
+                  }
                 }
               }
             }
@@ -2826,27 +2806,13 @@
       label = labelMap[_getID(input)];
     }
 
-    // get the mapping of id's to patterns
-    var patternMap = window["_" + _getJavascriptId(form.name) + "_Patterns"];
-
-    var pattern;
-
-    // get the pattern for this input element, if one has been
-    // associated using the ID of the input element
-    if (patternMap)
-    {
-      pattern = patternMap[_getID(input)];
-    }
-
     // format the error string, replacing the following tokens
     //   {0}    the value of the label
     //   {1}    the value of the input element
-    //   {2}    the validation pattern
     var errorString = _formatErrorString(errorFormat,
                                          {
                                            "0":label,
-                                           "1":value,
-                                           "2":pattern
+                                           "1":value
                                          });
     // return the error
     return errorString;

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
Mon Aug 21 22:51:00 2006
@@ -31,7 +31,7 @@
   )
 {
   if (!numberString)
-    return new ConverterException(messages[DecimalFormat.D]);
+    throw new ConverterException(messages[DecimalFormat.D]);
        
 
   // Get LocaleSymbols (from Locale.js)
@@ -42,7 +42,7 @@
     var grouping = symbols.getGroupingSeparator();
     if ((numberString.indexOf(grouping) == 0) ||
         (numberString.lastIndexOf(grouping) ==  (numberString.length - 1)))
-      return new ConverterException(messages[DecimalFormat.D]);
+      throw new ConverterException(messages[DecimalFormat.D]);
 
     // Remove the thousands separator - which Javascript doesn't want to see
     var thousands = new RegExp("\\" + grouping, "g");
@@ -114,9 +114,9 @@
           
           if ((messages == (void 0)) ||
               (messages[messageKey] == (void 0)))
-            return  new ConverterException("Conversion failed, but no appropriate message
found");  // default error format
+            throw  new ConverterException("Conversion failed, but no appropriate message
found");  // default error format
           else
-            return new ConverterException(messages[messageKey]);
+            throw new ConverterException(messages[messageKey]);
         }
         
         return result;
@@ -124,7 +124,7 @@
     }
   }
 
-  return new ConverterException(messages[DecimalFormat.D]);
+  throw new ConverterException(messages[DecimalFormat.D]);
 }
 
 function _decimalGetAsObject(
@@ -181,17 +181,19 @@
   // into the validator is a number, and _decimalParse expects a string.
   numberString = "" + value;
   
-  var returnVal = _decimalParse(numberString, 
+  try
+  {
+    return _decimalParse(numberString, 
                        this._messages,
                        this._maxPrecision,
                        this._maxScale,
                        this._maxValue,
                        this._minValue);
-                       
-  if (_instanceof(returnVal, ConverterException))
-    return new ValidatorException((void 0), returnVal.getFacesMessage());
-  
-  return returnVal;
+  }
+  catch (e)
+  {
+    throw new ValidatorException((void 0), e.getFacesMessage());
+  }
 }
 
 function DecimalValidator(
@@ -230,8 +232,19 @@
     return parseString;
   }
   else
-  {    
-    return new ValidatorException(this._messages[RegExpFormat.NM]);
+  {
+    // format the error string
+    //   {2}    a legal example
+    if (this._messages[RegExpFormat.NM] != null)
+    {
+      this._messages[RegExpFormat.NM] = 
+                  _formatErrorString(this._messages[RegExpFormat.NM],
+                                     { 
+                                       "2":this._pattern
+                                     });
+    }
+
+    throw new ValidatorException(this._messages[RegExpFormat.NM]);
   }
 }
 
@@ -242,7 +255,7 @@
   )
 {  
   this._pattern  = pattern;
-  this._messages = messages
+  this._messages = messages;
   this._class = "RegExpFormat";
 }
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateField.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateField.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateField.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateField.js
Mon Aug 21 22:51:00 2006
@@ -256,10 +256,14 @@
 {
   if (dateField.value != "")
   {
-    var value = _getDateFieldFormat(dateField).getAsObject(dateField.value);
-    
-    if (!_instanceof(value, ConverterException))
+    try{
+      var value = _getDateFieldFormat(dateField).getAsObject(dateField.value);      
       return value;
+    }
+    catch (e)
+    {
+      // no-op
+    }    
   }
 
   return null;

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFieldFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFieldFormat.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFieldFormat.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFieldFormat.js
Mon Aug 21 22:51:00 2006
@@ -32,10 +32,16 @@
 
   if (dateField.value != "")
   {
-    var value = format.getAsObject(dateField.value);
-
-    if (!_instanceof(value, ConverterException))
-      dateField.value = format.getAsString(value);
+    try
+    {
+      var value = format.getAsObject(dateField.value);
+      if (value != null)
+        dateField.value = format.getAsString(value);
+    }
+    catch (e)
+    {
+      // no-op
+    }
   }
 }
 

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=433532&r1=433531&r2=433532&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Mon Aug 21 22:51:00 2006
@@ -74,12 +74,20 @@
     var i;
     for (i = 0; i < pattern.length; i++)
     {
-      var date = _simpleDateParseImpl(parseString,
-                                      pattern[i],
-                                      this._localeSymbols,
-                                      this._msg);
-      if ( !_instanceof(date, ConverterException)|| i == pattern.length-1 )
+      try{
+        var date = _simpleDateParseImpl(parseString,
+                                        pattern[i],
+                                        this._localeSymbols,
+                                        this._msg);
         return date;
+      }
+      catch (e)
+      {
+        // if we're not on the last pattern try the next one, 
+        // but if we're on the last pattern, throw the exception
+        if ( i == pattern.length-1 )
+          throw e;
+      }
     }
   }
 }
@@ -116,7 +124,7 @@
   {
     if (parseString.length != parseContext.currIndex)
     {
-      return parseContext.parseException;
+      throw parseContext.parseException;
     }
 
     // Set the parsed year, if any;  adjust for AD vs. BC
@@ -175,7 +183,7 @@
     // now we check for strictness
     if (!_isStrict(parseContext, parsedTime))
     {
-      return parseContext.parseException;
+      throw parseContext.parseException;
     }
 
     return parsedTime;
@@ -183,7 +191,7 @@
   else
   {
     // failure
-    return parseContext.parseException;
+    throw parseContext.parseException;
   }
 }
 
@@ -1238,12 +1246,22 @@
 function SimpleDateFormat(
   pattern,  
   locale,
-  msg
+  msg,
+  exampleString
   )
 {
   // for debugging
   this._class = "SimpleDateFormat";
-  this._msg = msg;
+  
+  // format the error string
+  //   {2}    a legal example
+  if (msg != null)
+  {
+    this._msg = _formatErrorString(msg,
+                                   { 
+                                     "2":exampleString
+                                   });
+  }
   
   // save the Locale elements for the specified locale, or client locale
   // if no locale is specified



Mime
View raw message