001 // Copyright Aug 6, 2006 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 package org.apache.tapestry.form; 015 016 import org.apache.tapestry.IMarkupWriter; 017 import org.apache.tapestry.IRequestCycle; 018 import org.apache.tapestry.form.validator.Validator; 019 020 021 /** 022 * Marker interface for components that would like to override the default 023 * logic used to render validation contributions made for client side form 024 * validation. 025 * 026 * @author jkuhnert 027 */ 028 public interface ValidatableFieldExtension extends ValidatableField 029 { 030 031 /**Called during render of the specified component. Renders any contributions from validators. 032 * Check to see if this field would like to override the default 033 * contributions made by the specified {@link Validator} with it's own 034 * contributions. 035 * 036 * @param validator The validator to check if component wants to override. 037 * @param cycle The current request cycle. 038 * 039 * @return True if this field wants to override default, false otherwise. 040 */ 041 boolean overrideValidator(Validator validator, IRequestCycle cycle); 042 043 /** 044 * Very similar to the method signature used by {@link ValidatableFieldSupport#renderContributions(ValidatableField, IMarkupWriter, IRequestCycle)}, 045 * with the additional parameter being the {@link Validator} that this component has chosen to override. 046 * 047 * <p> 048 * This method will only be called if {@link #overrideValidator(Validator, IRequestCycle)} returns true 049 * for the specified {@link Validator}. 050 * </p> 051 * 052 * @param validator The original {@link Validator} that component opted to override. 053 * @param context The context object used by validation contributors. 054 * @param writer The markup writer to send content to. (if any is needed) 055 * @param cycle The current request cycle. 056 */ 057 void overrideContributions(Validator validator, FormComponentContributorContext context, 058 IMarkupWriter writer, IRequestCycle cycle); 059 }