Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2005 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.
 
 package org.apache.tapestry.form;
 
 
 import  org.apache.hivemind.service.ThreadLocale;
Default ValidatableFieldSupport implementation. This implementation generates calls to a static javascript function during render if client-side validation is enabled.

Author(s):
Paul Ferraro
Since:
4.0
 
 {
     private ValueConverter _converter;
 
     private ThreadLocale _threadLocale;
 
     public void setValueConverter(ValueConverter converter)
     {
          = converter;
     }
 
     public void setThreadLocale(ThreadLocale threadLocale)
     {
          = threadLocale;
     }
 
     protected Iterator getValidatorsIterator(ValidatableField component)
     {
         return (Iterator.coerceValue(component.getValidators(), Iterator.class);
     }

    

See also:
org.apache.tapestry.form.ValidatableFieldSupport.renderContributions(ValidatableField, IMarkupWriter, IRequestCycle)
 
     public void renderContributions(ValidatableField componentIMarkupWriter writer,
             IRequestCycle cycle)
     {
         ValidatableFieldExtension extension = null;
         if (ValidatableFieldExtension.class.isInstance(component))
             extension = (ValidatableFieldExtension)component;
         
         if (component.getForm().isClientValidationEnabled())
         {
             FormComponentContributorContext context = new FormComponentContributorContextImpl(
                     .getLocale(), cyclecomponent);
 
             Iterator validators = getValidatorsIterator(component);
 
             while (validators.hasNext())
             {
                 Validator validator = (Validatorvalidators.next();
                 
                 if (extension != null && extension.overrideValidator(validatorcycle))
                     extension.overrideContributions(validatorcontextwritercycle);
                 else
                     validator.renderContribution(writercyclecontextcomponent);
             }
         }
     }

    

See also:
org.apache.tapestry.form.ValidatableFieldSupport.validate(org.apache.tapestry.form.ValidatableField, org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle, java.lang.Object)
 
     public void validate(ValidatableField componentIMarkupWriter writerIRequestCycle cycleObject objectthrows ValidatorException
     {
         boolean isNonNull = (object != null);
 
         Iterator validators = getValidatorsIterator(component);
 
         ValidationMessages messages = new ValidationMessagesImpl(component.getLocale());
 
         while (validators.hasNext())
         {
             Validator validator = (Validatorvalidators.next();
 
             if (isNonNull || validator.getAcceptsNull())
                 validator.validate(componentmessagesobject);
        }
    }
    public boolean isRequired(ValidatableField field)
    {
        Iterator i = getValidatorsIterator(field);
        while (i.hasNext())
        {
            Validator validator = (Validatori.next();
            if (validator.isRequired())
                return true;
        }
        return false;
    }
New to GrepCode? Check out our FAQ X