2012-04-20 52 views
1

這可能是很簡單的,我嘗試添加基於另一場 式語言驗證: @If(Desinfect_1 =「」 & Desinfect =「消毒的殺菌劑跟班」; @Failure(「Veuillez cocher離開OU大堤「); //成功)的XPages驗證

XPages中,我試圖與驗證表達式:

<xp:inputText value="#{document1.chambre}" id="chambre1"> 
<xp:this.rendered><![CDATA[#{javascript:getComponent ("Desinfect1").getValue() == "Désinfection de chambre"}]]></xp:this.rendered> 
<xp:this.validators> 
<xp:validateExpression 
message="err"> 
<xp:this.expression><![CDATA[#{javascript:if (GetComponent ("Desinfect1").getValue() == "Désinfection de chambre" & GetComponent ("Chambre1").getValue() == ""){ 
return false; 
} 
else { 
return true; 
}}]]></xp:this.expression> 
</xp:validateExpression> 
</xp:this.validators> 
</xp:inputText> 
+0

很抱歉,但什麼問題/你的問題? – 2012-04-20 13:46:08

+1

順便說一句:SSJS是大小寫敏感的。 GetComponent不起作用。使用getComponent代替;-) – 2012-04-20 14:03:02

+0

問題是驗證不起作用我會嘗試getComponent – user1339222 2012-04-20 15:03:15

回答

0

嘗試添加一些打印出來,看看你的領域得到正確的價值觀

+0

將嘗試 - 謝謝 – user1339222 2012-04-20 18:28:24

2

當你正在做的邏輯運算符和在JavaScript中,你必須使用& &

<xp:this.validators> 
    <xp:validateExpression message="err"> 
     <xp:this.expression> 
      <![CDATA[#{javascript: if (getComponent("Desinfect1").getValue() == "Désinfection de chambre" && getComponent("Chambre1").getValue() == ""){ return false; } else { return true; }}]]> 
     </xp:this.expression> 
    </xp:validateExpression> 
</xp:this.validators>