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 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     * ●形式ï¼?lt;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     */
064    public 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:?‘回目 / false:?’回目)
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    }