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.hayabusa.html.TableFormatter;
020 import org.opengion.hayabusa.html.FormatterType;
021
022 import static org.opengion.fukurou.util.StringUtil.nval ;
023
024 /**
025 * ヘッãƒ??フッター、ã?ãƒ?‚£ー部のフォーマットを汎用çš?�«定義するタグですã?
026 *
027 * thead,tfoot,tbody に代わる表示フォーマットをカスタマイズするときに使用する親クラスですã?
028 * こã?クラス自身がタグとしては表に現れませんã€?
029 *
030 * @og.formSample
031 * ●形式ï¼?タグとしては使われません)
032 * ●body?šあã‚?EVAL_BODY_BUFFERED:BODYを評価しã?{@XXXX} を解析しまã�?
033 *
034 * @og.rev 3.5.4.0 (2003/11/25) 新規追åŠ?
035 * @og.rev 3.5.4.2 (2003/12/15) カスタãƒ?‚¿グクラスから削除しますã?(abstractåŒ?
036 * @og.rev 4.0.0.0 (2006/01/31) カスタãƒ?‚¿グクラスに復活させますã?(publicåŒ?
037 * @og.group 画面部å“?
038 *
039 * @version 4.0
040 * @author Kazuhiko Hasegawa
041 * @since JDK5.0,
042 */
043 public class TFormatTag extends CommonTagSupport {
044 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
045 private static final String VERSION = "5.7.6.3 (2014/05/23)" ;
046
047 private static final long serialVersionUID = 576320140523L ;
048
049 private String rowspan = "2";
050 private String noClass = "false";
051 private String usableKey = null;
052 private String usableList = "1" ;
053 private String itdBody = ""; // 3.5.6.0 (2004/06/18)
054 private String keyBreakClm = null; // 5.7.6.3 (2014/05/23)
055 private boolean useTrCut = true; // 5.5.0.3 (2012/03/13)
056
057 /**
058 * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
059 *
060 * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
061 *
062 * @return 後続å?ç�??æŒ?¤º( EVAL_BODY_BUFFERED )
063 */
064 @Override
065 public int doStartTag() {
066 // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
067 if( useTag() ) {
068 return EVAL_BODY_BUFFERED ; // Body を評価するã€? extends BodyTagSupport æ™?
069 }
070 return SKIP_BODY ; // Body を評価しなã�?
071 }
072
073 /**
074 * Taglibの終äº?‚¿グが見つかったときに処ç�?�™ã‚?doEndTag() ã‚?オーバã?ライドしますã?
075 *
076 * @og.rev 3.5.6.0 (2004/06/18) setItdBody メソãƒ?ƒ‰による itdBody の登録処ç�?¿½åŠ?
077 * @og.rev 5.1.7.0 (2010/06/01) フォーマットã?{@XXXX}の値に[が含まれる場合ã?、サイニタイズ("\\]\\"に変換)するã€?
078 * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
079 * @og.rev 5.7.6.3 (2014/05/23) useKeyBreak 属æ?の追åŠ?
080 *
081 * @return 後続å?ç�??æŒ?¤º(EVAL_PAGE)
082 */
083 @Override
084 public int doEndTag() {
085 debugPrint(); // 4.0.0 (2005/02/28)
086 // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
087 if( useTag() ) {
088 ViewFormTag viewform = (ViewFormTag)findAncestorWithClass( this,ViewFormTag.class );
089 if( viewform == null ) {
090 String errMsg = "<b>" + getTagName() + "タグは、ViewFormTagのå†??(要ç´?に記述してくださいã€?/b>";
091 throw new HybsSystemException( errMsg );
092 }
093 // 5.1.7.0 (2010/06/01) フォーマットã?{@XXXX}の値に[が含まれる場合ã?、サイニタイズ("\\]\\"に変換)するã€?
094 // String bodyFormat = getBodyString();
095 String bodyFormat = getSanitizedBodyString();
096
097 TableFormatter format = new TableFormatter();
098 format.setFormatType( getType() );
099 format.setFormat( bodyFormat, useTrCut ); // 5.5.0.3 (2012/03/13)
100 format.setRowspan( rowspan );
101 format.setNoClass( noClass );
102 format.setUsableKey( usableKey );
103 format.setUsableList( usableList );
104 format.setItdBody( itdBody ); // 3.5.6.0 (2004/06/18)
105 format.setKeyBreakClm( keyBreakClm ); // 5.7.6.3 (2014/05/23)
106 viewform.addFormatter( format );
107 }
108 return EVAL_PAGE ; // ペã?ジの残りを評価するã€?
109 }
110
111 /**
112 * タグリブオブジェクトをリリースしますã?
113 * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
114 *
115 * @og.rev 3.5.6.0 (2004/06/18) itdBody 属æ?の追åŠ?
116 * @og.rev 5.7.6.3 (2014/05/23) useTrCut,useKeyBreak 属æ?の追åŠ?
117 *
118 */
119 @Override
120 protected void release2() {
121 super.release2();
122 rowspan = "2";
123 noClass = "false";
124 usableKey = null;
125 usableList = "1" ;
126 itdBody = ""; // 3.5.6.0 (2004/06/18)
127 useTrCut = true; // 5.7.6.3 (2014/05/23)
128 keyBreakClm = null; // 5.7.6.3 (2014/05/23)
129 }
130
131 /**
132 * 【TAG】表示ãƒ??タを作æ?する場合ã?フォーマットã?行数(rowspan)をセãƒ?ƒˆしまã�?初期値:2)ã€?
133 *
134 * @og.tag
135 * 表示ãƒ??タを作æ?する場合ã?フォーマットã?行数をセãƒ?ƒˆしますã?
136 * 上位ã? viewFormタグより、こちらが優先されますã?
137 *
138 * @param span フォーマットã?行数
139 */
140 public void setRowspan( final String span ) {
141 rowspan = span;
142 }
143
144 /**
145 * 【TAG】カラãƒ??クラスå�?VERCHAR2,NUMBER など)を使用するかどã�?�‹[true/false]を指定しまã�?初期値:false)ã€?
146 *
147 * @og.tag
148 * "true" で、クラス属æ?を設定しません。これã?ã€?¼£?³?³ファイルに書かれてã�?‚‹属æ?ã‚?
149 * 使用しなã�?�“とを意味しますã?
150 * 初期値はã€?false" ですã?
151 *
152 * @param flag クラス名使用の有無(true:使用しなã�?false:使用するã€?
153 */
154 public void setNoClass( final String flag ) {
155 this.noClass = flag;
156 }
157
158 /**
159 * こã?フォーマットã?タイプを返しますã?
160 *
161 * タイプã?ã€?head/body/foot" の中から、指定しますã?
162 *
163 * @og.rev 3.5.5.8 (2004/05/20) abstract しますã?
164 *
165 * @return こã?フォーマットã?タイプを返しますã?
166 */
167 protected FormatterType getType() {
168 String errMsg = "こã?メソãƒ?ƒ‰は、THead/TBody/TFoot のå�?‚µブクラスで実è£?�—てくださいã€?;
169 throw new UnsupportedOperationException( errMsg );
170 }
171
172 /**
173 * 【TAG】フォーマットã?使用可否を判断するキーとなるカラãƒ?��を指定しますã?
174 *
175 * @og.tag
176 * キーがã?usableList に含まれる場合ã?、このフォーãƒ?‚’使用できますã?
177 * キー(カラãƒ?��)が指定されなã�??合ã?、常に使用されますã?
178 * ※ 現時点では、BODYタイプã?み使用してã�?�¾すã?
179 * ※ こã?属æ?は、リクエスト変数処ç�?‚’行いませんã€?
180 *
181 * @param key フォーマットã?使用可否を判断するカラãƒ?��
182 */
183 public void setUsableKey( final String key ) {
184 usableKey = key;
185 }
186
187 /**
188 * 【TAG】フォーマットã?使用可否を判断するæ–?—å?リストをæŒ?®šしまã�?初期値:"1")ã€?
189 *
190 * @og.tag
191 * キーがã?こã?æ–?—å?リスト中に存在する場合ã?、このフォーãƒ?‚’使用できますã?
192 * こã?æ–?—å?リストã?、固定なæ–?—å?ですã?{@XXXX}は使用できますが、[XXXX]は
193 * 使用できませんã€?
194 * 初期値はã€?1" ですã?
195 * ※ 現時点では、BODYタイプã?み使用してã�?�¾すã?
196 *
197 * @param list フォーマットã?使用可否を判断するæ–?—å?リスãƒ?
198 */
199 public void setUsableList( final String list ) {
200 usableList = nval( getRequestParameter(list),usableList );
201 }
202
203 /**
204 * itdフォーマット文字å?を設定しますã?
205 *
206 * itd ボディ部のæ–?—å?を指定しますã?
207 * itd ボディは、繰り返し処ç�?‚’行いますã?これをã?上位ã?ボディæ–?—å?の中の
208 * HYBS_ITD_MARKER æ–?—å? と置き換えますã?
209 * ※ こã?属æ?は、リクエスト変数処ç�?‚’行いませんã€?
210 *
211 * @og.rev 3.5.6.0 (2004/06/18) itdフォーマット文字å?の取り込み
212 *
213 * @param itd itdフォーマットã?æ–?—å?
214 */
215 public void setItdBody( final String itd ) {
216 if( itd != null ) {
217 itdBody = itd;
218 }
219 }
220
221 /**
222 * 【TAG】ここでæŒ?®šしたカラãƒ??値がã?キーブレイクした場合ã?こã?タグを使用しまã�?初期値:null)ã€?
223 *
224 * @og.tag
225 * usableKey,usableList の様に、予め決められた値の時にã€?�©用されるã?ではなくã?
226 * キーブレイクで 使用可否を指定する為の機è?ですã?
227 * こã?設定å?は、usableKey,usableList とは、独立してã�?‚‹ため、それぞれで
228 * 有効になれã?、使用されると判断されますã?
229 * キーブレイク判定では、最初ã?1件目は、å¿?�š使用されると判断されますã?
230 *
231 * @og.rev 5.7.6.3 (2014/05/23) 新規追åŠ?
232 *
233 * @param kclm キーブレイクをチェãƒ?‚¯するカラãƒ?D
234 */
235 public void setKeyBreakClm( final String kclm ) {
236 keyBreakClm = nval( getRequestParameter( kclm ),keyBreakClm );
237 }
238
239 /**
240 * 【TAGã€?先é?trタグを削除するかどã�?�‹[true/false]を指定しまã�?初期値:true)ã€?
241 *
242 * @og.tag
243 * フォーマットã?先é?がtrタグの場合ã?削除する処ç�?�Œありますがã€?
244 * CustomDataのような場合では削除したくありませんã€?
245 * falseを指定すると削除処ç�?‚’行わなã�?‚ˆã�?�«なりますã?
246 *
247 * @og.rev 5.5.0.3 (2012/03/13) 新規追åŠ?
248 *
249 * @param useFlg æƒ??出力をæŒ?®?[true:有効/false:無効]
250 */
251 public void setUseTrCut( final String useFlg ) {
252 useTrCut = nval( getRequestParameter( useFlg ),useTrCut );
253 }
254
255 /**
256 * こã?オブジェクトã?æ–?—å?表現を返しますã?
257 * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
258 *
259 * @return こã?クラスのæ–?—å?表現
260 */
261 @Override
262 public String toString() {
263 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
264 // .println( "VERSION" ,VERSION )
265 .println( "rowspan" ,rowspan )
266 .println( "noClass" ,noClass )
267 .println( "usableKey" ,usableKey )
268 .println( "usableList" ,usableList )
269 .println( "itdBody" ,itdBody )
270 .println( "keyBreakClm" ,keyBreakClm)
271 .println( "Other..." ,getAttributes().getAttribute() )
272 .fixForm().toString() ;
273 }
274 }