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    }