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.fukurou.util.Attributes;
020 import org.opengion.hayabusa.html.ViewMarker;
021 import org.opengion.hayabusa.html.ViewLink_LINK;
022
023 import java.util.Locale ;
024 import java.io.ObjectOutputStream;
025 import java.io.ObjectInputStream;
026 import java.io.IOException;
027
028 /**
029 * HTML のaタグと同等?リンクを作?するタグで、さらに国際化対応と引数の受け渡しが可能です?
030 *
031 * DBTableModelオブジェクトを表示する、?通オブジェクトです?
032 * こ?オブジェクトに???タ(DBTableModel)と、コントローラ(EntryTagForm)を与えて?
033 * 外部からコントロールすることで、各種形式で ??タ(DBTableModel)を表示させること?
034 * 可能です?
035 *
036 * @og.formSample
037 * ●形式?lt;og:viewLink command="…" > <og:link name="…" ... /> </og:viewLink >
038 * ●body?あ?EVAL_BODY_BUFFERED:BODYを評価し?{@XXXX} を解析しま?
039 *
040 * ●Tag定義??
041 * <og:viewLink
042 * command ○?TAG】コマン?NEW,RENEW,RESET,REVIEW)をセ?しま???)?
043 * viewLinkId 【TAG?通常使?せん)requestから取得す?ViewLink に対応す?Attributes オブジェクト? ID
044 * debug 【TAG】デバッグ??を?力するかど?[true/false]を指定しま?初期値:false)
045 * > ... Body ...
046 * </og:viewLink>
047 *
048 * ●使用?
049 * QueryTagとViewTagの間にviewLinkを使?す?
050 * <og:viewLink command="{@command}">
051 * <og:link column="NOSYN" gamenId="01PATTERN1" href="query.jsp" target="QUERY"
052 * keys="NOSYN,NMSYN,CDBK" value="[NOSYN],[NMSYN],[CDBK]" />
053 * <og:link column="NMSYN" gamenId="01PATTERN1" href="query.jsp" target="QUERY"
054 * keys="NMSYN" value="[NMSYN]" />
055 * <og:link column="CDBK" gamenId="01PATTERN1" href="query.jsp" target="QUERY"
056 * keys="NOSYN,NMSYN" value="[NOSYN],[NMSYN]" />
057 * </og:viewLink>
058 *
059 * @og.group 画面表示
060 *
061 * @version 4.0
062 * @author Kazuhiko Hasegawa
063 * @since JDK5.0,
064 */
065 public class ViewLinkTag extends CommonTagSupport {
066 //* こ?プログラ??VERSION??を設定します? {@value} */
067 private static final String VERSION = "5.1.9.0 (2010/08/01)" ;
068
069 private static final long serialVersionUID = 519020100801L ;
070
071 /** command 引数に渡す事?出来?コマン? 新?{@value} */
072 public static final String CMD_NEW = "NEW" ;
073 /** command 引数に渡す事?出来?コマン? 再検索 {@value} */
074 public static final String CMD_RENEW = "RENEW" ;
075 /** command 引数に渡す事?出来?コマン? リセ? {@value} */
076 public static final String CMD_RESET = "RESET" ; // 3.5.4.0 (2003/11/25)
077 /** command 引数に渡す事?出来?コマン? 再表示 {@value} */
078 public static final String CMD_REVIEW = "REVIEW" ; // 3.5.4.0 (2003/11/25)
079
080 /** command 引数に渡す事?出来?コマン?リス? */
081 private static final String[] COMMAND_LIST = new String[] {
082 CMD_NEW , CMD_RENEW ,CMD_RESET , CMD_REVIEW }; // 3.5.4.0 (2003/11/25)
083
084 private String viewLinkId = HybsSystem.VIEWLINK_KEY;
085 private String command = null;
086 private transient ViewMarker viewMarker = new ViewLink_LINK();
087
088 /**
089 * Taglibの開始タグが見つかったときに処??doStartTag() ?オーバ?ライドします?
090 *
091 * @og.rev 5.1.9.0 (2010/08/01) 戻り?を?EVAL_BODY_INCLUDE ?EVAL_BODY_BUFFERED に変更
092 *
093 * @return 後続????
094 */
095 @Override
096 public int doStartTag() {
097 // if( check( command, COMMAND_LIST ) ) { return( EVAL_BODY_INCLUDE ); }
098 if( check( command, COMMAND_LIST ) ) { return( EVAL_BODY_BUFFERED ); } // 5.1.9.0 (2010/08/01) 変更
099 else { return( SKIP_BODY ); }
100 }
101
102 /**
103 * Taglibの終?グが見つかったときに処??doEndTag() ?オーバ?ライドします?
104 *
105 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ?
106 *
107 * @return 後続????
108 */
109 @Override
110 public int doEndTag() {
111 debugPrint(); // 4.0.0 (2005/02/28)
112 if( check( command, COMMAND_LIST ) ) {
113 setRequestAttribute( viewLinkId,viewMarker );
114 }
115
116 return(EVAL_PAGE);
117 }
118
119 /**
120 * タグリブオブジェクトをリリースします?
121 * キャ?ュされて再利用される?で、フィールド?初期設定を行います?
122 *
123 * @og.rev 2.0.0.4 (2002/09/27) カスタ?グの release() メソ?を?追?
124 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ?
125 *
126 */
127 @Override
128 protected void release2() {
129 super.release2();
130 viewLinkId = HybsSystem.VIEWLINK_KEY;
131 command = null;
132 viewMarker = new ViewLink_LINK();
133 }
134
135 /**
136 * ?タグの LinkTag より、???カラ??値を書き換える 為の
137 * リンク??を受け取る?
138 *
139 * ?の値を受け取って、後ほど、すべてのカラ?対して処?行います?
140 *
141 * @og.rev 3.1.2.0 (2003/04/07) taglib パッケージ?で使用して???protected 化する?
142 * @og.rev 4.0.0.0 (2005/08/31) 同?ラ???登録を許可します?
143 *
144 * @param attri リンクアトリビュー?
145 */
146 protected void addAttribute( final Attributes attri ) {
147 viewMarker.addAttribute( attri );
148 }
149
150 /**
151 * 【TAG】コマン?NEW,RENEW,RESET,REVIEW)をセ?します?
152 *
153 * @og.tag
154 * コマンド?,HTMLから(get/post)?されます?で,CMD_xxx で設定される
155 * フィールド定数値の?れかを??できます?
156 *
157 * @param cmd コマン?public static final 宣?れて???)
158 * @see <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.ViewLinkTag.CMD_NEW">コマンド定数</a>
159 */
160 public void setCommand( final String cmd ) {
161 String cmd2 = getRequestParameter( cmd );
162 if( cmd2 != null && cmd2.length() > 0 ) { command = cmd2.toUpperCase(Locale.JAPAN); }
163 }
164
165 /**
166 * 【TAG?通常使?せん)requestから取得す?ViewLink に対応す?Attributes オブジェクト? ID?
167 *
168 * @og.tag
169 * ViewLink オブジェクトをこ?キーで、登録することにより?
170 * ViewForm オブジェクトで、リンク??を付加して表示させる?
171 * 初期値は、HybsSystem.VIEWLINK_KEY です?
172 *
173 * @og.rev 3.1.4.0 (2003/04/18) 新規追?
174 * @og.rev 3.5.6.3 (2004/07/12) {@XXXX} 変数を使用できるように変更?
175 * @og.rev 3.5.6.4 (2004/07/16) LINK_ID を付加して、他?id と混同しな??します?
176 *
177 * @param id オブジェク?D
178 */
179 public void setViewLinkId( final String id ) {
180 String temp = getRequestParameter( id ) ;
181 if( temp != null && temp.length() > 0 ) {
182 viewLinkId = temp + TaglibUtil.LINK_ID;
183 }
184 }
185
186 /**
187 * シリアライズ用のカスタ?リアライズ書き込みメソ?
188 *
189 * @og.rev 4.0.0.0 (2006/09/31) 新規追?
190 * @serialData ?のオブジェクト?、シリアライズされません?
191 *
192 * @param strm ObjectOutputStreamオブジェク?
193 * @throws IOException 入出力エラーが発生した??
194 */
195 private void writeObject( final ObjectOutputStream strm ) throws IOException {
196 strm.defaultWriteObject();
197 }
198
199 /**
200 * シリアライズ用のカスタ?リアライズ読み込みメソ?
201 *
202 * ここでは、transient 宣?れた?変数の??初期化が?なフィールド?み設定します?
203 *
204 * @og.rev 4.0.0.0 (2006/09/31) 新規追?
205 * @serialData ?のオブジェクト?、シリアライズされません?
206 *
207 * @param strm ObjectInputStreamオブジェク?
208 * @see #release2()
209 * @throws IOException シリアライズに関する入出力エラーが発生した??
210 * @throws ClassNotFoundException クラスを見つけることができなかった??
211 */
212 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
213 strm.defaultReadObject();
214 viewMarker = new ViewLink_LINK();
215 }
216
217 /**
218 * こ?オブジェクト???表現を返します?
219 * 基本???目?使用します?
220 *
221 * @return こ?クラスの??表現
222 */
223 @Override
224 public String toString() {
225 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
226 .println( "VERSION" ,VERSION )
227 .println( "viewLinkId" ,viewLinkId )
228 .println( "command" ,command )
229 .println( "Other..." ,getAttributes().getAttribute() )
230 .fixForm().toString() ;
231 }
232 }