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.html.ViewJsonParam; 019import org.opengion.hayabusa.html.ViewStackTableParam; 020 021import static org.opengion.fukurou.util.StringUtil.nval ; 022 023import java.io.ObjectOutputStream; 024import java.io.ObjectInputStream; 025import java.io.IOException; 026 027/** 028 * viewタグの viewFormType が JSON の場合にパラメータを設定します。 029 * 030 * JOSN出力のViewForm_JSON クラスに対して、各種パラメータを設定します。 031 * パラメータが設定されていない場合は、ViewJsonParam の初期値が 032 * 使用されます。 033 * (パラメータを使用するには、viewタグのuseParam 属性をtrueに設定する必要があります。) 034 * 035 * @og.formSample 036 * ●形式:<og:jsonParam useHead="false" /> 037 * ●body:なし 038 * 039 * ●Tag定義: 040 * <og:stackParam 041 * useHead 【TAG】ヘッダ情報を出力するかどうか(初期値:true) 042 * useInfo 【TAG】INFO情報を出力するかどうか(初期値:true) 043 * useRenderer 【TAG】データ出力でレンデラを利用するかどうか(初期値:false) 044 * dataName 【TAG】データ出力時の配列オブジェクトの名称指定(初期値:DATA) 045 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 046 * /> 047 * 048 * @og.rev 5.9.7.0 (2016/04/01) 新規作成 049 * @og.group 画面表示 050 * 051 * @version 5.0 052 * @author Takahashi Masakazu 053 * @since JDK5.0, 054 */ 055public class ViewJsonParamTag extends ViewParamTag { 056 //* このプログラムのVERSION文字列を設定します。 {@value} */ 057 private static final String VERSION = "5.6.1.2 (2013/02/22)" ; 058 059 private static final long serialVersionUID = 561220130222L ; 060 061 /** 062 * 【TAG】JSON出力で、INFO情報を出すかどうかを指定します。 063 * 064 * @og.tag 065 * JSON中INFO情報を出力しない場合はfalseを指定します。 066 * 067 * 068 * @param useinfo INFO情報を出力するかどうか 069 */ 070 public void setUseInfo( final String useinfo ) { 071 putParam( ViewJsonParam.JSON_INFO_KEY , 072 nval( getRequestParameter( useinfo ),null ) ); 073 } 074 075 /** 076 * 【TAG】JSON出力で、ヘッダ情報を出すかどうかを指定します。 077 * 078 * @og.tag 079 * JSON中にヘッダ情報を出力しない場合はfalseを指定します。 080 * 081 * 082 * @param usehead ヘッダ情報を出力するかどうか 083 */ 084 public void setUseHead( final String usehead ) { 085 putParam( ViewJsonParam.JSON_HEAD_KEY , 086 nval( getRequestParameter( usehead ),null ) ); 087 } 088 089 /** 090 * 【TAG】JSON出力で、値出力にレンデラを利用するかどうかを指定します。 091 * 092 * @og.tag 093 * JSONのデータのレンデラー変換を行うかどうか。 094 * 指定しない場合は使用しない(false)です。 095 * 096 * 097 * @param usernd レンデラーを利用するかどうか 098 */ 099 public void setUseRenderer( final String usernd ) { 100 putParam( ViewJsonParam.JSON_RENDERER_KEY , 101 nval( getRequestParameter( usernd ),null ) ); 102 } 103 104 /** 105 * 【TAG】JSON出力で、データ部の名前を指定します。 106 * 107 * @og.tag 108 * データ配列の名称を指定します。 109 * 指定しない場合は「DATA」です。 110 * 111 * 112 * @param name データ配列の名称 113 */ 114 public void setDataName( final String name ) { 115 putParam( ViewJsonParam.JSON_DATANAME_KEY , 116 nval( getRequestParameter( name ),null ) ); 117 } 118 119 /** 120 * タグの名称を、返します。 121 * 自分自身のクラス名より、自動的に取り出せないため、このメソッドをオーバーライドします。 122 * 123 * 124 * @return タグの名称 125 */ 126 @Override 127 protected String getTagName() { 128 return "jsonParam" ; 129 } 130 131 /** 132 * シリアライズ用のカスタムシリアライズ書き込みメソッド 133 * 134 * @serialData 一部のオブジェクトは、シリアライズされません。 135 * 136 * @param strm ObjectOutputStreamオブジェクト 137 * @throws IOException 入出力エラーが発生した場合 138 */ 139 private void writeObject( final ObjectOutputStream strm ) throws IOException { 140 strm.defaultWriteObject(); 141 } 142 143 /** 144 * シリアライズ用のカスタムシリアライズ読み込みメソッド 145 * 146 * ここでは、transient 宣言された内部変数の内、初期化が必要なフィールドのみ設定します。 147 * 148 * @serialData 一部のオブジェクトは、シリアライズされません。 149 * 150 * @param strm ObjectInputStreamオブジェクト 151 * @see #release2() 152 * @throws IOException シリアライズに関する入出力エラーが発生した場合 153 * @throws ClassNotFoundException クラスを見つけることができなかった場合 154 */ 155 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException { 156 strm.defaultReadObject(); 157 } 158}