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 }