|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| TranslatorBindingFactory.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 | // Copyright 2005 The Apache Software Foundation | |
| 2 | // | |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | // you may not use this file except in compliance with the License. | |
| 5 | // You may obtain a copy of the License at | |
| 6 | // | |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | // | |
| 9 | // Unless required by applicable law or agreed to in writing, software | |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | // See the License for the specific language governing permissions and | |
| 13 | // limitations under the License. | |
| 14 | ||
| 15 | package org.apache.tapestry.form.translator; | |
| 16 | ||
| 17 | import org.apache.hivemind.ApplicationRuntimeException; | |
| 18 | import org.apache.hivemind.Location; | |
| 19 | import org.apache.hivemind.lib.BeanFactory; | |
| 20 | import org.apache.tapestry.IBinding; | |
| 21 | import org.apache.tapestry.IComponent; | |
| 22 | import org.apache.tapestry.binding.AbstractBindingFactory; | |
| 23 | ||
| 24 | /** | |
| 25 | * Uses the tapestry.form.translator.TranslatorBeanFactory service to obtain configured | |
| 26 | * {@link org.apache.tapestry.form.translator.Translator} instances that are then wrapped as | |
| 27 | * {@link org.apache.tapestry.form.translator.TranslatorBinding}s. | |
| 28 | * | |
| 29 | * @author Howard Lewis Ship | |
| 30 | * @since 4.0 | |
| 31 | * @deprecated Support for the translator: will be removed in release 4.1, along with | |
| 32 | * {@link org.apache.tapestry.valid.ValidField}. | |
| 33 | */ | |
| 34 | public class TranslatorBindingFactory extends AbstractBindingFactory | |
| 35 | { | |
| 36 | private BeanFactory _translatorBeanFactory; | |
| 37 | ||
| 38 | 6 | public IBinding createBinding(IComponent root, String bindingDescription, String expression, |
| 39 | Location location) | |
| 40 | { | |
| 41 | 6 | try |
| 42 | { | |
| 43 | 6 | Translator translator = (Translator) _translatorBeanFactory.get(expression); |
| 44 | ||
| 45 | 3 | return new TranslatorBinding(bindingDescription, getValueConverter(), location, |
| 46 | translator); | |
| 47 | } | |
| 48 | catch (Exception ex) | |
| 49 | { | |
| 50 | 3 | throw new ApplicationRuntimeException(ex.getMessage(), location, ex); |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | 6 | public void setTranslatorBeanFactory(BeanFactory translatorBeanFactory) |
| 55 | { | |
| 56 | 6 | _translatorBeanFactory = translatorBeanFactory; |
| 57 | } | |
| 58 | } |
|
||||||||||