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.fukurou.util.XHTMLTag; 020 021import org.opengion.fukurou.util.StringUtil; 022 023/** 024 * 【入力】複数行の入力が可能なテキスト入力フィールドを作成するHTML拡張タグです。 025 * 026 * name 属性に ラベルリソース のキーを与えることで、 ロケールにあわせたリソースを使用して、 027 * 画面に表示します。 028 * ロケールは、ユーザー情報の lang 属性を初期値で使用し、 セットされていない場合は、 029 * リクエスト情報のロケールから取得します。 030 * ラベル部分と入力フィールド部分がテーブルタグの <td> により左右に分割されます。 031 * HTML 表示時は、前後に<tr>タグで囲って、 整形できます。 032 * 033 * @og.formSample 034 * ●形式:<og:queryOption > 035 * SELECT文 036 * </og:queryOption > 037 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します) 038 * 039 * ●Tag定義: 040 * <og:textarea 041 * name ○【HTML】名前を指定します(必須)。 042 * lbl 【TAG】ラベルリソースのラベルIDを指定します 043 * rows 【HTML】高さ(行数)を指定します 044 * cols 【HTML】横幅(カラム数)を指定します 045 * must 【TAG】必須入力を表す色に変えるかどうか[true/false]を指定します(初期値:false) 046 * mustAny 【TAG】選択必須入力(どれかひとつ必須)を表す色[true/mustAny/その他]を指定します(初期値:無指定) 047 * aimai 【TAG】曖昧検索可能フィールドとして、曖昧検索方法を指定します(初期値:null) 048 * id 【HTML】要素に対して固有の名前(id)をつける場合に設定します 049 * lang 【HTML】要素の内容と他の属性値の言語(lang,xml:lang)を指定します 050 * dir 【HTML】文字表記の方向(dir)を指定します 051 * title 【HTML】要素に対する補足的情報(title)を設定します 052 * style 【HTML】この要素に対して適用させるスタイルシート(style)を設定します 053 * readonly 【TAG】その部品に対して変更が出来ないように(readonly)指定します(サーバーに送信される) 054 * disabled 【TAG】その部品に対して、選択や変更が出来ないように(disabled)指定します(サーバーに送信されない) 055 * tabindex 【HTML】タブの移動順(tabindex)を指定します(0 〜 32767) 056 * accesskey 【HTML】アクセスキー(alt+キーで直接指定)を割り当てます 057 * clazz 【HTML】要素に対して class 属性を設定します 058 * language 【TAG】タグ内部で使用する言語コード[ja/en/zh/…]を指定します 059 * onClick 【HTML】JavaScriptのイベント onClick を設定します(例:onClick="renew('query.jsp','QUERY');") 060 * onBlur 【HTML】JavaScriptのイベント onBlur を設定します(例:onBlur="this.value=value.toUpperCase();") 061 * onFocus 【HTML】JavaScriptのイベント onFocus を設定します 062 * ondblClick 【HTML】JavaScriptのイベント ondblClick を設定します 063 * onMouseDown 【HTML】JavaScriptのイベント onMouseDown を設定します 064 * onMouseUp 【HTML】JavaScriptのイベント onMouseUp を設定します 065 * onMouseMove 【HTML】JavaScriptのイベント onMouseMove を設定します 066 * onMouseOut 【HTML】JavaScriptのイベント onMouseOut を設定します 067 * onMouseOver 【HTML】JavaScriptのイベント onMouseOver を設定します 068 * onSelect 【HTML】JavaScriptのイベント onSelect を設定します 069 * onKeydown 【HTML】JavaScriptのイベント onKeydown を設定します 070 * onKeypress 【HTML】JavaScriptのイベント onKeypress を設定します 071 * onKeyup 【HTML】JavaScriptのイベント onKeyup を設定します 072 * autofocus 【HTML5】指定した入力欄にカーソルが当たって自動的にフォーカスされます。 073 * placeholder 【HTML5】入力欄に初期表示する内容を指定します。 074 * required 【HTML5】入力必須を指定します 075 * roles 【TAG】ロールをセットします 076 * useRealTimeCheck 【TAG】リアルタイムチェックを行うかどうか(初期値:行う) 077 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 078 * > ... Body ... 079 * </og:textarea> 080 * 081 * ●使用例 082 * <og:textarea name="BUN" /> 083 * 084 * <og:textarea name="BUN"> 初期値に値をセットしたいとき 085 * test 086 * </og:textarea name="BUN"> 087 * 088 * @og.group 画面部品 089 * 090 * @version 4.0 091 * @author Kazuhiko Hasegawa 092 * @since JDK5.0, 093 */ 094public class TextareaTag extends HTMLTagSupport { 095 //* このプログラムのVERSION文字列を設定します。 {@value} */ 096 private static final String VERSION = "5.2.1.0 (2010/10/01)" ; 097 098 private static final long serialVersionUID = 521020101001L ; 099 100 /** 101 * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。 102 * 103 * @return 後続処理の指示( EVAL_BODY_BUFFERED ) 104 */ 105 @Override 106 public int doStartTag() { 107 return( EVAL_BODY_BUFFERED ); // Body を評価する。( extends BodyTagSupport 時) 108 } 109 110 /** 111 * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。 112 * 113 * @og.rev 3.1.1.0 (2003/03/28) ボディの内容を取得する処理を、CommonTagSupport で行う。 114 * @og.rev 3.1.1.0 (2003/03/28) body 属性に、 {@XXXX} パース機能を付加する。 115 * 116 * @return 後続処理の指示(SKIP_BODY) 117 */ 118 @Override 119 public int doAfterBody() { 120 String str = getBodyString(); 121 122 if( str != null && str.length() > 0 ) { 123 String label = StringUtil.htmlFilter( str ); 124 if( label != null && label.length() > 0 ) { 125 set( "body",label ); 126 } 127 } 128 129 return(SKIP_BODY); 130 } 131 132 /** 133 * 検索条件の入力用のテキストフィールドを作成します。 134 * 135 * テーブルタグによりフィールドは分割されます。 136 * 使用時は、テーブルタグを前後に使用して下さい。 137 * 138 * @og.rev 4.3.7.1 (2009/06/08) id=labelのclass化 139 * @og.rev 5.2.1.0 (2010/10/01) must , mustAny 属性を自動化します。 140 * @og.rev 5.8.4.1 (2015/02/20) aimai対応 6.2.0.0逆移植 141 * 142 * @return 入力用のテキストフィールドタグ 143 */ 144 @Override 145 protected String makeTag() { 146 StringBuilder rtn = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 147 if( getMsglbl() == null ) { setLbl( get( "name" ) ); } 148 149 // 4.3.7.1 (2009/06/08) id=labelのclass化 150 // rtn.append( "<td id=\"label\">" ); 151 rtn.append( "<td class=\"label\">" ); 152 rtn.append( getLongLabel() ); // 4.0.0 (2005/01/31) 153 rtn.append( "</td>" ); 154 rtn.append( "<td>" ); 155 rtn.append( XHTMLTag.textarea( getAttributes() ) ); 156 rtn.append( "</td>" ); 157 158 rtn.append( makeAimaiPicker( get( "name" ) ) ); 159 // 5.2.1.0 (2010/10/01) must , mustAny 属性を自動化します。 160 if( getMustType() != null ) { rtn.append( makeMustHidden( get( "name" ) ) ); } 161 162 return rtn.toString() ; 163 } 164 165 /** 166 * 【HTML】名前を指定します。 167 * 168 * @og.tag 名前を指定します。 169 * 170 * @param name 名前 171 */ 172 public void setName( final String name ) { 173 set( "name",getRequestParameter( name ) ); 174 } 175 176 /** 177 * 【HTML】高さ(行数)を指定します。 178 * 179 * @og.tag 高さ(行数)を指定します。 180 * 181 * @param rows 高さ(行数) 182 */ 183 public void setRows( final String rows ) { 184 set( "rows",getRequestParameter( rows ) ); 185 } 186 187 /** 188 * 【HTML】横幅(カラム数)を指定します。 189 * 190 * @og.tag 横幅を指定します。 191 * 192 * @param cols 横幅(カラム数) 193 */ 194 public void setCols( final String cols ) { 195 set( "cols",getRequestParameter( cols ) ); 196 } 197 198 /** 199 * 【TAG】リアルタイムチェックを行わない指定。 200 * 201 * @og.tag 202 * カラム単位でリアルタイムチェックを行わない設定をします。 203 * タグに独自属性としてrealTimeChk="xxx"を追記します。 204 * falseを設定した場合にチェックが行われなくなります。 205 * 初期値はリアルタイムチェックを行う(何も指定しない)です。 206 * 207 * この属性は、optionAttributesへの設定と同様の動作を行います。 208 * 209 * @og.rev 5.9.32.2 (2018/05/18) 新規追加 210 * 211 * @param flg リアルタイムチェックを行うかどうか 212 */ 213 public void setUseRealTimeCheck( final String flg ) { 214 String rtcf = getRequestParameter( flg ); 215 // optionAttributes扱いで登録します。 216 if( rtcf != null && rtcf.length() > 0 ){ 217 add( "optionAttributes", " realTimeChk=\""+getRequestParameter( flg )+"\"" ); 218 } 219 } 220}