incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r488333 - /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java
Date Mon, 18 Dec 2006 16:50:11 GMT
Author: matzew
Date: Mon Dec 18 08:50:11 2006
New Revision: 488333

URL: http://svn.apache.org/viewvc?view=rev&rev=488333
Log:
working on client side of length validator

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java?view=diff&rev=488333&r1=488332&r2=488333
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/LengthValidator.java
Mon Dec 18 08:50:11 2006
@@ -16,14 +16,18 @@
 
 package org.apache.myfaces.trinidadinternal.validator;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
 import org.apache.myfaces.trinidad.util.IntegerUtils;
 import org.apache.myfaces.trinidad.validator.ClientValidator;
+import org.apache.myfaces.trinidadinternal.util.JsonUtils;
 
 /**
  * <p>Implementation for <code>java.lang.Long</code> values.</p>
@@ -57,8 +61,16 @@
   {
     String maxStr = IntegerUtils.getString(getMaximum());
     String minStr = IntegerUtils.getString(getMinimum());
-    
-    return _getTrLengthValidator(context, component, maxStr, minStr);
+    String messageDetailMax = this.getMessageDetailMaximum();
+    String messageDetailMin = this.getMessageDetailMinimum();
+    Map<String, String> cMessages = null;
+    if(messageDetailMax != null || messageDetailMin != null)
+    {
+      cMessages = new HashMap<String, String>();
+      cMessages.put("max", messageDetailMax);
+      cMessages.put("min", messageDetailMin);
+    }
+    return _getTrLengthValidator(context, component, maxStr, minStr, cMessages);
 
   }
   
@@ -72,13 +84,31 @@
       FacesContext context,
       UIComponent component,
       String max,
-      String min)
+      String min,
+      Map messages)
   {
-    StringBuffer outBuffer = new StringBuffer();
+    StringBuilder outBuffer = new StringBuilder();
     outBuffer.append("new TrLengthValidator(");
     outBuffer.append(max);
     outBuffer.append(',');
     outBuffer.append(min);
+    outBuffer.append(',');
+    if(messages == null)
+    {
+      outBuffer.append("null");
+    }
+    else
+    {
+      try
+      {
+        JsonUtils.writeMap(outBuffer, messages, false);
+      }
+      catch (IOException e)
+      {
+        outBuffer.append("null");
+      }
+    }
+      
     outBuffer.append(")");
 
     return outBuffer.toString();



Mime
View raw message