001    // Copyright 2008 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    
015    package org.apache.tapestry5.corelib.internal;
016    
017    import org.apache.tapestry5.ComponentAction;
018    import org.apache.tapestry5.Field;
019    import org.apache.tapestry5.services.FormSupport;
020    
021    /**
022     * An implementation of {@link org.apache.tapestry5.services.FormSupport} that delegates all behavior to another
023     * instance of FormSupport. This allows some of the behavior to be overridden easily.
024     */
025    public class FormSupportAdapter implements FormSupport
026    {
027        private final FormSupport delegate;
028    
029        public FormSupportAdapter(FormSupport delegate)
030        {
031            this.delegate = delegate;
032        }
033    
034        public String allocateControlName(String id)
035        {
036            return delegate.allocateControlName(id);
037        }
038    
039        public <T> void store(T component, ComponentAction<T> action)
040        {
041            delegate.store(component, action);
042        }
043    
044        public <T> void storeAndExecute(T component, ComponentAction<T> action)
045        {
046            delegate.storeAndExecute(component, action);
047        }
048    
049        public void defer(Runnable command)
050        {
051            delegate.defer(command);
052        }
053    
054        public void setEncodingType(String encodingType)
055        {
056            delegate.setEncodingType(encodingType);
057        }
058    
059        public void addValidation(Field field, String validationName, String message, Object constraint)
060        {
061            delegate.addValidation(field, validationName, message, constraint);
062        }
063    
064        public String getClientId()
065        {
066            return delegate.getClientId();
067        }
068    
069        public boolean isClientValidationEnabled()
070        {
071            return delegate.isClientValidationEnabled();
072        }
073    
074        public String getFormComponentId()
075        {
076            return delegate.getFormComponentId();
077        }
078    
079        public String getFormValidationId()
080        {
081            return delegate.getFormValidationId();
082        }
083    }