001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.hayabusa.taglib;
017    
018    import org.opengion.hayabusa.common.HybsSystemException;
019    import org.opengion.fukurou.util.XHTMLTag;
020    
021    /**
022     * ボタンを作æ?するHTML拡張タグですã?
023     *
024     * ボタンごとにå¿?¦�な画面を選び出して制御を転送することができますã?
025     * BODY 部åˆ?�«ラベルã‚?¼·調æ–?­—などのタグを記述すれば、そのままボタンとして表示されますã?
026     * [ヒンãƒ?
027     * buttonタグとinputタグが生成するã?タンは、機è?çš?�«は同等ですが、buttonタグの方ã�?
028     * レタリング能力があり、å?容を持つことができますã?
029     * 例えば、画像をå†?®¹に持つbutton機è?は、type属æ?がimageのinputタグと
030     * そっくり同じですが、buttonタグはå†?®¹を持つことができますã?
031     *
032     * @og.formSample
033     * ●形式ï¼?lt;og:button type="…" name="…" value="…" lbl="…" />
034     * ●body?šあã‚?EVAL_BODY_BUFFERED:BODYを評価しã?{@XXXX} を解析しまã�?
035     *
036     * ●Tag定義??
037     *   <og:button
038     *       type             ○ã?HTML】ã?タンのタイプ[submit/reset/button]を指定しまã�?å¿??)ã€?
039     *       name               【HTML】ã?タンの名称を指定しまã�?
040     *       value              【HTML】ã?タンの値を指定しまã�?
041     *       caseKey            【TAG】このタグ自体を利用するかどã�?�‹の条件キーを指定しまã�?初期値:null)
042     *       caseVal            【TAG】このタグ自体を利用するかどã�?�‹の条件値を指定しまã�?初期値:null)
043     *       caseNN             【TAG】指定ã?値がã?null/ゼロæ–?­—å? でなã�??å�?Not Null=NN)は、このタグは使用されまã�?初期値:true)
044     *       caseNull           【TAG】指定ã?値がã?null/ゼロæ–?­—å? の場合ã?、このタグは使用されまã�?初期値:true)
045     *       lbl                【TAG】ラベルリソースのラベルIDを指定しまã�?
046     *       id                 【HTML】要ç´?�«対して固有ã?名前(id)をつける場合に設定しまã�?
047     *       lang               【HTML】要ç´??å†?®¹と他ã?属æ?値のè¨?ª?lang,xml:lang)を指定しまã�?
048     *       dir                【HTML】文字表記ã?方å�?dir)を指定しまã�?
049     *       title              【HTML】要ç´?�«対する補足çš?ƒ…報(title)を設定しまã�?
050     *       style              【HTML】この要ç´?�«対して適用させるスタイルシーãƒ?style)を設定しまã�?
051     *       disabled           【TAG】その部品に対してã€?�¸択や変更がå?来なã�?‚ˆã�?�«(disabled)æŒ?®šしまã�?サーバã?に送信されなã�?
052     *       tabindex           【HTML】タブã?移動é?(tabindex)を指定しまã�?0 ??32767)
053     *       accesskey          【HTML】アクセスキー(alt+キーで直接æŒ?®?を割り当てまã�?
054     *       clazz              【HTML】要ç´?�«対して class 属æ?を設定しまã�?
055     *       language           【TAG】タグå†?ƒ¨で使用するè¨?ªžコード[ja/en/zh/…]を指定しまã�?
056     *       onClick            【HTML】JavaScriptのイベンãƒ?onClick を設定しまã�?ä¾?onClick="renew('query.jsp','QUERY');")
057     *       onBlur             【HTML】JavaScriptのイベンãƒ?onBlur を設定しまã�?ä¾?onBlur="this.value=value.toUpperCase();")
058     *       onFocus            【HTML】JavaScriptのイベンãƒ?onFocus を設定しまã�?
059     *       ondblClick         【HTML】JavaScriptのイベンãƒ?ondblClick を設定しまã�?
060     *       onMouseDown        【HTML】JavaScriptのイベンãƒ?onMouseDown を設定しまã�?
061     *       onMouseUp          【HTML】JavaScriptのイベンãƒ?onMouseUp を設定しまã�?
062     *       onMouseMove        【HTML】JavaScriptのイベンãƒ?onMouseMove を設定しまã�?
063     *       onMouseOut         【HTML】JavaScriptのイベンãƒ?onMouseOut を設定しまã�?
064     *       onMouseOver        【HTML】JavaScriptのイベンãƒ?onMouseOver を設定しまã�?
065     *       autofocus          【HTML5】指定したå?力æ¬?�«カーソルが当たって自動的にフォーカスされますã?
066     *       roles              【TAG】ロールをセãƒ?ƒˆしまã�?
067     *       debug              【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
068     *   >   ... Body ...
069     *   </og:button>
070     *
071     * ●使用ä¾?
072     * <og:button type="submit" name="test" value="1" lbl="test" />     LabelResource プロパティのラベル使用したã�?�¨ききはlbl属æ?に、LabelResourceを使ã�?�¾すã?
073     * <og:button type="submit" name="test" value="1" msg="MSG0103" />  MessageResource プロパティのラベル使用したã�?�¨きã?msg属æ?を使ã�?�¾すã?
074     *
075     * @og.group 画面部å“?
076     *
077     * @version  4.0
078     * @author   Kazuhiko Hasegawa
079     * @since    JDK5.0,
080     */
081    public class ButtonTag extends HTMLTagSupport {
082            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
083            private static final String VERSION = "5.2.2.0 (2010/11/01)" ;
084    
085            private static final long serialVersionUID = 522020101101L ;
086    
087            private static final String CHECK_TYPE = "|submit|reset|button|" ;
088    
089            /**
090             * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
091             *
092             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?ボディが存在する場合ã?みボディが呼ばれる対応ã?
093             * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
094             *
095             * @return      後続å?ç�??æŒ?¤º( EVAL_BODY_BUFFERED )
096             */
097            @Override
098            public int doStartTag() {
099                    // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
100                    if( useTag() ) {
101                            set( "body",getLongLabel() );
102                            return( EVAL_BODY_BUFFERED );   // Body を評価するã€? extends BodyTagSupport æ™?
103                    }
104                    return ( SKIP_BODY );                           // Body を評価しなã�?
105            }
106    
107            /**
108             * Taglibのタグ本体を処ç�?�™ã‚?doAfterBody() ã‚?オーバã?ライドしますã?
109             *
110             * @og.rev 3.1.1.0 (2003/03/28) ボディのå†?®¹を取得するå?ç�?‚’、CommonTagSupport で行うã€?
111             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?ボディが存在する場合ã?みボディが呼ばれる対応ã?
112             *
113             * @return      後続å?ç�??æŒ?¤º(SKIP_BODY)
114             */
115            @Override
116            public int doAfterBody() {
117                    String label = getBodyString();
118    
119                    if( label != null && label.length() > 0 ) {
120                            set( "body",label );
121                    }
122    
123                    return(SKIP_BODY);
124            }
125    
126            /**
127             * ボタンを作æ?しますã?
128             *
129             * <button type="submit" name="名前" value="値">
130             *
131             * @return  ボタンタグæ–?­—å?
132             */
133            @Override
134            protected String makeTag() {
135                    return XHTMLTag.button( getAttributes() );
136            }
137    
138            /**
139             * 【HTML】ã?タンのタイプ[submit/reset/button]を指定しますã?
140             *
141             * @og.tag
142             *
143             * submit:提å?ボタンを作æ?しますã?
144             * reset:リセãƒ?ƒˆボタンを作æ?しますã?
145             * button:押しã?タンを作æ?しますã?
146             *
147             * @param   type ボタンのタイプ[submit/reset/button]
148             */
149            public void setType( final String type ) {
150                    String tp = getRequestParameter( type );
151                    if( check( "|" + tp + "|" , CHECK_TYPE ) ) {
152                            set( "type",tp );
153                    }
154                    else {
155                            String errMsg = "type は、下記ã?ç¯?›²よりæŒ?®šしてください。type=["
156                                                     + tp + "]  in [" + CHECK_TYPE + "]";
157                            throw new HybsSystemException( errMsg );
158                    }
159            }
160    
161            /**
162             * 【HTML】ã?タンの名称を指定しますã?
163             *
164             * @og.tag
165             * @param       name    ボタンの名称
166             */
167            public void setName( final String name ) {
168                    set( "name",getRequestParameter( name ) );
169            }
170    
171            /**
172             * 【HTML】ã?タンの値を指定しますã?
173             *
174             * @og.tag
175             * @param   value ボタンの値
176             */
177            public void setValue( final String value ) {
178                    set( "value",getRequestParameter( value ) );
179            }
180    
181            /**
182             * こã?オブジェクトã?æ–?­—å?表現を返しますã?
183             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
184             *
185             * @return こã?クラスのæ–?­—å?表現
186             */
187            @Override
188            public String toString() {
189                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
190                                    .println( "VERSION"             ,VERSION        )
191                                    .println( "Other..."    ,getAttributes().getAttribute() )
192                                    .fixForm().toString() ;
193    
194            }
195    }