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="{@docRoot}/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 */ 223 private void writeObject( final ObjectOutputStream strm ) throws IOException { 224 strm.defaultWriteObject(); 225 } 226 227 /** 228 * シリアライズ用ã®ã‚«ã‚¹ã‚¿ãƒ?‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºèªã¿è¾¼ã¿ãƒ¡ã‚½ãƒ?ƒ‰ 229 * 230 * ã“ã“ã§ã¯ã€transient 宣è¨?•れãŸå†?ƒ¨å¤‰æ•°ã®å†??åˆæœŸåŒ–ãŒå¿?¦ãªãƒ•ィールドã?ã¿è¨å®šã—ã¾ã™ã? 231 * 232 * @og.rev 4.0.0.0 (2006/09/31) æ–°è¦è¿½åŠ? 233 * @serialData 234 * 235 * @param strm ObjectInputStreamオブジェクãƒ? 236 * @see #release2() 237 */ 238 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException { 239 strm.defaultReadObject(); 240 viewMarker = new ViewMarker_MARKER(); 241 } 242 243 /** 244 * ã“ã?オブジェクトã?æ–?—å?表ç¾ã‚’è¿”ã—ã¾ã™ã? 245 * 基本çš?«ãƒ?ƒãƒ?‚°ç›®çš?«ä½¿ç”¨ã—ã¾ã™ã? 246 * 247 * @return ã“ã?ã‚¯ãƒ©ã‚¹ã®æ–?—å?è¡¨ç¾ 248 */ 249 @Override 250 public String toString() { 251 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 252 .println( "VERSION" ,VERSION ) 253 .println( "viewMarkerId" ,viewMarkerId ) 254 .println( "command" ,command ) 255 .println( "Other..." ,getAttributes().getAttribute() ) 256 .fixForm().toString() ; 257 } 258 }