public class SwitchTag extends CommonTagSupport
●形式:<og:switch key="・・・" />
<og:case match="A" /> ・・・ </og:case>
<og:case match="B" /> ・・・ </og:case>
<og:case match="C" /> ・・・ </og:case>
<og:case isDefault="true" /> ・・・ </og:case>
</og:switch>
●body:あり(EVAL_BODY_INCLUDE:BODYをインクルードし、{@XXXX} は解析しません)
●Tag定義:
<og:switch
key ○【TAG】switch のマッチ判定用のキーを設定します(必須)。
debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
> ... Body ...
</og:switch>
●使用例
<og:switch key="{@PARAM}" />
<og:case match="A" /> 処理A </og:case>
<og:case match="B" /> 処理B </og:case>
<og:case match="C" /> 処理C </og:case>
<og:case isDefault="true" /> 処理X </og:case>
</og:switch>
・switch の key に対して、case の match に指定された値が、マッチ(switch_key.match( case_match ))
した場合に、case の BODY 部分が処理されます。
マッチしなければ、BODY部は、スキップされます。
・isDefault="true" の場合は、どれとも マッチしなかった場合に、実行されます。
・Javaの switch-case 文は、最初に処理された case 以降を処理します。通常は、break を入れて
後続処理を実行されないようにしています。
この、switch-case タグは、caseタグの isBreak 属性で制御します。初期値が isBreak="true" に、
なっているため、通常は、どれかの case が実行された段階で、switchの処理は、終了されます。
isBreak="false" にすると、switchから抜けずに、継続して case との match を実行します。
この場合、Java等と異なるのは、直後のcase文が実行されるのではなく、あくまで match 作業が
継続されるということです。つまり、複数の case で処理を行いたい場合は、isBreak="false" に
すると同時に、match 条件もそれぞれで、マッチするように設定する必要があります。
<og:switch key="{@PARAM}" />
<og:case match="[1]" isBreak="false" /> 処理A </og:case>
<og:case match="[12]" isBreak="false" /> 処理B </og:case>
<og:case match="[123]" isBreak="false" /> 処理C </og:case>
<og:case isNull="true" /> 処理X </og:case>
<og:case isDefault="true" /> 処理Y </og:case>
</og:switch>
・上記指定では、isBreak="false" が指定されているため、マッチした後も継続して判定処理が実施されます。
・上記例で言うと、PARAM が "1" の場合、上記3つともにマッチします。
・isNull="true" は、switch の key が null の場合に成立します。(null とは、ゼロ文字列も含む)| 5.2.3.0 (2010/12/01) 新規追加 |
bodyContentid, pageContextEVAL_BODY_BUFFERED, EVAL_BODY_TAGEVAL_BODY_AGAINEVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE| コンストラクタと説明 |
|---|
SwitchTag() |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
int |
doEndTag()
Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
|
int |
doStartTag()
Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
|
protected java.lang.String |
getKey()
switch のマッチ判定用のキーを取得します。
|
protected boolean |
isMatch()
すでにマッチしたかどうかを返します。
|
protected void |
release2()
タグリブオブジェクトをリリースします。
|
protected void |
setBreak()
case タグが、ブレイクした場合に、このメソッドを呼び出します。
|
void |
setKey(java.lang.String key)
【TAG】switch のマッチ判定用のキーを設定します。
|
java.lang.String |
toString()
このオブジェクトの文字列表現を返します。
|
add, add, addEventColumn, addEventColumn, check, check, commitTableObject, debugPrint, doAfterBody, doCatch, doFinally, get, getApplicationInfo, getAttributes, getBodyRawString, getBodyString, getContextAttribute, getContextPath, getCookie, getCSVParameter, getDataCondition, getDateFormat, getDBColumn, getDBFunctionName, getDocumentLink, getGUIInfo, getGUIInfoAttri, getHostName, getLabel, getLabelInterface, getLanguage, getLASTAttri, getLongLabel, getMsglbl, getNVLAttri, getObject, getParameterNames, getParameterRows, getRequest, getRequestAttribute, getRequestCacheData, getRequestMethod, getRequestParameter, getRequestParameterValues, getRequestValue, getRequestValue, getRequestValues, getReservedParameter, getReservedValue, getResource, getSanitizedBodyString, getScope, getSessionAttribute, getTagName, getUser, getUserEditInfo, getUserInfo, isAjaxSubmitRequest, isDebug, isNoTransitionRequest, isNull, jspPrint, removeContextAttribute, removeObject, removeRequestAttribute, removeSessionAttribute, set, setAjaxSubmitRequest, setCaseKey, setCaseNN, setCaseNull, setCaseVal, setContextAttribute, setCookie, setDebug, setLanguage, setLbl, setNoTransitionRequest, setObject, setObject, setParameterNames, setParameterRows, setRequestAttribute, setRequestCacheData, setScope, setSessionAttribute, setUserInfo, startQueryTransaction, sys, sysBool, sysInt, useMainTrans, useQuotCheck, useTag, useXssCheckdoInitBody, getBodyContent, getPreviousOut, release, setBodyContentfindAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValueclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetParent, setPageContext, setParentpublic SwitchTag()
public int doStartTag()
doStartTag インタフェース内 TagdoStartTag クラス内 CommonTagSupportpublic int doEndTag()
doEndTag インタフェース内 TagdoEndTag クラス内 CommonTagSupportprotected void release2()
release2 クラス内 CommonTagSupportpublic void setKey(java.lang.String key)
key - マッチ判定用のキーgetKey()switch のマッチ判定用のキーを設定します。
protected java.lang.String getKey()
setKey( String )protected void setBreak()
isMatch()protected boolean isMatch()
setBreak()public java.lang.String toString()
toString クラス内 CommonTagSupportWebアプリケーションフレームワーク openGionCopyright (c) 2009 The openGion Project.