Coverage Report - org.seasar.cubby.action.Form
 
Classes in this File Line Coverage Branch Coverage Complexity
Form
N/A
N/A
0
 
 1  
 /*
 2  
  * Copyright 2004-2010 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  
 
 17  
 package org.seasar.cubby.action;
 18  
 
 19  
 import static org.seasar.cubby.action.RequestParameterBindingType.ALL_PROPERTIES;
 20  
 
 21  
 import java.lang.annotation.ElementType;
 22  
 import java.lang.annotation.Retention;
 23  
 import java.lang.annotation.RetentionPolicy;
 24  
 import java.lang.annotation.Target;
 25  
 
 26  
 /**
 27  
  * アクションメソッド呼び出し時に要求パラメータがバインドされるオブジェクトや方法を指定します。
 28  
  * 
 29  
  * <p>
 30  
  * この注釈によって、どのように要求パラメータがバインドされるかが変わります。
 31  
  * 
 32  
  * <pre>
 33  
  * import static org.seasar.cubby.action.RequestParameterBindingType.*;
 34  
  * 
 35  
  * public class FooAction {
 36  
  * 
 37  
  *         // コンテナの機能によって自動的にインジェクションされる想定です。
 38  
  *         public BarDto barDto;
 39  
  * 
 40  
  *         // -&gt; アクション(FooAction)の @RequestParameter で修飾されたプロパティとフィールドにバインドします。
 41  
  *  // よく使用するパターンです。
 42  
  *         public ActionResult m01() {
 43  
  *         }
 44  
  * 
 45  
  *         // -&gt; アクション(FooAction)の @RequestParameter で修飾されたプロパティとフィールドにバインドします。
 46  
  *         &#064;Form(bindingType = ONLY_SPECIFIED_PROPERTIES)
 47  
  *         public ActionResult m02() {
 48  
  *         }
 49  
  * 
 50  
  *         // -&gt; アクション(FooAction)のすべてのプロパティにバインドします。フィールドにはバインドしません。
 51  
  *         &#064;Form(bindingType = ALL_PROPERTIES)
 52  
  *         public ActionResult m03() {
 53  
  *         }
 54  
  * 
 55  
  *         // -&gt; 要求パラメータを barDto の全プロパティにバインドします。フィールドにはバインドしません。
 56  
  *  // よく使用するパターンです。
 57  
  *         &#064;Form(&quot;barDto&quot;)
 58  
  *         public ActionResult m11() {
 59  
  *         }
 60  
  * 
 61  
  *         // 要求パラメータを barDto の @RequestParameter で修飾されたプロパティとフィールドにバインドします。
 62  
  *         &#064;Form(&quot;barDto&quot;
 63  
  *             bindingType = ONLY_SPECIFIED_PROPERTIES)
 64  
  *         public ActionResult m12() {
 65  
  *         }
 66  
  * 
 67  
  *         // 要求パラメータを barDto の全プロパティにバインドします。フィールドにはバインドしません。
 68  
  *         &#064;Form(value = &quot;barDto&quot;,
 69  
  *             bindingType = ALL_PROPERTIES)
 70  
  *         public ActionResult m13() {
 71  
  *         }
 72  
  * 
 73  
  *         // 要求パラメータをバインドしません。
 74  
  *         &#064;Form(bindingType = NONE)
 75  
  *         public ActionResult m21() {
 76  
  *         }
 77  
  * }
 78  
  * </pre>
 79  
  * 
 80  
  * </p>
 81  
  * 
 82  
  * <p>
 83  
  * クラスとメソッドの両方に注釈をつけた場合は、メソッドの注釈が優先されます。
 84  
  * 
 85  
  * <pre>
 86  
  * &#064;Form(&quot;barDto&quot;)
 87  
  * // 全アクションメソッドに対して一括でバインディングの指定を行います。
 88  
  * public class Foo2Action {
 89  
  * 
 90  
  *         public BarDto barDto;
 91  
  * 
 92  
  *         public BazDto bazDto;
 93  
  * 
 94  
  *         // 要求パラメータを barDto のプロパティにバインドします (クラスでの指定が有効なため)。
 95  
  *         public ActionResult m01() {
 96  
  *         }
 97  
  * 
 98  
  *         &#064;Form(&quot;bazDto&quot;)
 99  
  *         // 要求パラメータを bazDto のプロパティにバインドします(アクションメソッドでの指定が優先されるため)。
 100  
  *         public ActionResult m02() {
 101  
  *         }
 102  
  * }
 103  
  * </pre>
 104  
  * 
 105  
  * </p>
 106  
  * 
 107  
  * @author agata
 108  
  * @see RequestParameter
 109  
  * @see RequestParameterBindingType
 110  
  */
 111  
 @Retention(RetentionPolicy.RUNTIME)
 112  
 @Target( { ElementType.METHOD, ElementType.TYPE })
 113  
 public @interface Form {
 114  
         /** アクションメソッド自身に要求パラメータがバインディングされることを表します */
 115  
         public static final String THIS = "this";
 116  
 
 117  
         /**
 118  
          * バインディングするオブジェクトのプロパティ名。
 119  
          * <p>
 120  
          * "this" が指定された場合は、アクションクラス自身に要求パラメータがバインディングされることを表します。
 121  
          * </p>
 122  
          */
 123  
         String value() default THIS;
 124  
 
 125  
         /**
 126  
          * 要求パラメータからフォームオブジェクトへのバインディング方法を指定します。
 127  
          */
 128  
         RequestParameterBindingType bindingType() default ALL_PROPERTIES;
 129  
 
 130  
 }