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.plugin.view; 017 018import org.opengion.hayabusa.common.HybsSystem; 019import org.opengion.hayabusa.db.DBTableModel; 020 021/** 022 * 各フィールド情報から、動的にカラムを作成する動的カラム一覧表示クラスです。 023 * 024 * AbstractViewForm により、setter/getterメソッドのデフォルト実装を提供しています。 025 * 各HTMLのタグに必要な setter/getterメソッドのみ,追加定義しています。 026 * 027 * AbstractViewForm を継承している為,ロケールに応じたラベルを出力させる事が出来ます。 028 * 029 * @og.group 画面表示 030 * 031 * @version 4.0 032 * @author Kazuhiko Hasegawa 033 * @since JDK5.0, 034 */ 035public class ViewForm_HTMLDynamic extends ViewForm_HTMLTable { 036 //* このプログラムのVERSION文字列を設定します。 {@value} */ 037 private static final String VERSION = "5.1.6.0 (2010/05/01)" ; 038 039 /** カラムの値を返す場合の、カラムキー名称 {@value} */ 040 public static final String COLUMN_RETURN_KEY = "COLUMN_RETURN"; 041 private int rtnColumnNo = -1; // column_return カラムの番号 042 043 // 4.3.4.4 (2009/01/01) 044// /** 045// * デフォルトコンストラクター 046// * 047// */ 048// public ViewForm_HTMLDynamic() { 049// super(); 050// } 051 052 /** 053 * 初期化します。 054 * ここでは、内部で使用されているキャッシュをクリアし、 055 * 新しいモデル(DBTableModel)と言語(lang) を元に内部データを再構築します。 056 * ただし、設定情報は、以前の状態がそのままキープされています。 057 * 058 * @og.rev 3.1.1.0 (2003/03/28) 同期メソッド(synchronized付き)を非同期に変更する。 059 * @og.rev 3.5.6.1 (2004/06/25) lang 言語コード 属性を削除します。 060 * 061 * @param table DBTableModelオブジェクト 062 */ 063 @Override 064 public void init( final DBTableModel table ) { 065 super.init( table ); 066 int clmCnt = getColumnCount(); 067 for( int i=0; i<clmCnt; i++ ) { 068 if( COLUMN_RETURN_KEY.equalsIgnoreCase( getColumnName(i) )) { 069 rtnColumnNo = i; 070 break; 071 } 072 } 073 } 074 075 /** 076 * DBTableModel から HTML文字列を作成して返します。 077 * startNo(表示開始位置)から、pageSize(表示件数)までのView文字列を作成します。 078 * 表示残りデータが pageSize 以下の場合は,残りのデータをすべて出力します。 079 * 080 * @og.rev 3.5.4.0 (2003/11/25) getBgColorCycleClass の返す文字列を変更する。 081 * @og.rev 3.5.6.4 (2004/07/16) ヘッダーとボディー部をJavaScriptで分離 082 * 083 * @param startNo 表示開始位置 084 * @param pageSize 表示件数 085 * 086 * @return DBTableModelから作成された HTML文字列 087 */ 088 @Override 089 public String create( final int startNo, final int pageSize ) { 090 if( getRowCount() == 0 ) { return ""; } // 暫定処置 091 092 int lastNo = getLastNo( startNo, pageSize ); 093 094 StringBuilder out = new StringBuilder( HybsSystem.BUFFER_LARGE ); 095 096 out.append( getCountForm( startNo,pageSize ) ); 097 out.append( getHeader() ); 098 099 int rowIndex = 0; 100 out.append("<tbody>").append( HybsSystem.CR ); 101 out.append("<tr").append( getBgColorCycleClass( rowIndex++ ) ).append(">"); 102 int clmCnt = getColumnCount(); // 3.5.5.7 (2004/05/10) 103 for( int row=startNo; row<lastNo; row++ ) { 104 for(int column = 0; column < clmCnt; column++) { 105 if( isColumnReturn( row,column ) ) { 106 out.append("</tr>"); 107 out.append("<tr").append( getBgColorCycleClass( rowIndex++ ) ).append(">"); 108 } 109 else if( isColumnDisplay( column ) ) { 110 out.append(" <td>"); 111 out.append( getValueLabel(row,column) ); 112 out.append("</td>").append( HybsSystem.CR ); 113 } 114 } 115 } 116 out.append("</tr>").append( HybsSystem.CR ); 117 out.append("</tbody>").append( HybsSystem.CR ); 118 out.append("</table>").append( HybsSystem.CR ); 119 120 out.append( getScrollBarEndDiv() ); // 3.8.0.3 (2005/07/15) 121 return out.toString(); 122 } 123 124 /** 125 * DBTableModel から テーブルのタグ文字列を作成して返します。 126 * 127 * @return テーブルのタグ文字列 128 */ 129 @Override 130 protected String getTableHead() { 131 // ヘッダーは,不要です。 132 return ""; 133 } 134 135 /** 136 * カラムが表示可能かどうかを返します。 137 * もし,表示不可の場合は,このカラムの全データが,表示対象から外されます。 138 * 139 * @param row 行番号 140 * @param column カラム番号 141 * 142 * @return 表示可能(true)/不可能(false) 143 */ 144 private boolean isColumnReturn( final int row,final int column ) { 145 boolean rtnFlag = false; 146 147 if( rtnColumnNo == column && 148 "1".equals( getValue( row,column ) ) ) { 149 rtnFlag = true; 150 } 151 152 return rtnFlag; 153 } 154 155 /** 156 * 表示項目の編集(並び替え)が可能かどうかを返します 157 * 158 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 159 * 160 * @return 表示項目の編集(並び替え)が可能かどうか(false:不可能) 161 */ 162 @Override 163 public boolean isEditable() { 164 return false; 165 } 166}