ユーザガイドによると、validationで"requiredif"ではなく"validwhen"が推奨されるようだ。
使い方は簡単で、このように"=="で条件を書くことができる。
<field property="emailAddress" depends="validwhen">
<arg0 key="userinfo.emailAddress.label"/>
<var>
<var-name>test</var-name>
<var-value>((sendNewsletter == null) or (*this* != null))</var-value>
</var>
</field>
注意しなければならないのは、この条件を満たす時はチェックOKということで、決してNGの条件を書くわけではない。
"Aがnullではないならば、このフィールドもnullではない"ことのチェック
○:((A == null) or (*this* != null))
×:((A != null) and (*this* != null))
あー、情報処理試験でいつも飛ばしておく論理式だな、こりゃ。
しばし悩んだのがこのエラー。
line 1:50: expecting RPAREN, found 'and' at antlr.Parser.match(Parser.java:213)
原因は、こういうことらしい。
A few quick notes on the grammer.
- All comparisons must be enclosed in parens.
- Only two items may be joined with <code>and</code> or <code>or</code>
- If both items to be compared are convertable to ints, a numeric comparison is done, otherwise a string comparison is done.
<var-value>(((A == null) and (B == null) and (C == null)) or (*this* != null))</var-value>
という記述はまかりならんということか。
正しい記述。
<var-value>((((A == null) and (B == null)) and (C == null)) or (*this* != null))</var-value>
・・・メンドクサ!