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.HybsSystem;
019 import org.opengion.hayabusa.html.ViewMarker;
020 import org.opengion.hayabusa.html.ViewMarker_MARKER;
021 import org.opengion.fukurou.util.Attributes;
022 import static org.opengion.fukurou.util.StringUtil.nval ;
023
024 import java.util.Locale ;
025 import java.io.ObjectOutputStream;
026 import java.io.ObjectInputStream;
027 import java.io.IOException;
028
029 /**
030 * è¤?•°のcolumnMarker を統合して、検索結果に対して様ã?な属æ?を付加するタグですã?(参ç?:columnMarker)
031 *
032 * DBTableModelオブジェクトã?表示にHTMLタグをã?ークしますã?
033 * 子タグとして、ColumnMarkerTag のBODY要ç´?‚’パã?スして、タグを作æ?しますã?
034 *
035 * @og.formSample
036 * ●形式ï¼?lt;og:viewMarker > ?¥?¥?¥ </og:viewMarker >
037 * ●body?šあã‚?EVAL_BODY_BUFFERED:BODYを評価しã?{@XXXX} を解析しまã�?
038 *
039 * ●Tag定義??
040 * <og:viewMarker
041 * command ○ã?TAG】コマンãƒ?NEW,RENEW,RESET,REVIEW)をセãƒ?ƒˆしまã�?å¿??)ã€?
042 * viewMarkerId 【TAGã€?通常使ã�?�¾せん)requestから取得すã‚?ViewMarker に対応すã‚?Attributes オブジェクトã? ID
043 * debug 【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
044 * isRenderer 【TAG】ã?ーカーのタイプが renderer かどã�?�‹[true/false]を指定しまã�?初期値:true)
045 * > ... Body ...
046 * </og:viewMarker>
047 *
048 * ●使用ä¾?
049 * å•?“�CD??CDSYHN02)は赤字で表示するã€?
050 * å•?“�CD??CDSYHN03)は-----と表示するã€?
051 * <og:viewMarker command="{@command}">
052 * <og:columnMarker column="CDSYHN02" onMark="true" >
053 * <font color='red'>[VCDSYHN02]</font>
054 * </og:columnMarker>
055 * <og:columnMarker column="CDSYHN03" onMark="true" >
056 * <CENTER>-----</CENTER>
057 * </og:columnMarker>
058 * </og:viewMarker>
059 *
060 * @og.group 画面表示
061 *
062 * @version 4.0
063 * @author Kazuhiko Hasegawa
064 * @since JDK5.0,
065 */
066 public class ViewMarkerTag extends CommonTagSupport {
067 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
068 private static final String VERSION = "5.1.9.0 (2010/08/01)" ;
069
070 private static final long serialVersionUID = 519020100801L ;
071
072 /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 新è¦?{@value} */
073 public static final String CMD_NEW = "NEW" ;
074 /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 再検索 {@value} */
075 public static final String CMD_RENEW = "RENEW" ;
076 /** command 引数に渡す事ã?出来ã‚?コマンãƒ? リセãƒ?ƒˆ {@value} */
077 public static final String CMD_RESET = "RESET" ; // 3.5.4.0 (2003/11/25)
078 /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 再表示 {@value} */
079 public static final String CMD_REVIEW = "REVIEW" ; // 3.5.4.0 (2003/11/25)
080
081 /** command 引数に渡す事ã?出来ã‚?コマンãƒ?リスãƒ? */
082 private static final String[] COMMAND_LIST = new String[] {
083 CMD_NEW , CMD_RENEW ,CMD_RESET , CMD_REVIEW }; // 3.5.4.0 (2003/11/25)
084
085 private transient ViewMarker viewMarker = new ViewMarker_MARKER();
086 private String viewMarkerId = null;
087 private String command = null;
088 private boolean isRenderer = true; // 3.8.6.1 (2006/10/20)
089
090 /**
091 * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
092 *
093 * @og.rev 5.1.9.0 (2010/08/01) 戻りå?をã?EVAL_BODY_INCLUDE â†?EVAL_BODY_BUFFERED に変更
094 *
095 * @return 後続å?ç�??æŒ?¤º
096 */
097 @Override
098 public int doStartTag() {
099 // if( check( command, COMMAND_LIST ) ) { return( EVAL_BODY_INCLUDE ); }
100 if( check( command, COMMAND_LIST ) ) { return( EVAL_BODY_BUFFERED ); } // 5.1.9.0 (2010/08/01) 変更
101 else { return( SKIP_BODY ); }
102 }
103
104 /**
105 * Taglibの終äº?‚¿グが見つかったときに処ç�?�™ã‚?doEndTag() ã‚?オーバã?ライドしますã?
106 *
107 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
108 * @og.rev 3.8.6.1 (2006/10/20) isRenderer 属æ?でマã?カーの種類をæŒ?®?
109 *
110 * @return 後続å?ç�??æŒ?¤º
111 */
112 @Override
113 public int doEndTag() {
114 debugPrint(); // 4.0.0 (2005/02/28)
115 if( check( command, COMMAND_LIST ) ) {
116 final String mid ;
117 if( isRenderer ) {
118 mid = nval( viewMarkerId,HybsSystem.VIEW_MARK_KEY );
119 }
120 else {
121 mid = nval( viewMarkerId,HybsSystem.EDIT_MARK_KEY );
122 }
123 setRequestAttribute( mid,viewMarker );
124 }
125
126 return(EVAL_PAGE);
127 }
128
129 /**
130 * タグリブオブジェクトをリリースしますã?
131 * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
132 *
133 * @og.rev 2.0.0.4 (2002/09/27) カスタãƒ?‚¿グの release() メソãƒ?ƒ‰をã?追åŠ?
134 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
135 * @og.rev 3.8.6.1 (2006/10/20) isRenderer属æ?追åŠ??viewMarkerId属æ?初期値変更
136 *
137 */
138 @Override
139 protected void release2() {
140 super.release2();
141 viewMarker = new ViewMarker_MARKER();
142 viewMarkerId = null;
143 command = null;
144 isRenderer = true; // 3.8.6.1 (2006/10/20)
145 }
146
147 /**
148 * å†?ƒ¨タグの ColumnMarkerTag より、å?ã€??カラãƒ??値を書き換える 為の
149 * マã?カーæ–?—å?を受け取るã?
150 *
151 * è¤?•°の値を受け取って、後ほど、すべてのカラãƒ?�«対して処ç�?‚’行いますã?
152 *
153 * @og.rev 3.1.2.0 (2003/04/07) taglib パッケージå†?ƒ¨で使用してã�?‚‹ç®?‰€ã‚?protected 化するã?
154 * @og.rev 4.0.0.0 (2005/08/31) 同ä¸?‚«ラãƒ??è¤?•°登録を許可しますã?
155 *
156 * @param attri Attribute マã?ク処ç�?±žæ?
157 */
158 protected void addAttribute( final Attributes attri ) {
159 viewMarker.addAttribute( attri );
160 }
161
162 /**
163 * 【TAG】コマンãƒ?NEW,RENEW,RESET,REVIEW)をセãƒ?ƒˆしますã?
164 *
165 * @og.tag
166 * コマンドã?,HTMLから(get/post)æŒ?®šされますã?で,CMD_xxx で設定される
167 * フィールド定数値のã�?�¥れかをã?æŒ?®šできますã?
168 *
169 * @param cmd コマンãƒ?public static final 宣è¨?�•れてã�?‚‹æ–?—å?)
170 * @see <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.ViewMarkerTag.CMD_NEW">コマンド定数</a>
171 */
172 public void setCommand( final String cmd ) {
173 String cmd2 = getRequestParameter( cmd );
174 if( cmd2 != null && cmd2.length() > 0 ) { command = cmd2.toUpperCase(Locale.JAPAN); }
175 }
176
177 /**
178 * 【TAGã€?通常使ã�?�¾せん)requestから取得すã‚?ViewMarker に対応すã‚?Attributes オブジェクトã? IDã€?
179 *
180 * @og.tag
181 * ViewForm オブジェクトに、ViewMarker オブジェクトをこã?キーより取得することによりã€?
182 * カラãƒ?�«対して、ã?ーカーæƒ??を付加して表示させるã?
183 * 初期値は、HybsSystem.VIEW_MARK_KEY ですã?
184 *
185 * @og.rev 3.1.4.0 (2003/04/18) 新規追åŠ?
186 * @og.rev 3.5.6.3 (2004/07/12) {@XXXX} 変数を使用できるように変更ã€?
187 * @og.rev 3.5.6.4 (2004/07/16) MARK_ID を付加して、他ã?id と混同しなã�?‚ˆã�?�«しますã?
188 * @og.rev 3.8.6.1 (2006/10/20) 初期値:null (editMarker をè?慮)
189 *
190 * @param id ViewMarker オブジェクãƒ?D
191 */
192 public void setViewMarkerId( final String id ) {
193 viewMarkerId = nval( getRequestParameter( id ),null ) ;
194 }
195
196 /**
197 * 【TAG】ã?ーカーのタイプが renderer かどã�?�‹[true/false]を指定しまã�?初期値:true)ã€?
198 *
199 * @og.tag
200 * こã?Marker オブジェクトが、ViewMarker かã?EditMarker かをæŒ?®šしますã?
201 * å†?ƒ¨çš?�«は、ViewMarker オブジェクトを構築しており、viewForm で、どちらにセãƒ?ƒˆ
202 * するかを決めてã�?‚‹ã�?�‘ですã?
203 * true にセãƒ?ƒˆすると、従来からある、viewMarker(renderer) を指定しますã?
204 * false は、editMarker として作用しã?オブジェクトが書き込み可能な場合に表示されますã?
205 * 初期値は、true:renderer ですã?
206 *
207 * @og.rev 3.8.6.1 (2006/10/20) 新規追åŠ?
208 *
209 * @param flag マã?カータイãƒ?[true:renderer/false:editor]
210 */
211 public void setIsRenderer( final String flag ) {
212 isRenderer = nval( getRequestParameter( flag ),isRenderer ) ;
213 }
214
215 /**
216 * シリアライズ用のカスタãƒ?‚·リアライズ書き込みメソãƒ?ƒ‰
217 *
218 * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
219 * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
220 *
221 * @param strm ObjectOutputStreamオブジェクãƒ?
222 * @throws IOException 入出力エラーが発生したå?å�?
223 */
224 private void writeObject( final ObjectOutputStream strm ) throws IOException {
225 strm.defaultWriteObject();
226 }
227
228 /**
229 * シリアライズ用のカスタãƒ?‚·リアライズ読み込みメソãƒ?ƒ‰
230 *
231 * ここでは、transient 宣è¨?�•れたå†?ƒ¨変数のå†??初期化がå¿?¦�なフィールドã?み設定しますã?
232 *
233 * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
234 * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
235 *
236 * @param strm ObjectInputStreamオブジェクãƒ?
237 * @see #release2()
238 * @throws IOException シリアライズに関する入出力エラーが発生したå?å�?
239 * @throws ClassNotFoundException クラスを見つけることができなかったå?å�?
240 */
241 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
242 strm.defaultReadObject();
243 viewMarker = new ViewMarker_MARKER();
244 }
245
246 /**
247 * こã?オブジェクトã?æ–?—å?表現を返しますã?
248 * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
249 *
250 * @return こã?クラスのæ–?—å?表現
251 */
252 @Override
253 public String toString() {
254 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
255 .println( "VERSION" ,VERSION )
256 .println( "viewMarkerId" ,viewMarkerId )
257 .println( "command" ,command )
258 .println( "Other..." ,getAttributes().getAttribute() )
259 .fixForm().toString() ;
260 }
261 }