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 static org.opengion.fukurou.util.StringUtil.nval; 020 021 022/** 023 * 左右分割スクロール処理を行う、View を設定します。 024 * 025 * BODY部に記述された Viewタグに対して、左右分割情報を追記設定します。 026 * Viewタグの左側には、このタグで指定された fixDisplay のカラムを columnDisplay に 027 * 設定するとともに、このタグで指定された numberType をセットします。 028 * (初期値は、numberType="sequence" です。) 029 * Viewタグの右側には、fixDisplay のカラムを noDisplay のカラムに設定するとともに、 030 * command="VIEW" , noMessage="true" , useSelectedRow="false" , numberType="delete" 031 * をセットします。(既存の設定値があれば、それに追記されます。) 032 * 033 * @og.formSample 034 * ●形式:<og:splitView fixDisplay="CLM,NAME_JA"><og:view ・・・ /></og:splitView> 035 * ●body:あり(EVAL_BODY_INCLUDE:BODYをインクルードし、{@XXXX} は解析しません) 036 * 037 * ●Tag定義: 038 * <og:splitView 039 * fixDisplay 【TAG】固定するカラム名を、CSV形式(カンマ区切り文字列)で設定します 040 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 041 * > ... Body ... 042 * </og:splitView> 043 * 044 * ●使用例 045 * <og:splitView fixDisplay="CLM,NAME_JA"> 046 * <og:view 047 * viewFormType = "HTMLTable" 048 * command = "{@command}" 049 * checked = "{@checked}" 050 * startNo = "{@startNo}" 051 * pageSize = "{@pageSize}" 052 * noWritable = "{@noWritable}" 053 * columnWritable = "{@columnWritable}" 054 * /> 055 * </og:splitView> 056 * 057 * @og.rev 5.3.0.0 (2010/12/01) 新規作成 058 * @og.group 画面部品 059 * 060 * @version 4.0 061 * @author Kazuhiko Hasegawa 062 * @since JDK5.0, 063 */ 064public class SplitViewTag extends CommonTagSupport { 065 //* このプログラムのVERSION文字列を設定します。 {@value} */ 066 private static final String VERSION = "5.3.0.0 (2010/12/01)" ; 067 068 private static final long serialVersionUID = 530020101201L ; 069 070 private static final String SPLIT_A = 071 "<style type=\"text/css\">#GantBody div tr { height:22px; }</style>" + HybsSystem.CR 072 + "<table id=\"GantBody\" border=\"0px\" cellpadding=\"0px\" cellspacing=\"0px\"" + HybsSystem.CR 073 + " frame=\"box\" rules=\"all\" style=\"margin:0px;padding:0px;\">" + HybsSystem.CR 074 + " <tr style=\"margin:0px;padding:0px;\">" + HybsSystem.CR 075 + " <td valign=\"top\" style=\"margin:0px; padding:0px;\" >" + HybsSystem.CR 076 + " <div id=\"X1\" style=\"overflow-x:hidden; overflow-y:hidden;\" >" + HybsSystem.CR ; 077 078 private static final String SPLIT_B = 079 " </div>" + HybsSystem.CR 080 + " </td>" + HybsSystem.CR 081 + " <td valign=\"top\" style=\"margin:0px; padding:0px;\">" + HybsSystem.CR 082 + " <div id=\"X2\" style=\"position:absolute; overflow-x:hidden; overflow-y:hidden;\" >" + HybsSystem.CR ; 083 084 private static final String SPLIT_C = 085 " </div>" + HybsSystem.CR 086 + " </td>" + HybsSystem.CR 087 + " </tr>" + HybsSystem.CR 088 + "</table>" + HybsSystem.CR ; 089 090 private String fixDisplay = null; 091 private boolean firstStepFlag = true; // BODY部の view 処理の制御 092 093 /** 094 * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。 095 * 096 * @return 後続処理の指示( EVAL_BODY_INCLUDE ) 097 */ 098 @Override 099 public int doStartTag() { 100 firstStepFlag = true; 101 // EVAL_BODY_BUFFERED ではなく、Viewなので、INCLUDE 処理します。 102 jspPrint( SPLIT_A ); 103 return EVAL_BODY_INCLUDE ; // Body インクルード( extends TagSupport 時) 104 } 105 106 /** 107 * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。 108 * 109 * @return 後続処理の指示(SKIP_BODY) 110 */ 111 @Override 112 public int doAfterBody() { 113 // EVAL_BODY_INCLUDE なので、コンテンツの取得ではなく、処理のみ実行されます。 114 115 if( firstStepFlag ) { 116 firstStepFlag = false; 117 118 jspPrint( SPLIT_B ); 119 return EVAL_BODY_BUFFERED ; // ボディーを再評価( extends BodyTagSupport 時) 120 } 121 else { 122 jspPrint( SPLIT_C ); 123 return SKIP_BODY ; // Body を評価しない 124 } 125 } 126 127 /** 128 * タグリブオブジェクトをリリースします。 129 * キャッシュされて再利用されるので、フィールドの初期設定を行います。 130 * 131 */ 132 @Override 133 protected void release2() { 134 super.release2(); 135 fixDisplay = null; 136 } 137 138 /** 139 * 【TAG】固定するカラム名を、CSV形式(カンマ区切り文字列)で設定します。 140 * 141 * @og.tag 142 * Viewタグの左側(固定部)には、このタグで指定された fixDisplay のカラムを 143 * columnDisplay に設定します。 144 * Viewタグの右側には、fixDisplay のカラムを noDisplay のカラムに設定します。 145 * 既存の設定値(noDisplay)があれば、それに追記されます。 146 * 147 * @param clms 固定するカラム名(カンマ区切り文字列) 148 */ 149 public void setFixDisplay( final String clms ) { 150 fixDisplay = nval( getRequestParameter( clms ),fixDisplay ); 151 } 152 153 /** 154 * 固定するカラム名を、CSV形式(カンマ区切り文字列)で取得します。 155 * 156 * これは、BODY部に記述された、viewタグからアクセスされるメソッドです。 157 * 設定されていない場合は、null です。 158 * 159 * @return 固定するカラム名(カンマ区切り文字列) 160 */ 161 protected String getFixDisplay() { 162 return fixDisplay ; 163 } 164 165 /** 166 * BODY部の view 処理の制御を行うためのフラグを返します。 167 * 168 * 左右分割を行うには、Viewタグを2回出力する必要があります。 169 * ここでは isFirstStep="true" が1回目(左側:固定部)で、false が 170 * 右側(可変部)になるように、View側で制御します。 171 * 172 * @return BODY部の view 処理の制御(true:1回目 / false:2回目) 173 */ 174 protected boolean isFirstStep() { 175 return firstStepFlag ; 176 } 177 178 /** 179 * このオブジェクトの文字列表現を返します。 180 * 基本的にデバッグ目的に使用します。 181 * 182 * @return このクラスの文字列表現 183 */ 184 @Override 185 public String toString() { 186 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 187 .println( "VERSION" ,VERSION ) 188 .println( "fixDisplay" ,fixDisplay ) 189 .println( "Other..." ,getAttributes().getAttribute() ) 190 .fixForm().toString() ; 191 } 192}