You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/12/19 13:37:25 UTC

svn commit: r488674 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java javascript/META-INF/adf/jsLibs/CoreFormat.js

Author: matzew
Date: Tue Dec 19 05:37:24 2006
New Revision: 488674

URL: http://svn.apache.org/viewvc?view=rev&rev=488674
Log:
improving the client side daterestr. validator

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java?view=diff&rev=488674&r1=488673&r2=488674
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java Tue Dec 19 05:37:24 2006
@@ -19,6 +19,8 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -99,8 +101,20 @@
       weekdaysValues  = "null";
       monthValues  = "null";
     }
+    
+    
+    String messageDetailDaysOfWeek = this.getMessageDetailInvalidDaysOfWeek();
+    String messageDetailMonth = this.getMessageDetailInvalidMonths();
+    
+    Map<String, String> cMessages = null;
+    if(messageDetailDaysOfWeek != null || messageDetailMonth != null)
+    {
+      cMessages = new HashMap<String, String>();
+      cMessages.put("days", messageDetailDaysOfWeek);
+      cMessages.put("month", messageDetailMonth);
+    }
 
-    return _getTrDateRestrictionValidator(context, component, weekdaysValues, monthValues);
+    return _getTrDateRestrictionValidator(context, component, weekdaysValues, monthValues, cMessages);
   }
   
   
@@ -114,14 +128,31 @@
       FacesContext context,
       UIComponent component,
       String weekdaysValues,
-      String monthValues)
+      String monthValues,
+      Map messages)
   {
     StringBuilder outBuffer = new StringBuilder(31 + weekdaysValues.length() + monthValues.length());
     outBuffer.append("new TrDateRestrictionValidator(");
     outBuffer.append(weekdaysValues);
     outBuffer.append(',');
     outBuffer.append(monthValues);
-    outBuffer.append(")");
+    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();
   }

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?view=diff&rev=488674&r1=488673&r2=488674
==============================================================================
--- 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 Tue Dec 19 05:37:24 2006
@@ -649,10 +649,13 @@
 
 function TrDateRestrictionValidator(
   weekdaysValue,
-  monthValue)
+  monthValue,
+  messages)
+  
 {
   this._weekdaysValue = weekdaysValue;
   this._monthValue = monthValue;
+  this._messages = messages;
   this._weekdaysMap = {'2':'tue','4':'thu','6':'sat','1':'mon','3':'wed','5':'fri','0':'sun'};
   this._monthMap = {'2':'mar','4':'may','9':'oct','8':'sep','11':'dec','6':'jul','1':'feb','3':'apr','10':'nov','7':'aug','5':'jun','0':'jan'};
 
@@ -687,10 +690,23 @@
   	{
   		if(weekDaysArray[i].toLowerCase() == dayString)
   		{
-        facesMessage = _createFacesMessage("org.apache.myfaces.trinidad.validator.DateRestrictionValidator.WEEKDAY",
+  			var facesMessage;
+  			var key = "org.apache.myfaces.trinidad.validator.DateRestrictionValidator.WEEKDAY";
+  			if(this._messages && this._messages["days"])
+  			{
+          facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
+                                        this._messages["days"],
+                                        label,
+                                        ""+converter.getAsString(value),
+                                        dayString);
+  			}
+  			else
+  			{
+          facesMessage = _createFacesMessage(key,
                                         label,
                                         ""+converter.getAsString(value),
                                         dayString);
+  			}
         throw new TrConverterException(facesMessage);
   		}
   	}
@@ -705,10 +721,23 @@
   	{
   		if(monthArray[i].toLowerCase() == monthString)
   		{
-        facesMessage = _createFacesMessage("org.apache.myfaces.trinidad.validator.DateRestrictionValidator.MONTH",
+  			var facesMessage;
+  			var key = "org.apache.myfaces.trinidad.validator.DateRestrictionValidator.MONTH";
+  			if(this._messages && this._messages["month"])
+  			{
+          facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
+                                        this._messages["month"],
+                                        label,
+                                        ""+converter.getAsString(value),
+                                        monthString);
+  			}
+  			else
+  			{
+          facesMessage = _createFacesMessage(key,
                                         label,
                                         ""+converter.getAsString(value),
                                         monthString);
+  			}
         throw new TrConverterException(facesMessage);
   		}
   	}