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?šあã‚?
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     *       lbl                【TAG】ラベルリソースのラベルIDを指定しまã�?
044     *       id                 【HTML】要ç´?�«対して固有ã?名前(id)をつける場合に設定しまã�?
045     *       lang               【HTML】要ç´??å†?®¹と他ã?属æ?値のè¨?ª?lang,xml:lang)を指定しまã�?
046     *       dir                【HTML】文字表記ã?方å�?dir)を指定しまã�?
047     *       title              【HTML】要ç´?�«対する補足çš?ƒ…報(title)を設定しまã�?
048     *       style              【HTML】この要ç´?�«対して適用させるスタイルシーãƒ?style)を設定しまã�?
049     *       disabled           【TAG】その部品に対してã€?�¸択や変更がå?来なã�?‚ˆã�?�«(disabled)æŒ?®šしまã�?サーバã?に送信されなã�?
050     *       tabindex           【HTML】タブã?移動é?(tabindex)を指定しまã�?0 ??32767)
051     *       accesskey          【HTML】アクセスキー(alt+キーで直接æŒ?®?を割り当てまã�?
052     *       clazz              【HTML】要ç´?�«対して class 属æ?を設定しまã�?
053     *       language           【TAG】タグå†?ƒ¨で使用するè¨?ªžコード[ja/en/zh/…]を指定しまã�?
054     *       onClick            【HTML】JavaScriptのイベンãƒ?onClick を設定しまã�?ä¾?onClick="renew('query.jsp','QUERY');")
055     *       onBlur             【HTML】JavaScriptのイベンãƒ?onBlur を設定しまã�?ä¾?onBlur="this.value=value.toUpperCase();")
056     *       onFocus            【HTML】JavaScriptのイベンãƒ?onFocus を設定しまã�?
057     *       ondblClick         【HTML】JavaScriptのイベンãƒ?ondblClick を設定しまã�?
058     *       onMouseDown        【HTML】JavaScriptのイベンãƒ?onMouseDown を設定しまã�?
059     *       onMouseUp          【HTML】JavaScriptのイベンãƒ?onMouseUp を設定しまã�?
060     *       onMouseMove        【HTML】JavaScriptのイベンãƒ?onMouseMove を設定しまã�?
061     *       onMouseOut         【HTML】JavaScriptのイベンãƒ?onMouseOut を設定しまã�?
062     *       onMouseOver        【HTML】JavaScriptのイベンãƒ?onMouseOver を設定しまã�?
063     *       roles              【TAG】ロールをセãƒ?ƒˆしまã�?
064     *       debug              【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
065     *   >   ... Body ...
066     *   </og:button>
067     *
068     * ●使用ä¾?
069     * <og:button type="submit" name="test" value="1" lbl="test" />     LabelResource プロパティのラベル使用したã�?�¨ききはlbl属æ?に、LabelResourceを使ã�?�¾すã?
070     * <og:button type="submit" name="test" value="1" msg="MSG0103" />  MessageResource プロパティのラベル使用したã�?�¨きã?msg属æ?を使ã�?�¾すã?
071     *
072     * @og.group 画面部å“?
073     *
074     * @version  4.0
075     * @author   Kazuhiko Hasegawa
076     * @since    JDK5.0,
077     */
078    public class ButtonTag extends HTMLTagSupport {
079            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
080            private static final String VERSION = "5.2.2.0 (2010/11/01)" ;
081    
082            private static final long serialVersionUID = 522020101101L ;
083    
084            private static final String CHECK_TYPE = "|submit|reset|button|" ;
085    
086            /**
087             * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
088             *
089             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?ボディが存在する場合ã?みボディが呼ばれる対応ã?
090             * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
091             *
092             * @return      後続å?ç�??æŒ?¤º( EVAL_BODY_BUFFERED )
093             */
094            @Override
095            public int doStartTag() {
096                    // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
097                    if( useTag() ) {
098                            set( "body",getLongLabel() );
099                            return( EVAL_BODY_BUFFERED );   // Body を評価するã€? extends BodyTagSupport æ™?
100                    }
101                    return ( SKIP_BODY );                           // Body を評価しなã�?
102            }
103    
104            /**
105             * Taglibのタグ本体を処ç�?�™ã‚?doAfterBody() ã‚?オーバã?ライドしますã?
106             *
107             * @og.rev 3.1.1.0 (2003/03/28) ボディのå†?®¹を取得するå?ç�?‚’、CommonTagSupport で行うã€?
108             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?ボディが存在する場合ã?みボディが呼ばれる対応ã?
109             *
110             * @return      後続å?ç�??æŒ?¤º(SKIP_BODY)
111             */
112            @Override
113            public int doAfterBody() {
114                    String label = getBodyString();
115    
116                    if( label != null && label.length() > 0 ) {
117                            set( "body",label );
118                    }
119    
120                    return(SKIP_BODY);
121            }
122    
123            /**
124             * ボタンを作æ?しますã?
125             *
126             * <button type="submit" name="名前" value="値">
127             *
128             * @return  ボタンタグæ–?­—å?
129             */
130            @Override
131            protected String makeTag() {
132                    return XHTMLTag.button( getAttributes() );
133            }
134    
135            /**
136             * 【HTML】ã?タンのタイプ[submit/reset/button]を指定しますã?
137             *
138             * @og.tag
139             *
140             * submit:提å?ボタンを作æ?しますã?
141             * reset:リセãƒ?ƒˆボタンを作æ?しますã?
142             * button:押しã?タンを作æ?しますã?
143             *
144             * @param   type ボタンのタイプ[submit/reset/button]
145             */
146            public void setType( final String type ) {
147                    String tp = getRequestParameter( type );
148                    if( check( "|" + tp + "|" , CHECK_TYPE ) ) {
149                            set( "type",tp );
150                    }
151                    else {
152                            String errMsg = "type は、下記ã?ç¯?›²よりæŒ?®šしてください。type=["
153                                                     + tp + "]  in [" + CHECK_TYPE + "]";
154                            throw new HybsSystemException( errMsg );
155                    }
156            }
157    
158            /**
159             * 【HTML】ã?タンの名称を指定しますã?
160             *
161             * @og.tag
162             * @param       name    ボタンの名称
163             */
164            public void setName( final String name ) {
165                    set( "name",getRequestParameter( name ) );
166            }
167    
168            /**
169             * 【HTML】ã?タンの値を指定しますã?
170             *
171             * @og.tag
172             * @param   value ボタンの値
173             */
174            public void setValue( final String value ) {
175                    set( "value",getRequestParameter( value ) );
176            }
177    
178            /**
179             * こã?オブジェクトã?æ–?­—å?表現を返しますã?
180             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
181             *
182             * @return こã?クラスのæ–?­—å?表現
183             */
184            @Override
185            public String toString() {
186                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
187                                    .println( "VERSION"             ,VERSION        )
188                                    .println( "Other..."    ,getAttributes().getAttribute() )
189                                    .fixForm().toString() ;
190    
191            }
192    }