01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.bind.annotation;
16:
17: import java.lang.annotation.ElementType;
18: import java.lang.annotation.Retention;
19: import java.lang.annotation.RetentionPolicy;
20: import java.lang.annotation.Target;
21:
22: import org.strecks.bind.factory.BindFactoryClass;
23: import org.strecks.bind.factory.BindSelectFactory;
24: import org.strecks.converter.Converter;
25: import org.strecks.converter.SafeBeanUtilsConverter;
26:
27: /**
28: * <p>
29: * Defines mechanism for binding from a selection (e.g. drop down menu). This bind handler handles
30: * binding where the source (form) property holds the selection key as a String. For example,
31: * suppose you are selecting from product categories. In this case:
32: * </p>
33: * <ul>
34: * <li>there may be a source property called <code>selectedCategoryId</code> as a String type,
35: * and containing a <code>BindSelect</code> annotation </li>
36: * <li>the bean contains a collection which contains the eligible/selectable objects as a
37: * <code>Collection</code> or <code>Map</code></li>
38: * <li>the bean has a reference, possibly indirectly via other containing beans, to a target bean
39: * with a a richly typed property, which will be the target of the selection. In our current
40: * example, this may be a <code>productCategory</code> property of type <code>Category</code> in
41: * a <code>Product</code> bean.</li>
42: * <li> The select binding operation takes the source <code>String</code> property, converts it to
43: * the key type of the collection, does the lookup for the object which matches this property, then
44: * binds the object returned from this lookup to the target property. </li>
45: * </ul>
46: *
47: * @author Phil Zoio
48: */
49: @Target(ElementType.METHOD)
50: @Retention(RetentionPolicy.RUNTIME)
51: @BindFactoryClass(BindSelectFactory.class)
52: public @interface BindSelect {
53:
54: /**
55: * The expression of the bean to set (eg. person.gender)
56: */
57: String targetBeanExpression();
58:
59: /**
60: * the property for the id part of target bean to (eg. the gender part of person.gender.id)
61: */
62: String targetBeanIdProperty();
63:
64: /**
65: * The class of the id property
66: */
67: Class<? extends Object> idClass();
68:
69: /**
70: * An expression evaluating to a Map object which can be used to look up instances of the target
71: * bean
72: */
73: String lookupMapExpression();
74:
75: /**
76: * Converter class used to map from String ids to an object representation of this value
77: */
78: Class<? extends Converter> idConverter() default SafeBeanUtilsConverter.class;
79:
80: }
|