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/11/02 01:38:05 UTC

svn commit: r470175 - in /incubator/adffaces/trunk/trinidad: trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/ trinidad-demo/src/main/java/org/apache/myf...

Author: matzew
Date: Wed Nov  1 17:38:04 2006
New Revision: 470175

URL: http://svn.apache.org/viewvc?view=rev&rev=470175
Log:
client version of the dateRestriction validator. still thinking about a nice documentation ... :) see ADFFACES-258

Added:
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/clientDateRestrictionValidate.jspx
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java
Modified:
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/DateRestrictionValidator.java
    incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateRestriction.xml
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ClientValidationBean.java
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/index.jspx
    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

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/DateRestrictionValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/DateRestrictionValidator.java?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/DateRestrictionValidator.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/validator/DateRestrictionValidator.java Wed Nov  1 17:38:04 2006
@@ -172,18 +172,8 @@
 
     if (value != null)
     {
-      TimeZone tz = null;
-      RequestContext rctx = RequestContext.getCurrentInstance();
-      if (rctx != null)
-      {
-        tz = rctx.getTimeZone();
-      }
-      else
-      {
-        tz = TimeZone.getDefault();
-      }
-      Calendar calendar = Calendar.getInstance(tz);
-      calendar.setTime(_getDateValue(value));
+      Calendar calendar = getCalendar();
+      calendar.setTime(getDateValue(value));
       Date convertedDate = calendar.getTime();
       
       String weekday = _dayMap.get(calendar.get(Calendar.DAY_OF_WEEK));
@@ -352,13 +342,30 @@
     return converter;
   }
 
+  
+  protected Calendar getCalendar()
+  {
+    TimeZone tz = null;
+    RequestContext rctx = RequestContext.getCurrentInstance();
+    if (rctx != null)
+    {
+      tz = rctx.getTimeZone();
+    }
+    else
+    {
+      tz = TimeZone.getDefault();
+    }
+    return Calendar.getInstance(tz);
+
+  }
+  
   /**
    * Parses the already converted value to a <code>java.util.Date</code>.
    * @param value converted value
    * @return fulltyped <code>java.util.Date</code>
    * @throws IllegalArgumentException
    */
-  private static Date _getDateValue(
+  protected static Date getDateValue(
       Object value) throws IllegalArgumentException
     {
       if (value instanceof Date)

Modified: incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateRestriction.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateRestriction.xml?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateRestriction.xml (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateRestriction.xml Wed Nov  1 17:38:04 2006
@@ -18,10 +18,10 @@
               xmlns:tr="http://myfaces.apache.org/trinidad"
               xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin">
   <validator>
-    <description><![CDATA[Validate that the date entered is within a given range.]]></description>
+    <description><![CDATA[Validate that the date entered is within a given restriction.]]></description>
     <display-name>validateDateRestriction</display-name>
     <validator-id>org.apache.myfaces.trinidad.DateRestriction</validator-id>
-    <validator-class>org.apache.myfaces.trinidad.validator.DateRestrictionValidator</validator-class>
+    <validator-class>org.apache.myfaces.trinidadinternal.validator.DateRestrictionValidator</validator-class>
     <property>
       <description><![CDATA[the .]]>
       </description>

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ClientValidationBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ClientValidationBean.java?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ClientValidationBean.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ClientValidationBean.java Wed Nov  1 17:38:04 2006
@@ -1,3 +1,4 @@
+package org.apache.myfaces.trinidaddemo;
 /*
 * Copyright 2006 The Apache Software Foundation.
 *
@@ -13,11 +14,9 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.trinidaddemo;
-import java.math.BigDecimal;
 
+import java.math.BigDecimal;
 import java.util.Date;
-
 
 public class ClientValidationBean implements java.io.Serializable
 {

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml Wed Nov  1 17:38:04 2006
@@ -1852,6 +1852,12 @@
     </navigation-case>
 
     <navigation-case>
+      <from-outcome>clientDateRestrictionValidate</from-outcome>
+      <to-view-id>/convertValidate/clientDateRestrictionValidate.jspx</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
       <from-outcome>convertValidateDemos</from-outcome>
       <to-view-id>/convertValidate/index.jspx</to-view-id>
       <redirect/>

Added: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/clientDateRestrictionValidate.jspx
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/clientDateRestrictionValidate.jspx?view=auto&rev=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/clientDateRestrictionValidate.jspx (added)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/clientDateRestrictionValidate.jspx Wed Nov  1 17:38:04 2006
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!--
+  Copyright 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.
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
+          xmlns:f="http://java.sun.com/jsf/core"
+          xmlns:tr="http://myfaces.apache.org/trinidad"
+          xmlns:trdemo="http://myfaces.apache.org/trinidaddemo">
+  <jsp:directive.page contentType="text/html;charset=utf-8"/>
+  <f:view>
+    <tr:document title="Client-side Date Restriction Validator">
+        <tr:form usesUpload="true">
+          <tr:panelPage>
+            <tr:messages/>
+            <f:facet name="navigationGlobal">
+              <tr:navigationPane hint="buttons">
+                <tr:commandNavigationItem text="Converters and Validators"
+                                    action="convertValidateDemos"
+                                    immediate="true"/>
+              </tr:navigationPane>
+            </f:facet>
+           <tr:panelHeader text="Client-side Date Restriction Validator">
+            <tr:outputText styleClass="AFInstructionText"
+                           value="In the following examples, the date Restriction validator runs on the client, avoiding a round trip."/>
+            <tr:spacer height="10"/>
+            <tr:panelHeader text="Client Validators"/>
+            <tr:spacer height="10"/>
+            <tr:panelFormLayout>
+
+              <tr:inputDate id="days" value="#{dateRestrictionValidator.testInvalidDays}"
+                                  label="Select a date!">
+                <f:facet name="help">
+                  <tr:outputText value="Ensures, that  #{dateRestrictionValidator.country} holidays are not selectable"/>
+                </f:facet>
+                <tr:convertDateTime pattern="yyyy-MM-dd"/>
+                <tr:validateDateRestriction  invalidDays="#{dateRestrictionValidator.nationalHolidays}" />
+              </tr:inputDate>
+              
+              <tr:inputDate id="month" value="#{dateRestrictionValidator.testInvalidMonth}"
+                                  label="Select a date!">
+                <f:facet name="help">
+                  <tr:outputText value="November/December dates are not allowed here!"/>
+                </f:facet>
+                <tr:convertDateTime pattern="yyyy-MM-dd"/>
+                <tr:validateDateRestriction  invalidMonths="Nov Dec" />
+              </tr:inputDate>
+              
+              <tr:inputDate id="daysOfWeek" value="#{dateRestrictionValidator.testInvalidDaysOfWeek}"
+                                  label="Select a date!">
+                <f:facet name="help">
+                  <tr:outputText value="Please no Mondays...!"/>
+                </f:facet>
+                <tr:convertDateTime pattern="yyyy-MM-dd"/>
+                <tr:validateDateRestriction  invalidDaysOfWeek="Mon"/>
+              </tr:inputDate>
+
+            </tr:panelFormLayout>
+           </tr:panelHeader>
+            <tr:panelButtonBar>
+              <tr:commandButton text="Submit"/>
+            </tr:panelButtonBar>
+          </tr:panelPage>
+        </tr:form>
+    </tr:document>
+  </f:view>
+</jsp:root>

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/index.jspx
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/index.jspx?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/index.jspx (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/convertValidate/index.jspx Wed Nov  1 17:38:04 2006
@@ -33,6 +33,7 @@
               <tr:panelGroupLayout layout="vertical">
                 <tr:commandLink text="client converters and validators" action="clientConvert"/>
                 <tr:commandLink text="converters and validators" action="convertValidate"/>
+                <tr:commandLink text="client Date Restriction Validator" action="clientDateRestrictionValidate" />
                 <tr:commandLink text="Date Restriction Validator" action="dateRestrictionValidate" />
                 <tr:commandLink text="message customization on validators and converters" action="messageCustomization"/>
               </tr:panelGroupLayout>

Added: 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=auto&rev=470175
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java (added)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/validator/DateRestrictionValidator.java Wed Nov  1 17:38:04 2006
@@ -0,0 +1,215 @@
+package org.apache.myfaces.trinidadinternal.validator;
+/*
+* Copyright 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.
+*/
+
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.validator.ValidatorException;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.trinidad.util.MessageFactory;
+import org.apache.myfaces.trinidad.validator.ClientValidator;
+import org.apache.myfaces.trinidadinternal.convert.GenericConverterFactory;
+import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
+import org.apache.myfaces.trinidadinternal.util.JsonUtils;
+
+/**
+ * @author Matthias Wessendorf
+ *
+ */
+public class DateRestrictionValidator extends org.apache.myfaces.trinidad.validator.DateRestrictionValidator
+                                       implements ClientValidator
+{
+  public DateRestrictionValidator()
+  {
+    super();
+    _initJsDateMap();
+  }
+
+  @Override
+  public void validate(
+    FacesContext context,
+    UIComponent  component,
+    Object       value) throws ValidatorException
+  {
+    if (value == null)
+      return;
+    
+    if (!(value instanceof Date))
+    {
+      GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
+      value = fac.convert(value, Date.class);
+    }
+    super.validate(context, component, value);
+  }
+  
+  public Collection<String> getClientImportNames()
+  {
+    return _IMPORT_NAMES;
+  }
+
+  public String getClientScript(
+   FacesContext context,
+   UIComponent component)
+  {
+    return null;
+  }
+
+
+  /**
+   * @todo this should have not_in_range messages, not just max and min!
+   * @todo Format these numbers properly.
+   */
+  public String getClientValidation(
+    FacesContext context,
+    UIComponent component)
+  {
+    String[] weekdaysValue = getInvalidDaysOfWeek();
+    String weekdaysValues = null;
+    StringBuilder sb1 = new StringBuilder();
+    
+    String[] monthValue = getInvalidMonths();
+    String monthValues = null;
+    StringBuilder sb2 = new StringBuilder();
+    monthValues = sb2.toString();
+
+    try
+    {
+      JsonUtils.writeObject(sb1, weekdaysValue, false);
+      weekdaysValues = sb1.toString();
+      JsonUtils.writeObject(sb2, monthValue, false);
+      monthValues = sb2.toString();
+    }
+    catch (IOException e)
+    {
+      weekdaysValues  = "null";
+      monthValues  = "null";
+    }
+
+    return _getTrDateRestrictionValidator(context, component, WEEKDAY_MESSAGE_ID, MONTH_MESSAGE_ID, VALIDATOR_ID, weekdaysValues, monthValues);
+  }
+  
+  
+  public String getClientLibrarySource(
+   FacesContext context)
+  {
+    return null;
+  }
+  
+  private static String _getTrDateRestrictionValidator(
+      FacesContext context,
+      UIComponent component,
+      String weekId,
+      String monthId,
+      String defaultId,
+      String weekdaysValues,
+      String monthValues)
+  {
+    StringBuffer outBuffer = new StringBuffer(250);
+    outBuffer.append("new TrDateRestrictionValidator(");
+
+    FacesMessage weekMessage =
+      MessageFactory.getMessage(context, weekId,
+                                  new Object[]{"{0}", "{1}", "{2}"});
+
+    outBuffer.append("{WV:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(weekMessage.getDetail()));
+
+    outBuffer.append("',WV_S:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(weekMessage.getSummary()));    
+
+    FacesMessage monthMessage =
+      MessageFactory.getMessage(context, monthId,
+                                  new Object[]{"{0}", "{1}", "{2}"});
+
+    outBuffer.append("',MV:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(monthMessage.getDetail()));
+    outBuffer.append("',MV_S:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(monthMessage.getSummary()));  
+    
+    FacesMessage defaultMessage =
+      MessageFactory.getMessage(context, defaultId,
+                                  new Object[]{"{0}", "{1}"});
+
+    outBuffer.append("',D:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(defaultMessage.getDetail())); 
+    outBuffer.append("',D_S:'");
+    outBuffer.append(XhtmlLafUtils.escapeJS(defaultMessage.getSummary()));
+    outBuffer.append("'},null,0,");
+    outBuffer.append(weekdaysValues);
+    outBuffer.append(',');
+    outBuffer.append(monthValues);
+    outBuffer.append(',');
+    outBuffer.append(_getMapAsJson(_jsWeekDays));
+    outBuffer.append(',');
+    outBuffer.append(_getMapAsJson(_jsMonths));
+    outBuffer.append(")");
+
+    return outBuffer.toString();
+  }
+  
+  private static String _getMapAsJson(Map map)
+  {
+    StringBuilder sb = new StringBuilder();
+    try
+    {
+      JsonUtils.writeMap(sb, map, false);
+    }
+    catch (IOException e)
+    {
+      sb.append("null");
+    }
+    return sb.toString();
+  }
+  
+  private void _initJsDateMap()
+  {
+    _jsWeekDays = new HashMap<Integer, String>();
+    _jsWeekDays.put(Calendar.SUNDAY-1, "sun");
+    _jsWeekDays.put(Calendar.MONDAY-1, "mon");
+    _jsWeekDays.put(Calendar.TUESDAY-1, "tue");
+    _jsWeekDays.put(Calendar.WEDNESDAY-1, "wed");
+    _jsWeekDays.put(Calendar.THURSDAY-1, "thu");
+    _jsWeekDays.put(Calendar.FRIDAY-1, "fri");
+    _jsWeekDays.put(Calendar.SATURDAY-1, "sat");
+    
+    _jsMonths = new HashMap<Integer, String>();
+    _jsMonths.put(Calendar.JANUARY, "jan");
+    _jsMonths.put(Calendar.FEBRUARY, "feb");
+    _jsMonths.put(Calendar.MARCH, "mar");
+    _jsMonths.put(Calendar.APRIL, "apr");
+    _jsMonths.put(Calendar.MAY, "may");
+    _jsMonths.put(Calendar.JUNE, "jun");
+    _jsMonths.put(Calendar.JULY, "jul");
+    _jsMonths.put(Calendar.AUGUST, "aug");
+    _jsMonths.put(Calendar.SEPTEMBER, "sep");
+    _jsMonths.put(Calendar.OCTOBER, "oct");
+    _jsMonths.put(Calendar.NOVEMBER, "nov");
+    _jsMonths.put(Calendar.DECEMBER, "dec");
+  }
+  
+  private static final Collection<String> _IMPORT_NAMES = Collections.singletonList( "TrNumberConverter()" );
+  private static Map<Integer, String> _jsMonths = null;
+  private static Map<Integer, String> _jsWeekDays = null;
+}
\ No newline at end of file

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?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- 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 Wed Nov  1 17:38:04 2006
@@ -14,6 +14,176 @@
  * limitations under the License.
  */
 
+/**
+ * Construct a TrColorConverter with the specifed color pattern.
+ */
+function TrColorConverter(
+  pattern,
+  allowsTransparent,
+  msg_summary,
+  msg_detail,
+  patternsString)
+{
+  // for debugging
+  this._class = "TrColorConverter";
+  this._allowsTransparent = allowsTransparent;  
+  this._msg_summary = msg_summary; 
+  this._msg_detail = msg_detail;
+  this._patternsString = patternsString;     
+  
+  if (pattern != null)
+  {
+    if (typeof(pattern) == "string" ) 
+      pattern = [pattern];
+  }
+
+  this._pattern = pattern;
+}
+
+TrColorConverter.prototype = new TrConverter();
+TrColorConverter.prototype.getAsString = function(
+  formatColor)
+{
+  //pu: Return undefined string for an undefined Color.
+  if (formatColor == null)
+    return null;
+
+  // return localized transparent text for transparent color
+  if (formatColor.alpha == 0)
+    return _cfTrans;
+
+  var stringHolder = new Object();
+  stringHolder.value ="";
+  
+  var pattern = this._pattern;
+  if (typeof pattern != "string")
+    pattern = pattern[0];
+    
+  _cfoDoClumping(pattern,
+              _cfoSubformat,
+              formatColor,
+              stringHolder);
+  
+  return stringHolder.value;
+}
+
+/**
+ * Parses a String into a Color using the current object's pattern.  If the
+ * parsing fails, undefined will be returned.
+ */
+TrColorConverter.prototype.getAsObject  = function(
+  parseString,
+  label)
+{
+  // The following are from the javadoc for Number and DateTimeConverter, same applies to color....
+  // If the specified String is null, return a null. Otherwise, trim leading and trailing whitespace before proceeding.
+  // If the specified String - after trimming - has a zero length, return null.
+  if (parseString == null)
+    return null;
+    
+  parseString = TrUIUtils.trim(parseString);
+  if (parseString.length == 0)
+    return null
+
+  // return transparent color for localized transparent text
+  if (this._allowsTransparent && _cfTrans == parseString)
+    return new TrColor(0,0,0,0);
+     
+  var facesMessage = _createFacesMessage( this._msg_summary,
+                                          this._msg_detail,
+                                          label,
+                                          parseString,
+                                          this._patternsString);
+  
+  var pattern = this._pattern;                                       
+  if (typeof pattern == "string")
+  {
+    return this._rgbColorParseImpl(parseString,
+                              pattern,
+                              facesMessage);
+  }
+  else
+  { 
+    var i;
+    for (i = 0; i < pattern.length; i++)
+    {
+      try{
+        var color = this._rgbColorParseImpl(parseString,
+                                     pattern[i],
+                                     facesMessage);
+        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;
+      }
+    }
+  }
+}
+
+TrColorConverter.prototype._rgbColorParseImpl  = function(
+  parseString,
+  parsePattern,
+  msg)
+{
+  var parseContext = new Object();
+  parseContext.currIndex = 0;
+  parseContext.parseString = parseString;
+  parseContext.parseException = new TrConverterException(msg);
+  
+  var parsedColor = new TrColor(0x00, 0x00, 0x00);
+
+  // parse the color
+  if (_cfoDoClumping(parsePattern,
+                  _cfoSubParse,
+                  parseContext,
+                  parsedColor))
+  {
+    if (parseString.length != parseContext.currIndex)
+    {
+      throw parseContext.parseException;
+    }
+
+    return parsedColor;
+  }
+  else
+  {
+    // failure
+    throw parseContext.parseException;
+  }
+}
+
+function TrColor(
+  red,
+  green,
+  blue,
+  alpha)
+{
+  // for debugging
+  this._class = "TrColor";
+  
+  if (alpha == null)
+    alpha = 0xff;
+
+  this.red   = (red & 0xff);
+  this.green = (green & 0xff);
+  this.blue  = (blue & 0xff);
+  this.alpha = (alpha & 0xff);
+}
+
+TrColor.prototype.toString = function()
+{
+  return "rgba(" + this.red + 
+         "," + this.green + 
+         "," + this.blue + 
+         "," + this.alpha + ")";
+}
+
+
+
 
 // External variables used:
 //  _cfTrans    - the localized text for transparent colors
@@ -150,6 +320,7 @@
   stringHolder
   )
 {    
+
   // string to append to the toString
   var appendString = null;
   
@@ -447,172 +618,4 @@
   }
   
   return stringNumber;
-}
-
-/**
- * Construct a TrColorConverter with the specifed color pattern.
- */
-function TrColorConverter(
-  pattern,
-  allowsTransparent,
-  msg_summary,
-  msg_detail,
-  patternsString)
-{
-  // for debugging
-  this._class = "TrColorConverter";
-  this._allowsTransparent = allowsTransparent;  
-  this._msg_summary = msg_summary; 
-  this._msg_detail = msg_detail;
-  this._patternsString = patternsString;     
-  
-  if (pattern != null)
-  {
-    if (typeof(pattern) == "string" ) 
-      pattern = [pattern];
-  }
-
-  this._pattern = pattern;
-}
-
-TrColorConverter.prototype = new TrConverter();
-TrColorConverter.prototype.getAsString = function(
-  formatColor)
-{
-  //pu: Return undefined string for an undefined Color.
-  if (formatColor == null)
-    return null;
-
-  // return localized transparent text for transparent color
-  if (formatColor.alpha == 0)
-    return _cfTrans;
-
-  var stringHolder = new Object();
-  stringHolder.value ="";
-  
-  var pattern = this._pattern;
-  if (typeof pattern != "string")
-    pattern = pattern[0];
-    
-  _cfoDoClumping(pattern,
-              _cfoSubformat,
-              formatColor,
-              stringHolder);
-  
-  return stringHolder.value;
-}
-
-/**
- * Parses a String into a Color using the current object's pattern.  If the
- * parsing fails, undefined will be returned.
- */
-TrColorConverter.prototype.getAsObject  = function(
-  parseString,
-  label)
-{
-  // The following are from the javadoc for Number and DateTimeConverter, same applies to color....
-  // If the specified String is null, return a null. Otherwise, trim leading and trailing whitespace before proceeding.
-  // If the specified String - after trimming - has a zero length, return null.
-  if (parseString == null)
-    return null;
-    
-  parseString = TrUIUtils.trim(parseString);
-  if (parseString.length == 0)
-    return null
-
-  // return transparent color for localized transparent text
-  if (this._allowsTransparent && _cfTrans == parseString)
-    return new TrColor(0,0,0,0);
-     
-  var facesMessage = _createFacesMessage( this._msg_summary,
-                                          this._msg_detail,
-                                          label,
-                                          parseString,
-                                          this._patternsString);
-  
-  var pattern = this._pattern;                                       
-  if (typeof pattern == "string")
-  {
-    return this._rgbColorParseImpl(parseString,
-                              pattern,
-                              facesMessage);
-  }
-  else
-  { 
-    var i;
-    for (i = 0; i < pattern.length; i++)
-    {
-      try{
-        var color = this._rgbColorParseImpl(parseString,
-                                     pattern[i],
-                                     facesMessage);
-        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;
-      }
-    }
-  }
-}
-
-TrColorConverter.prototype._rgbColorParseImpl  = function(
-  parseString,
-  parsePattern,
-  msg)
-{
-  var parseContext = new Object();
-  parseContext.currIndex = 0;
-  parseContext.parseString = parseString;
-  parseContext.parseException = new TrConverterException(msg);
-  
-  var parsedColor = new TrColor(0x00, 0x00, 0x00);
-
-  // parse the color
-  if (_cfoDoClumping(parsePattern,
-                  _cfoSubParse,
-                  parseContext,
-                  parsedColor))
-  {
-    if (parseString.length != parseContext.currIndex)
-    {
-      throw parseContext.parseException;
-    }
-
-    return parsedColor;
-  }
-  else
-  {
-    // failure
-    throw parseContext.parseException;
-  }
-}
-
-function TrColor(
-  red,
-  green,
-  blue,
-  alpha)
-{
-  // for debugging
-  this._class = "TrColor";
-  
-  if (alpha == null)
-    alpha = 0xff;
-
-  this.red   = (red & 0xff);
-  this.green = (green & 0xff);
-  this.blue  = (blue & 0xff);
-  this.alpha = (alpha & 0xff);
-}
-
-TrColor.prototype.toString = function()
-{
-  return "rgba(" + this.red + 
-         "," + this.green + 
-         "," + this.blue + 
-         "," + this.alpha + ")";
 }

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?view=diff&rev=470175&r1=470174&r2=470175
==============================================================================
--- 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 Wed Nov  1 17:38:04 2006
@@ -2486,6 +2486,7 @@
 
               if (validatorConstructor)
               {
+
                 var validator = eval(validatorConstructor);
 
                 try {

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=470175&r1=470174&r2=470175
==============================================================================
--- 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 Wed Nov  1 17:38:04 2006
@@ -202,6 +202,81 @@
   
 }
 
+function TrDateRestrictionValidator(
+  messages,
+  maxPrecision,
+  maxScale,
+  weekdaysValue,
+  monthValue,
+  weekdaysMap,
+  monthMap)
+{
+  this._messages = messages;
+  this._maxPrecision = maxPrecision;
+  this._maxScale = maxScale;
+  this._weekdaysValue = weekdaysValue;
+  this._monthValue = monthValue;
+  this._weekdaysMap = weekdaysMap;
+  this._monthMap = monthMap;
+
+  // for debugging
+  this._class = "TrDateRestrictionValidator";
+}
+
+// weekday value
+TrDateRestrictionValidator.WV = 'WV';
+// month value
+TrDateRestrictionValidator.MV  = 'MV';
+// default
+TrDateRestrictionValidator.D   = 'D';
+
+TrDateRestrictionValidator.prototype = new TrValidator();
+TrDateRestrictionValidator.prototype.validate  = function(
+  value,
+  label
+)
+{
+
+  submittedDay = value.getDay();
+  weekDaysArray = eval(this._weekdaysValue);
+  if(weekDaysArray)
+  {
+  	var dayString = this._weekdaysMap[submittedDay];
+  	for(var i = 0; i < weekDaysArray.length; ++i)
+  	{
+  		if(weekDaysArray[i].toLowerCase() == dayString)
+  		{
+        facesMessage = _createFacesMessage(this._messages[(TrDateRestrictionValidator.WV+ '_S')],
+                                       this._messages[TrDateRestrictionValidator.WV],
+                                        label,
+                                        ""+value,
+                                        dayString);
+        throw new TrConverterException(facesMessage);
+  		}
+  	}
+  }
+  
+  submittedMonth = value.getMonth();
+  monthArray = eval(this._monthValue);
+  if(monthArray)
+  {
+  	var monthString = this._monthMap[submittedMonth];
+  	for(var i = 0; i < monthArray.length; ++i)
+  	{
+  		if(monthArray[i].toLowerCase() == monthString)
+  		{
+        facesMessage = _createFacesMessage(this._messages[(TrDateRestrictionValidator.MV+ '_S')],
+                                       this._messages[TrDateRestrictionValidator.MV],
+                                        label,
+                                        ""+value,
+                                        monthString);
+        throw new TrConverterException(facesMessage);
+  		}
+  	}
+  }
+	return value;
+}
+
 function _decimalParse(
   numberString,
   messages,