myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r568222 - in /myfaces/trinidad/trunk/trinidad: trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ trinidad-impl/src/main/javascript/META-INF/...
Date Tue, 21 Aug 2007 18:08:58 GMT
Author: awiner
Date: Tue Aug 21 11:08:57 2007
New Revision: 568222

URL: http://svn.apache.org/viewvc?rev=568222&view=rev
Log:
TRINIDAD-96: Making client validation code incremental, step 4
- Get rid of "Global Message Index" API - the global message is attached directly to the validator
function
  without an intermediate index
- For inline validation, the error title and format were unused, so don't send them to the
client in the first place

Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/FormData.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js

Modified: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/FormData.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/FormData.java?rev=568222&r1=568221&r2=568222&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/FormData.java
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/FormData.java
Tue Aug 21 11:08:57 2007
@@ -26,8 +26,6 @@
     String targetId,
     String label);
 
-  abstract public Integer addGlobalMessageFormat(RenderingContext rc);
-
   abstract public void addNeededValue(String name);
 
   abstract public void addRenderedValue(String name);

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java?rev=568222&r1=568221&r2=568222&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
Tue Aug 21 11:08:57 2007
@@ -92,17 +92,6 @@
     labelMap.put(targetId, label);
   }
 
-  @Override
-  public Integer addGlobalMessageFormat(
-    RenderingContext rc)
-  {
-    String format = rc.getSkin().getTranslatedString(rc.getLocaleContext(),  
-                                                     _GLOBAL_FORMAT_KEY);
-    return _addErrorFormat(format);
-  }
-  
-
-
   public Map<String, String> getLabelMap(
     boolean  createIfNecessary
     )
@@ -777,7 +766,5 @@
     public Object             converter;
   }
 
-
-  static private final String _GLOBAL_FORMAT_KEY = "af_messages.GLOBAL_MESSAGE_FORMAT";
   static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(CoreFormData.class);
 }

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java?rev=568222&r1=568221&r2=568222&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
Tue Aug 21 11:08:57 2007
@@ -446,13 +446,12 @@
   //     3: converter (or (void 0) if omitted) - index into Validations array
   //     4: validator array - array of integers, each index into Validations
   //     TODO: turn into a Map of clientId to 4 entries
+  //     TODO: consider passing "immediate"
   //  - Validator function:
   //     TODO: don't render for PPR.
-  //     TODO: don't pass index of global message format - just pass the message
-  //          and delete addGlobalMessageFormat() API
   //  - Label map: clientId to label
   //     TODO: inline into Validators array
-  //  - _Formats array: now used only for required messages + "global"
+  //  - _Formats array: now used only for required messages
   //  TODO:
   //    Make one monster function of the form:
   //   TrPage.prototype._addValidators(
@@ -498,10 +497,12 @@
     }
 
     // TODO - when there are immediate components validate only those on the
-    // client?
+    // client?  Or consider simply treating immediate components
+    // as if they were non-immediate on the client
+    
     // When there is an immediate component do server side validation,
-    // see bug 4697440 CLIENT VALIDATION HANDLES
-    //                 EDITABLEVALUEHOLDER IMMEDIATE INCORRECTLY
+    // Before had bug where client-side validation ignored
+    // all immediate components!?!
     boolean hasImmediateComponent = fData.hasImmediateComponent();
 
     RequestContext rc = RequestContext.getCurrentInstance();
@@ -671,20 +672,32 @@
     else
     {
       writer.writeText("Validator(f,s){return ", null);
-      
-      if (rc.getClientValidation() == RequestContext.ClientValidation.INLINE)
+     
+      boolean isInline =
+        (rc.getClientValidation() == RequestContext.ClientValidation.INLINE);
+
+      if (isInline)
         writer.writeText("_validateInline(f,s,_", null);
       else
         writer.writeText("_validateAlert(f,s,_", null);
           
       writer.writeText(jsID, null);
-      writer.writeText("_Validators,", null);
-      Integer globalFormatIndex = fData.addGlobalMessageFormat(arc);
-      writer.writeText(globalFormatIndex, null);
-      writer.writeText(",\"", null);
-      writer.writeText(XhtmlUtils.escapeJS(
-          arc.getTranslatedString("af_form.SUBMIT_ERRORS")), null);
-      writer.writeText("\");}", null);
+      writer.writeText("_Validators", null);
+      // The _validateAlert() function needs extra arguments
+      // for the "global format" and error title
+      if (!isInline)
+      {
+        writer.writeText(",\"", null);
+        writer.writeText(XhtmlUtils.escapeJS(
+            arc.getTranslatedString(_GLOBAL_FORMAT_KEY)), null);
+        writer.writeText("\",\"", null);
+
+        writer.writeText(XhtmlUtils.escapeJS(
+            arc.getTranslatedString("af_form.SUBMIT_ERRORS")), null);
+        writer.writeText("\"", null);
+      }
+
+      writer.writeText(");}", null);
     }
 
     //
@@ -1137,6 +1150,9 @@
   private PropertyKey _defaultCommandKey;
   private PropertyKey _onsubmitKey;
   private PropertyKey _targetFrameKey;
+
+  static private final String _GLOBAL_FORMAT_KEY =
+    "af_messages.GLOBAL_MESSAGE_FORMAT";
 
   // -= Simon Lessard =-
   // FIXME: Nothing in this class is logged as of 2006-08-03

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=568222&r1=568221&r2=568222&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Tue Aug 21 11:08:57 2007
@@ -1182,11 +1182,11 @@
   form,
   source,
   validators,
-  globalMessageIndex,
+  globalMessage,
   errorTitle
   )
 {
-  var failureMap = _multiValidate(form, source,  validators, globalMessageIndex);
+  var failureMap = _multiValidate(form, source,  validators);
   
   if (failureMap.length == 0)
     return true;
@@ -1225,7 +1225,7 @@
       var facesMessage = messages[j];
     
       var errorString = _getGlobalErrorString(currInput, 
-                          globalMessageIndex, 
+                          globalMessage, 
                           facesMessage.getDetail(),
                           label);   
     
@@ -1248,12 +1248,10 @@
 function _validateInline(
   form,
   source,
-  validators,
-  globalMessageIndex,
-  errorTitle
+  validators
   )
 {
-  var failureMap = _multiValidate(form, source,  validators, globalMessageIndex);
+  var failureMap = _multiValidate(form, source,  validators);
   
   var noFailures = true;
 
@@ -2285,8 +2283,7 @@
 function _multiValidate(
   form,
   source,
-  validators,
-  globalMessageIndex
+  validators
   )
 {
   // Initialise the return map.
@@ -2536,29 +2533,20 @@
 
 function _getGlobalErrorString(
   input,
-  formatIndex,
+  errorFormat,
   errorString,
   label
   )
 {
   var form = _getForm(input);  
-  // get the list of different error formats
-  var errorFormats = window["_" + _getJavascriptId(form.name) + "_Formats"];
-
-  if (errorFormats)
+  if (errorFormat && label != null)
   {
-    // get the appropriate error format
-    var errorFormat = errorFormats[formatIndex];
-
-    if (errorFormat && label != null)
-    {
-      return _formatErrorString(errorFormat,
-                               {
-                                 "0":label,
-                                 "1":errorString
-                               });
-    }
-  }   
+    return _formatErrorString(errorFormat,
+                             {
+                               "0":label,
+                               "1":errorString
+                             });
+  }
   
   return errorString;  
 }                



Mime
View raw message