Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Form |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 2004-2008 the Seasar Foundation and the Others. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | * either express or implied. See the License for the specific language | |
14 | * governing permissions and limitations under the License. | |
15 | */ | |
16 | package org.seasar.cubby.action; | |
17 | ||
18 | import static org.seasar.cubby.action.RequestParameterBindingType.ALL_PROPERTIES; | |
19 | ||
20 | import java.lang.annotation.ElementType; | |
21 | import java.lang.annotation.Retention; | |
22 | import java.lang.annotation.RetentionPolicy; | |
23 | import java.lang.annotation.Target; | |
24 | ||
25 | /** | |
26 | * アクションメソッド呼び出し時にリクエストパラメータがバインドされるオブジェクトや方法を指定します。 | |
27 | * | |
28 | * <p> | |
29 | * この注釈によって、どのようにリクエストパラメータがバインドされるかが変わります。 | |
30 | * <pre> | |
31 | * import static org.seasar.cubby.action.RequestParameterBindingType.*; | |
32 | * | |
33 | * public class FooAction { | |
34 | * | |
35 | * // コンテナの機能によって自動的にインジェクションされる想定です。 | |
36 | * public BarDto barDto; | |
37 | * | |
38 | * // -> アクション(FooAction)の @RequestParameter で修飾されたプロパティにバインドします。 | |
39 | * // よく使用するパターンです。 | |
40 | * public ActionResult m01() { | |
41 | * } | |
42 | * | |
43 | * // -> アクション(FooAction)の @RequestParameter で修飾されたプロパティにバインドします。 | |
44 | * @Form(bindingType = ONLY_SPECIFIED_PROPERTIES) | |
45 | * public ActionResult m02() { | |
46 | * } | |
47 | * | |
48 | * // -> アクション(FooAction)の全プロパティにバインドします。 | |
49 | * @Form(bindingType = ALL_PROPERTIES) | |
50 | * public ActionResult m03() { | |
51 | * } | |
52 | * | |
53 | * // リクエストパラメータを barDto の全プロパティにバインドします。 | |
54 | * // よく使用するパターンです。 | |
55 | * @Form("barDto") | |
56 | * public ActionResult m11() { | |
57 | * } | |
58 | * | |
59 | * // リクエストパラメータを barDto の @RequestParameter で修飾されたプロパティにバインドします。 | |
60 | * @Form("barDto" | |
61 | * bindingType = ONLY_SPECIFIED_PROPERTIES) | |
62 | * public ActionResult m12() { | |
63 | * } | |
64 | * | |
65 | * // リクエストパラメータを barDto の全プロパティにバインドします。 | |
66 | * @Form(value = "barDto", | |
67 | * bindingType = ALL_PROPERTIES) | |
68 | * public ActionResult m13() { | |
69 | * } | |
70 | * | |
71 | * // リクエストパラメータをバインドしません。 | |
72 | * @Form(bindingType = NONE) | |
73 | * public ActionResult m21() { | |
74 | * } | |
75 | * } | |
76 | * </pre> | |
77 | * </p> | |
78 | * | |
79 | * <p> | |
80 | * クラスとメソッドの両方に注釈をつけた場合は、メソッドの注釈が優先されます。 | |
81 | * <pre> | |
82 | * @Form("barDto") | |
83 | * // 全アクションメソッドに対して一括でバインディングの指定を行います。 | |
84 | * public class Foo2Action { | |
85 | * | |
86 | * public BarDto barDto; | |
87 | * | |
88 | * public BazDto bazDto; | |
89 | * | |
90 | * // リクエストパラメータを barDto のプロパティにバインドします (クラスでの指定が有効なため)。 | |
91 | * public ActionResult m01() { | |
92 | * } | |
93 | * | |
94 | * @Form("bazDto") | |
95 | * // リクエストパラメータを bazDto のプロパティにバインドします(アクションメソッドでの指定が優先されるため)。 | |
96 | * public ActionResult m02() { | |
97 | * } | |
98 | * } | |
99 | * </pre> | |
100 | * </p> | |
101 | * | |
102 | * <p> | |
103 | * このアノテーションをつけない場合の挙動が 1.0.x と 1.1.x で異なるのでご注意ください。 | |
104 | * <table> | |
105 | * <thead> | |
106 | * <tr> | |
107 | * <th>バージョン</th> | |
108 | * <th>バインド対象のオブジェクト</th> | |
109 | * <th>バインド対象のプロパティ</th> | |
110 | * </tr> | |
111 | * </thead> | |
112 | * <tbody> | |
113 | * <tr> | |
114 | * <td>1.0.x</td> | |
115 | * <td>アクション</td> | |
116 | * <td>すべてのプロパティ</td> | |
117 | * </tr> | |
118 | * <tr> | |
119 | * <td>1.1.x</td> | |
120 | * <td>アクション</td> | |
121 | * <td>@RequestParameter で修飾されたプロパティ</td> | |
122 | * </tr> | |
123 | * </tbody> | |
124 | * </table> | |
125 | * </p> | |
126 | * | |
127 | * @author agata | |
128 | * @since 1.0.0 | |
129 | * @see RequestParameter | |
130 | * @see RequestParameterBindingType | |
131 | */ | |
132 | @Retention(RetentionPolicy.RUNTIME) | |
133 | @Target( { ElementType.METHOD, ElementType.TYPE }) | |
134 | public @interface Form { | |
135 | /** アクションメソッド自身にリクエストパラメータがバインディングされることを表します */ | |
136 | public static final String THIS = "this"; | |
137 | ||
138 | /** | |
139 | * バインディングするオブジェクトのプロパティ名。 | |
140 | * <p> | |
141 | * "this" が指定された場合は、アクションクラス自身にリクエストパラメータがバインディングされることを表します。 | |
142 | * </p> | |
143 | */ | |
144 | String value() default THIS; | |
145 | ||
146 | /** | |
147 | * リクエストパラメータからフォームオブジェクトへのバインディングするかを示します。 | |
148 | * <p> | |
149 | * <code>false</code> が指定された場合はフォームオブジェクトへのバインディングを行いません。 | |
150 | * </p> | |
151 | * | |
152 | * @deprecated {@link RequestParameterBindingType#NONE} を使用するようにしてください。 | |
153 | */ | |
154 | @Deprecated | |
155 | boolean binding() default true; | |
156 | ||
157 | /** | |
158 | * リクエストパラメータからフォームオブジェクトへのバインディング方法を指定します。 | |
159 | * | |
160 | * @since 1.1.0 | |
161 | */ | |
162 | RequestParameterBindingType bindingType() default ALL_PROPERTIES; | |
163 | ||
164 | } |