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 */ 016package org.opengion.hayabusa.taglib; 017 018import org.opengion.hayabusa.common.HybsSystem; 019import org.opengion.hayabusa.common.HybsSystemException; 020import org.opengion.fukurou.util.XHTMLTag; 021 022import static org.opengion.fukurou.util.StringUtil.nval ; 023 024/** 025 * 入力フィールドやボタンなどを作成するHTML拡張タグです。 026 * 027 * 簡易的な入力用タグとして、columnタグがありますので、通常は、columnタグをお使い下さい。 028 * name 属性に ラベルリソース のキーを与えることで、ロケールにあわせたリソースを 029 * 使用して、画面に表示します。 030 * ロケールは、session 登録項目の HybsSystem#LANG_KEY を初期値で使用し、 031 * language 属性で定義されている場合は、そちらを優先します。 032 * 033 * @og.formSample 034 * ●形式:<og:input name=… value=… /> 035 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します) 036 * 037 * ●Tag定義: 038 * <og:input 039 * type 【HTML】表示形式[text/password/checkbox/radio/submit/reset/button/image/file]を指定します(初期値:text) 040 * HTML5追加分[search/tel/url/email/datetime/date/month/week/time/datetime-local/number/range/color] 041 * name 【HTML】名前を指定します 042 * value 【HTML】このフィールドに設定する値を指定します 043 * caseKey 【TAG】このタグ自体を利用するかどうかの条件キーを指定します(初期値:null) 044 * caseVal 【TAG】このタグ自体を利用するかどうかの条件値を指定します(初期値:null) 045 * caseNN 【TAG】指定の値が、null/ゼロ文字列 でない場合(Not Null=NN)は、このタグは使用されます(初期値:true) 046 * caseNull 【TAG】指定の値が、null/ゼロ文字列 の場合は、このタグは使用されます(初期値:true) 047 * lbl 【TAG】ラベルリソースのラベルIDを指定します 048 * lbls 【TAG】ラベルをCSV形式で複数指定します 049 * td 【TAG】テーブル形式の <td> タグを使用するかどうか[yes/no/false]を指定します(初期値:yes) 050 * colspan 【TAG】フィールド部分の colspan を指定します 051 * nextForm 【TAG】入力カーソルを指定されたname属性のフィールドへ自動的に移動します 052 * optionAttributes 【TAG】JavaScript などの HTML基本タグ以外の属性を、そのままタグとして使用します 053 * must 【TAG】必須入力を表す色に変えるかどうか[true/false]を指定します(初期値:false) 054 * mustAny 【TAG】選択必須入力(どれかひとつ必須)を表す色[true/mustAny/その他]を指定します(初期値:無指定) 055 * size 【HTML】横幅を指定します(typeがtextまたはpasswordの場合は文字数で、それ以外はピクセル) 056 * maxlength 【HTML】最大入力文字数を指定します(typeがtextまたはpasswordの場合) 057 * checked 【HTML】type が checkbox か radio のとき、初めから選択された状態で表示します("checked"のみ指定可) 058 * src 【HTML】type が image の場合、送信ボタンとして利用する画像のURLをセットします 059 * alt 【HTML】type が image の場合で、画像が表示できない場合の代替テキストをセットします 060 * accept 【HTML】type が file の場合に、MIMEタイプをCSV形式で複数指定出来ます 061 * usemap 【HTML】type が image の場合、クライアントサイド・イメージマップのURLを指定します 062 * ismap 【HTML】type が image の場合に、サーバーサイド・イメージマップを使用する場合に指定します 063 * id 【HTML】要素に対して固有の名前(id)をつける場合に設定します 064 * lang 【HTML】要素の内容と他の属性値の言語(lang,xml:lang)を指定します 065 * dir 【HTML】文字表記の方向(dir)を指定します 066 * title 【HTML】要素に対する補足的情報(title)を設定します 067 * style 【HTML】この要素に対して適用させるスタイルシート(style)を設定します 068 * readonly 【TAG】その部品に対して変更が出来ないように(readonly)指定します(サーバーに送信される) 069 * disabled 【TAG】その部品に対して、選択や変更が出来ないように(disabled)指定します(サーバーに送信されない) 070 * tabindex 【HTML】タブの移動順(tabindex)を指定します(0 ~ 32767) 071 * accesskey 【HTML】アクセスキー(alt+キーで直接指定)を割り当てます 072 * clazz 【HTML】要素に対して class 属性を設定します 073 * language 【TAG】タグ内部で使用する言語コード[ja/en/zh/…]を指定します 074 * onClick 【HTML】JavaScriptのイベント onClick を設定します(例:onClick="renew('query.jsp','QUERY');") 075 * onChange 【HTML】JavaScriptのイベント onChange を設定します(例:onChange="renew('query.jsp','QUERY');") 076 * onBlur 【HTML】JavaScriptのイベント onBlur を設定します(例:onBlur="this.value=value.toUpperCase();") 077 * onFocus 【HTML】JavaScriptのイベント onFocus を設定します 078 * ondblClick 【HTML】JavaScriptのイベント ondblClick を設定します 079 * onMouseDown 【HTML】JavaScriptのイベント onMouseDown を設定します 080 * onMouseUp 【HTML】JavaScriptのイベント onMouseUp を設定します 081 * onMouseMove 【HTML】JavaScriptのイベント onMouseMove を設定します 082 * onMouseOut 【HTML】JavaScriptのイベント onMouseOut を設定します 083 * onMouseOver 【HTML】JavaScriptのイベント onMouseOver を設定します 084 * onSelect 【HTML】JavaScriptのイベント onSelect を設定します 085 * onKeydown 【HTML】JavaScriptのイベント onKeydown を設定します 086 * onKeypress 【HTML】JavaScriptのイベント onKeypress を設定します 087 * onKeyup 【HTML】JavaScriptのイベント onKeyup を設定します 088 * autocomplete 【HTML5】入力候補を提示して入力内容を自動補完する[on/off](初期値はon)。 089 * autofocus 【HTML5】指定した入力欄にカーソルが当たって自動的にフォーカスされます。 090 * pattern 【HTML5】正規表現で入力値のパターンを指定します。 091 * placeholder 【HTML5】入力欄に初期表示する内容を指定します。 092 * required 【HTML5】入力必須を指定します 093 * list 【HTML5】ユーザーに入力候補として提案するデータリストの要素のid属性の値を指定します。 094 * min 【HTML5】入力欄で入力できる最小値を指定します。 095 * max 【HTML5】入力欄で入力できる最大値を指定します。 096 * step 【HTML5】入力欄で刻むステップ値を指定する。 097 * roles 【TAG】ロールをセットします 098 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 099 * > ... Body ... 100 * </og:input> 101 * 102 * ●使用例 103 * <og:input name="OYA" /> lbl属性が指定されていない場合は、name属性をキーにしてLabelResourceを読み取ります。 104 * <og:input name="PN" lbl="KO" /> lbl属性を指定することで、ラベルだけを付替えることができます。 105 * <og:input name="PN" size="13" maxlength="11" /> 強制的にサイズの変更をするときは、size属性、maxlength属性を使用できます。 106 * <og:input name="OYA" td="false" /> 自動作成されるtdタグやラベルを外すときはtd属性を使います。 107 * <og:input name="OYA" td="no" /> 自動作成されるtdタグを外し、ラベルとフィールドは残します。 108 * <og:input name="PN" optionAttributes="onBlur='blr()' 109 * onFocus='fcs()'" /> 110 * JavaScriptのイベントをコーディングするときは、optionAttributes属性を使います。 111 * <og:input type="radio" name="OYA" /> ラベル部分と入力フィールド部分がテーブルタグの<td>により左右に分割されます。 112 * 113 * <table> 114 * <tr><og:input name="PN" value="{@PN}" /></tr> 115 * <tr><og:input name="CD" value="{@CD}" /></tr> 116 * </table> 117 * 118 * <table> 119 * <tr><og:input name="PN" value="{@PN}" >部品入力フィールド</og:input></tr> 120 * <tr><og:input name="CD" value="{@CD}" >コードフィールド</og:input></tr> 121 * </table> 122 * HTML 表示時は、前後に<tr>タグで囲って,整形できます。 123 * 124 * <og:input name="A" nextForm="B" /> 最大桁数入力後、フォーム B にフォーカスが移動します。 125 * <og:input name="B" /> 126 * 127 * BODY 部分に記述した値は、入力フィールドの直後にセットされます。 128 * <og:input name="PN" > 129 * <button type="button" onclick="popup(・・・);return false;"> 130 * <og:message lbl="POPUP" comment="▼" /> 131 * </button> 132 * </og:input> 133 * 134 * @og.group 画面部品 135 * 136 * @version 4.0 137 * @author Kazuhiko Hasegawa 138 * @since JDK5.0, 139 */ 140public class InputTag extends HTMLTagSupport { 141 //* このプログラムのVERSION文字列を設定します。 {@value} */ 142 private static final String VERSION = "5.7.1.0 (2013/12/06)" ; 143 144 private static final long serialVersionUID = 571020131206L ; 145 146 // 5.7.1.0 (2013/12/06) HTML5 で新たに追加された、type を追加 147 private static final String CHECK_TYPE = "|text|password|checkbox|radio|submit|reset|button|image|file|hidden|" 148 + "search|tel|url|email|datetime|date|month|week|time|datetime-local|number|range|color|" ; 149 150 // 4.0.0 (2005/01/31) HTML_LABEL_SEPARATOR を boolean 変数として取得します。 151 private final String CLM = HybsSystem.sysBool( "HTML_LABEL_SEPARATOR" ) ? ":" : "" ; 152 153 private String td_flag = "yes"; // yes:<td> タグを使用 / false:フィールドのみ / no:ラベルとフィールド 154 // 3.0.1.4 (2003/03/17) colspan 属性を追加。 155 private String colspan = ""; 156 // 3.5.4.2 (2003/12/15) nextForm 属性を追加。 157 private String nextForm = null; 158 159 // 4.0.0 (2005/01/31) COLUMNS_MAXSIZE を定義しておきます。 160 private final int COLUMNS_MAXSIZE = HybsSystem.sysInt( "HTML_COLUMNS_MAXSIZE" ) ; // 表示フィールドの大きさ 161 162 // 4.0.0 (2007/05/30) BODY 部分に記述した値は、入力フィールドの直後にセットされます。 163 private String body = null; 164 165 /** 166 * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。 167 * 168 * @og.rev 4.0.0.0 (2007/05/30) 新規追加(BODY部の評価) 169 * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属性対応 170 * 171 * @return 後続処理の指示( EVAL_BODY_BUFFERED ) 172 */ 173 @Override 174 public int doStartTag() { 175 // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属性対応 176 if( useTag() ) { 177 return EVAL_BODY_BUFFERED ; // Body を評価する。( extends BodyTagSupport 時) 178 } 179 return SKIP_BODY ; // Body を評価しない 180 } 181 182 /** 183 * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。 184 * 185 * @og.rev 4.0.0.0 (2007/05/30) 新規追加(BODY部の評価) 186 * 187 * @return 後続処理の指示(SKIP_BODY) 188 */ 189 @Override 190 public int doAfterBody() { 191 body = getBodyString(); 192 return SKIP_BODY ; 193 } 194 195 /** 196 * タグリブオブジェクトをリリースします。 197 * キャッシュされて再利用されるので、フィールドの初期設定を行います。 198 * 199 * @og.rev 2.0.0.4 (2002/09/27) カスタムタグの release() メソッドを、追加 200 * @og.rev 2.0.0.8 (2002/10/09) yes/no/false で指定するように変更 201 * @og.rev 3.0.1.4 (2003/03/17) colspan 属性を追加。 202 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。 203 * @og.rev 3.5.4.2 (2003/12/15) nextForm 属性を追加。 204 */ 205 @Override 206 protected void release2() { 207 super.release2(); 208 td_flag = "yes"; // table形式の <td> タグを使用するかどうか 209 colspan = ""; 210 nextForm = null; // 3.5.4.2 (2003/12/15) 211 } 212 213 /** 214 * 検索条件の入力用のテキストフィールドを作成します。 215 * 216 * テーブルタグによりフィールドは分割されます。 217 * 使用時は、テーブルタグを前後に使用して下さい。 218 * 219 * @og.rev 2.0.0.8 (2002/10/09) yes/no/false で指定するように変更 220 * @og.rev 2.0.1.0 (2002/10/10) ラベルとフィールドのセパレーターとして、コロン(:)を使用するかどうかを指定できる 221 * @og.rev 3.0.1.2 (2003/03/07) forward.jsp の代替用 CommonForwardTag を新規作成 222 * @og.rev 3.1.0.1 (2003/03/26) キャッシュエントリーは、type="submit" の場合のみ、登録する。 223 * @og.rev 3.1.1.0 (2003/03/28) forward.jsp 関係の処理を削除する。 224 * @og.rev 3.1.1.0 (2003/03/28) radio ボタン等で、ラベルをクリックしても値をセットできるようにする。 225 * @og.rev 3.5.4.2 (2003/12/15) 入力カーソルを自動的に次のフィールドへ移動する機能を追加する。 226 * @og.rev 4.0.0.0 (2007/05/30) BODY 部分に記述した値は、入力フィールドの直後にセットされます。 227 * @og.rev 4.3.7.1 (2009/06/08) id=labelのclass化 228 * @og.rev 5.2.1.0 (2010/10/01) must , mustAny 属性を自動化します。 229 * @og.rev 5.6.2.2 (2013/03/15) 自動must処理の出力位置を変更 230 * 231 * @return 入力用のテキストフィールドタグ 232 */ 233 @Override 234 protected String makeTag() { 235 if( get( "value" ) == null ) { set( "value","" ); } 236 if( getMsglbl() == null ) { setLbl( get( "name" ) ); } 237 238 // 3.5.4.2 (2003/12/15) 入力カーソルを自動的に次のフィールドへ移動する機能 239 if( nextForm != null ) { 240 String onKeyup = "nextForm(this,'" + nextForm + "'," + get( "maxlength" ) + ");" ; 241 set( "onKeyup",onKeyup ); 242 } 243 244 String type = get( "type" ); 245 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 246 // もう少しましな、別の方法を考える必要があります。 247 if( "yes".equals( td_flag ) ) { 248 if( type != null && ( "radio".equals( type ) || "checkbox".equals( type ) )) { 249 if( get( "id" ) == null ) { set( "id",TaglibUtil.getTagId() ); } 250 251 rtn.append( "<td>" ); 252 rtn.append( XHTMLTag.input( getAttributes() ) ); 253 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 254 rtn.append( "</td>" ); 255 rtn.append( "<td " ); 256 rtn.append( colspan ); 257 rtn.append( ">" ); 258 rtn.append( "<label for=\"" ); 259 rtn.append( get( "id" ) ); 260 rtn.append( "\">" ); 261 rtn.append( getLongLabel() ); // 4.0.0 (2005/01/31) 262 rtn.append( "</label>" ); 263 } 264 else if( type != null && ( "submit".equals( type ) || "reset".equals( type ) || "button".equals( type ) ) ) { 265 set( "value",getMsglbl() ); 266 rtn.append( "<td" ); 267 rtn.append( colspan ); 268 rtn.append( ">" ); 269 rtn.append( XHTMLTag.input( getAttributes() ) ); 270 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 271 rtn.append( "</td>" ); 272 rtn.append( "<td>" ); 273 } 274 else { 275 // 4.3.7.1 (2009/06/08) id=labelのclass化 276 // rtn.append( "<td id=\"label\">" ); 277 rtn.append( "<td class=\"label\">" ); 278 rtn.append( getLongLabel() ); // 4.0.0 (2005/01/31) 279 rtn.append( CLM ); 280 rtn.append( "</td>" ); 281 rtn.append( "<td" ); 282 rtn.append( colspan ); 283 rtn.append( ">" ); 284 rtn.append( XHTMLTag.input( getAttributes() ) ); 285 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 286 } 287 if( getMustType() != null ) { rtn.append( makeMustHidden( get( "name" ) ) ); } // 5.6.2.2 (2013/03/15) 288 rtn.append( "</td>" ); 289 } 290 else if( "no".equals( td_flag ) ) { 291 if( type != null && ( "radio".equals( type ) || "checkbox".equals( type ) )) { 292 rtn.append( "<label>" ); 293 rtn.append( XHTMLTag.input( getAttributes() ) ); 294 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 295 // 4.3.7.1 (2009/06/08) id=labelのclass化 296 // rtn.append( "<span id=\"label\">" ); 297 rtn.append( "<span class=\"label\">" ); 298 rtn.append( getLongLabel() ); // 4.0.0 (2005/01/31) 299 rtn.append( "</span>" ); 300 rtn.append( "</label>" ); 301 } 302 else if( type != null && ( "submit".equals( type ) || "reset".equals( type ) || "button".equals( type ) ) ) { 303 set( "value",getMsglbl() ); 304 rtn.append( XHTMLTag.input( getAttributes() ) ); 305 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 306 } 307 else { 308 // 4.3.7.1 (2009/06/08) id=labelのclass化 309 // rtn.append( "<span id=\"label\">" ); 310 rtn.append( "<span class=\"label\">" ); 311 rtn.append( getLongLabel() ); // 4.0.0 (2005/01/31) 312 rtn.append( CLM ); 313 rtn.append( "</span>" ); 314 rtn.append( XHTMLTag.input( getAttributes() ) ); 315 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 316 } 317 if( getMustType() != null ) { rtn.append( makeMustHidden( get( "name" ) ) ); } // 5.6.2.2 (2013/03/15) 318 } 319 else { 320 if( type != null && ( "submit".equals( type ) || "reset".equals( type ) || "button".equals( type ) ) ) { 321 set( "value",getMsglbl() ); 322 rtn.append( XHTMLTag.input( getAttributes() ) ); 323 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 324 } 325 else { 326 rtn.append( XHTMLTag.input( getAttributes() ) ); 327 if( body != null ) { rtn.append( body ); } // 4.0.0 (2007/05/30) BODY部の評価 328 } 329 if( getMustType() != null ) { rtn.append( makeMustHidden( get( "name" ) ) ); } // 5.6.2.2 (2013/03/15) 330 } 331 332 return rtn.toString() ; 333 } 334 335 /** 336 * 【HTML】名前を指定します。 337 * 338 * @og.tag 339 * <og:input name="PN" /> 340 * 341 * @param name 名前 342 */ 343 public void setName( final String name ) { 344 set( "name",getRequestParameter( name ) ); 345 } 346 347 /** 348 * 【HTML】表示形式を指定します(初期値:text)。 349 * 350 * @og.tag 351 * 通常は、表示形式[text/password/checkbox/radio/submit/reset/button/image/file]を指定します。 352 * HTML5 で追加された形式[search/tel/url/email/datetime/date/month/week/time/datetime-local/number/range/color] 353 * も、設定できます。 354 * 355 * HTML5 の機能を有効にするには、ネイティブモードで動作させる必要があります。 356 * ① USE_IE7_HEADER = "false" に設定する。 357 * ② USE_HTML5_HEADER = "true" に設定する。 358 * ③ IEのツール⇒互換表示設定で、互換表示に追加したWebサイトから削除する。 359 * ④ 同上の設定で、イントラサイトを互換表示で表示するのチェックを外す。 360 * 必要があります。 361 * 362 * <og:input type="text" /> テキストボックスを表示 363 * <og:input type="password" /> パスワード専用テキストボックスを表示 364 * <og:input type="checkbox" /> チェックボックスを表示 365 * <og:input type="radio" /> ラジオボタンを表示 366 * <og:input type="submit" /> 送信実行ボタンを表示 367 * <og:input type="reset" /> 入力したフィールド内容を全てリセット 368 * <og:input type="button" /> ボタンを表示 369 * <og:input type="image" /> イメージを表示してクリックした座標を返す 370 * <og:input type="file" /> ファイル名入力ボックスを表示 371 * <og:input type="hidden" /> 表示させずにサーバーに送信するデータ 372 * 373 * HTML5 で追加されたタイプ 374 * <og:input type="search" /> 検索テキストの入力欄を作成する 375 * <og:input type="tel" /> 電話番号の入力欄を作成する 376 * <og:input type="url" /> URLの入力欄を作成する 377 * <og:input type="email" /> メールアドレスの入力欄を作成する 378 * <og:input type="datetime" /> UTC(協定世界時)による日時の入力欄を作成する 379 * <og:input type="date" /> 日付の入力欄を作成する 380 * <og:input type="month" /> 月の入力欄を作成する 381 * <og:input type="week" /> 週の入力欄を作成する 382 * <og:input type="time" /> 時間の入力欄を作成する 383 * <og:input type="datetime-local" /> UTC(協定世界時)によらないローカル日時の入力欄を作成する 384 * <og:input type="number" /> 数値の入力欄を作成する 385 * <og:input type="range" /> レンジの入力欄を作成する 386 * <og:input type="color" /> 色の入力欄を作成する 387 * 388 * @og.rev 5.7.1.0 (2013/12/06) HTML5 対応 389 * 390 * @param type 表示形式[text/password/checkbox/radio/submit/reset/button/image/file]、HTML5用 [search/tel/url/email/datetime/date/month/week/time/datetime-local/number/range/color] 391 */ 392 public void setType( final String type ) { 393 String tp = getRequestParameter( type ); 394 395 if( check( "|" + tp + "|" , CHECK_TYPE ) ) { 396 set( "type",tp ); 397 } 398 else { 399 String errMsg = "type 属性は、下記の中から選択してください。type=[" 400 + tp + " in [" + CHECK_TYPE + "]"; 401 throw new HybsSystemException( errMsg ); 402 } 403 } 404 405 /** 406 * 【HTML】このフィールドに設定する値を指定します。 407 * 408 * @og.tag 409 * type属性の値が"radio"か"checkbox"以外の場合、この属性は省略可能です。 410 *<og:input name="PN" value="syokichi" /> 411 * 412 * @param value 初期値 413 */ 414 public void setValue( final String value ) { 415 set( "value",getRequestParameter( value ) ); 416 } 417 418 /** 419 * 【HTML】横幅を指定します(typeがtextまたはpasswordの場合は文字数で、それ以外はピクセル)。 420 * 421 * @og.tag 422 * <og:input name="PN" size="20" /> 423 * 424 * @param size 横幅 425 */ 426 public void setSize( final String size ) { 427 set( "size",getRequestParameter( size ) ); 428 } 429 430 /** 431 * 【HTML】最大入力文字数を指定します(typeがtextまたはpasswordの場合)。 432 * 433 * @og.tag 434 * 最大文字数はsize指定を超え得るが、超えた場合ユーザエージェントはスクロール機構を提供する必要があります。 435 *この属性の初期値は「無制限」です。 436 *<og:input name="PN" maxlength="20" /> 437 * 438 * @og.rev 3.5.4.2 (2003/12/15) 最大入力制限数に応じたサイズ自動生成を入れます。 439 * @og.rev 3.5.4.5 (2004/01/23) CSSで処理する場合のクラス属性は、maxlength が 5 以下の場合とする。 440 * @og.rev 4.0.0.0 (2005/01/31) getFieldSize メソッドを XHTMLTag から DBColumn へ移動 441 * 442 * @param maxlength 最大入力文字数 443 */ 444 public void setMaxlength( final String maxlength ) { 445 String mlen = nval( getRequestParameter( maxlength ),null ) ; 446 set( "maxlength",mlen ); 447 if( get( "size" ) == null && mlen != null ) { 448 // 4.0.0 (2005/01/31) getFieldSize メソッドを XHTMLTag から DBColumn へ移動 449 int size = Integer.parseInt( mlen ); 450 if( size > COLUMNS_MAXSIZE ) { size = COLUMNS_MAXSIZE; } 451 set( "size",String.valueOf( size ) ); 452 } 453 454 // 3.5.4.5 (2004/01/23) 追加 455 if( mlen != null && mlen.length() == 1 ) { 456 char ch = mlen.charAt(0); 457 if( ch >= '1' && ch <= '5' ) { 458 add( "class", "S0" + ch ); // 3.5.5.9 (2004/06/07) セパレータ引数付きのメソッドに変更 459 } 460 } 461 } 462 463 /** 464 * 【HTML】type が checkbox か radio のとき、初めから選択された状態で表示します("checked"のみ指定可)。 465 * 466 * @og.tag 467 * 468 * <og:input name="PN" type="checkbox" checked="checked" /> 469 * 470 * @param ch 選択された状態にするかどうか[checked:選択状態/そのた:なにもしない] 471 */ 472 public void setChecked( final String ch ) { 473 String checked = getRequestParameter( ch ); 474 if( "checked".equals( checked )) { 475 set( "checked","checked" ); 476 } 477 } 478 479 /** 480 * 【HTML】type が image の場合、送信ボタンとして利用する画像のURLをセットします。 481 * 482 * @og.tag src セット 483 * 484 * @param src 画像のURL 485 */ 486 public void setSrc( final String src ) { 487 set( "src",getRequestParameter( src ) ); 488 } 489 490 /** 491 * 【HTML】type が image の場合で、画像が表示できない場合の代替テキストをセットします。 492 * 493 * @og.tag alt セット 494 * 495 * @param alt 代替テキスト 496 */ 497 public void setAlt( final String alt ) { 498 set( "alt",getRequestParameter( alt ) ); 499 } 500 501 /** 502 * 【HTML】type が file の場合に、MIMEタイプをCSV形式で複数指定出来ます。 503 * 504 * @og.tag accept セット 505 * 506 * @param accept MIMEタイプ(CSV形式) 507 */ 508 public void setAccept( final String accept ) { 509 set( "accept",getRequestParameter( accept ) ); 510 } 511 512 /** 513 * 【HTML】type が image の場合、クライアントサイド・イメージマップのURLを指定します。 514 * 515 * @og.tag usemap セット 516 * 517 * @param usemap クライアントサイド・イメージマップのURL 518 */ 519 public void setUsemap( final String usemap ) { 520 set( "usemap",getRequestParameter( usemap ) ); 521 } 522 523 /** 524 * 【HTML】type が image の場合に、サーバーサイド・イメージマップを使用する場合に指定します。 525 * 526 * @og.tag ismap セット 527 * 528 * @param ismap サーバーサイド・イメージマップを使用する場合に指定 529 */ 530 public void setIsmap( final String ismap ) { 531 set( "ismap",getRequestParameter( ismap ) ); 532 } 533 534 /** 535 * 【TAG】テーブル形式の <td> タグを使用するかどうか[yes/no/false]を指定します(初期値:yes)。 536 * 537 * @og.tag 538 * 通常(初期値:yes)は、テーブル形式の<td> タグを使用して、ラベルとフィールドを整列させます。 539 * no の場合は、tdタグを使用せず、ラベルとフィールドを連続して出力します。 540 * false は、ラベルを出力せず、フィールドのみ出力します。 541 * <og:input name="PN" td="false" /> 542 * 543 * @og.rev 2.0.0.8 (2002/10/09) yes/no/false で指定するように変更 544 * 545 * @param flag [yes:tdタグを使用/no:ラベルとフィールド/false:フィールドのみ] 546 */ 547 public void setTd( final String flag ) { 548 String td = nval( getRequestParameter( flag ),td_flag ); 549 550 if( check( "|" + td + "|" , "|yes|no|false|" ) ) { 551 td_flag = td; 552 } 553 else { 554 String errMsg = "td 属性は、下記の中から選択してください。td=[" 555 + td + " in [|true|false|label|]"; 556 throw new HybsSystemException( errMsg ); 557 } 558 } 559 560 /** 561 * 【TAG】ラベルをCSV形式で複数指定します。 562 * 563 * @og.tag 564 * シングルラベルの lbl 属性との違いは,ここではラベルを複数 カンマ区切りで 565 * 渡すことが可能であることです。これにより、"A,B,C" という値に対して、 566 * "Aのラベル表示,Bのラベル表示,Cのラベル表示" という具合に文字列を 567 * 再合成します。 568 * これは、SQL文のOrder By 句で、ソート順を指定する場合などに便利です。 569 * 570 * <og:orderBy columns="MKNMJP,MKCD,MKNMEN" lbls="MKNMJP,MKCD,MKNMEN" /> 571 * 572 * @og.rev 3.5.6.2 (2004/07/05) 先に配列に分解してからリクエスト変数の値を取得 573 * @og.rev 5.2.2.0 (2010/11/01) setMsglbl 廃止 ⇒ setLbl に置換え 574 * 575 * @param lbls 複数ラベルID(カンマ区切り) 576 */ 577 public void setLbls( final String lbls ) { 578 579 String[] array = getCSVParameter( lbls ); 580 581 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 582 583 buf.append( getLabel( array[0] ) ); 584 for( int i=1; i<array.length; i++ ) { 585 buf.append( "," ); 586 buf.append( getLabel( array[i] ) ); 587 } 588 setLbl( buf.toString() ); // 5.2.2.0 (2010/11/01) setMsglbl 廃止 ⇒ setLbl に置換え 589 } 590 591 /** 592 * 【TAG】フィールド部分の colspan を指定します。 593 * 594 * @og.tag 595 * 通常は、ラベルとフィールドが、別のtdで囲われます。しかし、場合によっては、 596 * フィールド部の長いカラムがある場合、上下のカラムとの位置関係がおかしくなり、 597 * ラベルとフィールドが離れて表示されるケースがあります。 598 * この場合、長いフィールド部を持つカラムに、colspan 属性を指定すると、 599 * その分のカラムを割り当てることにより、上下のカラムとの位置関係を 600 * 調節することが可能になります。 601 * 通常は、3 を指定して、フィールド、ラベル、フィールドの 602 * 組み合わせ部分に、長いフィールドが適用されるように使用します。 603 * 604 * <og:input name="PN" colspan="3" /> 605 * 606 * @og.rev 3.0.1.4 (2003/03/17) colspan 属性を追加。 607 * 608 * @param sp フィールド部分のcolspan 609 */ 610 public void setColspan( final String sp ) { 611 colspan = nval( getRequestParameter( sp ),colspan ); 612 if( colspan.length() > 0 ) { 613 colspan = " colspan=\"" + colspan + "\" "; 614 } 615 } 616 617 /** 618 * 【TAG】入力カーソルを指定されたname属性のフィールドへ自動的に移動します。 619 * 620 * @og.tag 621 * JavaScript の onKeyup イベントを利用して、最大桁数まで入力すると、 622 * 次のフィールドに、自動的に飛ぶように設定します。 623 * 引数は、次に飛ばすフィールドの name 属性です。 624 * 実行するには、JavaScript の nextForm ファンクションが必要です。(default.js で指定) 625 * 626 * @og.rev 3.5.4.2 (2003/12/15) 新規追加 627 * 628 * @param name 次にフォーカスを移すタグのname属性 629 */ 630 public void setNextForm( final String name ) { 631 nextForm = nval( getRequestParameter( name ),nextForm ); 632 } 633 634 /** 635 * このオブジェクトの文字列表現を返します。 636 * 基本的にデバッグ目的に使用します。 637 * 638 * @return このクラスの文字列表現 639 */ 640 @Override 641 public String toString() { 642 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 643 .println( "VERSION" ,VERSION ) 644 .println( "td_flag" ,td_flag ) 645 .println( "colspan" ,colspan ) 646 .println( "nextForm" ,nextForm ) 647 .println( "CHECK_TYPE" ,CHECK_TYPE ) 648 .println( "HTML_LABEL_SEPARATOR" ,CLM ) 649 .println( "HTML_COLUMNS_MAXSIZE" ,COLUMNS_MAXSIZE ) 650 .println( "Other..." ,getAttributes().getAttribute() ) 651 .fixForm().toString() ; 652 } 653}