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.plugin.view;
017    
018    import org.opengion.hayabusa.db.DBTableModel;
019    import org.opengion.hayabusa.common.HybsSystem;
020    import org.opengion.fukurou.util.XHTMLTag;
021    
022    /**
023     * エントリ形式フォー??クラスです?
024     *
025     * フォーマットを外部から?することにより?自由にレイアウトを作?できます?
026     *
027     * AbstractViewForm により、setter/getterメソ?の?ォルト実?提供して?す?
028     * 各HTMLのタグに?な setter/getterメソ?のみ?追?義して?す?
029     *
030     * AbstractViewForm を継承して?為,ロケールに応じたラベルを?力させる事が出来ます?
031     *
032     * @og.rev 3.1.8.0 (2003/05/16) ViewForm_HTMLEntry クラスの新規作?
033     * @og.group 画面表示
034     *
035     * @version  4.0
036     * @author   Kazuhiko Hasegawa
037     * @since    JDK5.0,
038     */
039    public class ViewForm_HTMLEntry extends ViewForm_HTMLFormatTextField {
040            //* こ?プログラ??VERSION??を設定します?       {@value} */
041            private static final String VERSION = "5.2.1.0 (2010/10/01)" ;
042    
043            private String mustHidden = "";
044    
045            /**
046             * DBTableModel から HTML??を作?して返します?
047             * startNo(表示開始位置)から、pageSize(表示件数)までのView??を作?します?
048             * 表示残り??タ?pageSize 以下?場合?,残りの??タをすべて出力します?
049             *
050             * @og.rev 5.2.1.0 (2010/10/01) must 属?の処?追?ます?
051             *
052             * @param  startNo    表示開始位置
053             * @param  pageSize   表示件数
054             *
055             * @return  DBTableModelから作?され?HTML??
056             */
057            @Override
058            public String create( final int startNo, final int pageSize )  {
059                    return super.create( startNo,pageSize ) + mustHidden;
060            }
061    
062            /**
063             * row行,colum?の??タの値をHTML??に変換して返します?
064             * Entry 系のため??常の行番号付? Editor ではなく?行番号無し?
065             * Editorを使用して、HTML??を作?します?
066             *
067             * @og.rev 3.8.0.9 (2005/10/17) writableControl 追?よる引数変更
068             *
069             * @param       row             行番号
070             * @param       column  カラ?号
071             * @param       inVal   設定?
072             *
073             * @return      row行,colum?の??タの値
074             */
075            @Override
076            protected String getEditorValue( final int row, final int column , final String inVal ) {
077                    return getDBColumn(column).getEditorValue( inVal );
078            }
079    
080            /**
081             * 画面に選択された番号を表示します?
082             * Entry 系のため?択番号を作?しません?
083             *
084             * @param  row   行番号
085             *
086             * @return      空?? ""(固?
087             */
088            @Override
089            protected String makeSelectNo( final int row ) {
090                    return "" ;
091            }
092    
093            /**
094             * 初期化します?
095             * こ?クラスでは、データが0件の場合?、?期データを1件作?します?
096             * 初期化時に、?期データ作?処?行います?
097             *
098             * @og.rev 3.2.3.0 (2003/06/06) 新規追?
099             * @og.rev 3.5.6.0 (2004/06/18) null 比?バグを修正
100             * @og.rev 3.5.6.1 (2004/06/25) lang ?コー?属?を削除します?
101             * @og.rev 4.0.1.0 (2007/12/12) initの場?変更
102             * @og.rev 5.2.1.0 (2010/10/01) must 属?の処?追?ます?
103             *
104             * @param       table   DBTableModelオブジェク?
105             */
106            @Override
107            public void init( final DBTableModel table ) {
108            //      super.init( table );
109                    if( table != null && table.getRowCount() == 0 ) {
110                            String[] data = new String[table.getColumnCount()];
111                            for( int i=0; i<data.length; i++ ) {
112                                    data[i] = table.getDBColumn(i).getDefault();
113                                    if( data[i] == null ) { data[i] = ""; }
114                            }
115                            table.addValues( data,0 );
116    
117                            // 5.2.1.0 (2010/10/01) must 属?の処?追?ます?
118                            String[] clms = table.getMustArray();
119                            if( clms != null ) {
120                                    StringBuilder buf = new StringBuilder();
121                                    for( int i=0; i<clms.length; i++ ) {
122                                            buf.append( XHTMLTag.hidden( HybsSystem.MUST_KEY +"must", clms[i] ) );
123                                    }
124                                    mustHidden = buf.toString();
125                            }
126                    }
127                    super.init( table ); // 4.0.1.0 (2007/12/12)?件時不?合対応につき??更
128            }
129    
130            /**
131             * 表示?の編?並び替?が可能かど?を返しま?
132             *
133             * @og.rev 5.1.6.0 (2010/05/01) 新規追?
134             *
135             * @return      表示?の編?並び替?が可能かど?(false:不可能)
136             */
137            @Override
138            public boolean isEditable() {
139                    return false;
140            }
141    }