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 java.lang.annotation.ElementType;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.annotation.Target;
22
23 /**
24 * リクエストパラメータがバインディングされるオブジェクトを指定します。
25 *
26 * <pre>
27 * public class HogeAction {
28 * private FugaBean fuga;
29 *
30 * public FugaBean getFuga() {
31 * return this.fuga;
32 * }
33 *
34 * // -> HogeActionにバインディングします。
35 * public ActionResult m1() {
36 * }
37 *
38 * // -> HogeActionにバインディングします。
39 * @Form
40 * public ActionResult m2() {
41 * }
42 *
43 * // プロパティfugaにバインディングします。
44 * @Form("fuga")
45 * public ActionResult m3() {
46 * }
47 *
48 * // バインディングしません。
49 * @Form(binding = false)
50 * public ActionResult m4() {
51 * }
52 * }
53 *
54 * @Form("fuga")
55 * // 全アクションメソッドに対して一括でバインディングの指定を行います。
56 * public class Hoge2Action {
57 * private FugaBean fuga;
58 *
59 * public FugaBean getFuga() {
60 * return this.fuga;
61 * }
62 *
63 * private ZzzBean zzz;
64 *
65 * public ZzzBean getZzz() {
66 * return this.zzz;
67 * }
68 *
69 * // プロパティfugaにバインディングします(クラスでの指定が有効なため)。
70 * public ActionResult m1() {
71 * }
72 *
73 * @Form("zzz")
74 * // プロパティzzzにバインディングします(アクションメソッドでの指定が優先されるため)。
75 * public ActionResult m2() {
76 * }
77 * }
78 * </pre>
79 *
80 * @author agata
81 * @since 1.0.0
82 */
83 @Retention(RetentionPolicy.RUNTIME)
84 @Target( { ElementType.METHOD, ElementType.TYPE })
85 public @interface Form {
86 /** アクションメソッド自身にリクエストパラメータがバインディングされることを表します */
87 public static final String THIS = "this";
88
89 /**
90 * バインディングするオブジェクトのプロパティ名。
91 * <p>
92 * "this" が指定された場合は、アクションクラス自身にリクエストパラメータがバインディングされることを表します。
93 * </p>
94 */
95 String value() default THIS;
96
97 /**
98 * リクエストパラメータからフォームオブジェクトへのバインディングするかを示します。
99 * <p>
100 * <code>false</code> が指定された場合はフォームオブジェクトへのバインディングを行いません。
101 * </p>
102 */
103 boolean binding() default true;
104
105 }