如果我使用JSF 2.0.4,我應該在faces-config.xml
中註冊一個自定義驗證器嗎? 我的自定義驗證器使用的驗證器接口是javax.faces.validator.Validator
。如何爲複合組件內的輸入組件指定驗證程序?
<cc:myComp id="customcomp1" ... />
<cc:myComp id="customcomp2" ...>
<f:validator id="myvalidator" for="myComp" />
</cc:myComp>
myComp.xhtml
<cc:interface>
<cc:attribute ... />
<!-- more attributes -->
</cc:interface>
<cc:implementation>
<h:panelGroup layout="block">
<h:inputText id="firstName" ... />
<h:inputText id="middleName" ... />
<h:inputText id="lastName" ... />
</h:panelGroup>
</cc:implementation>
您似乎在使用自定義組件或複合組件。你需要展示你是如何創建它的。也許你根本沒有正確地委託驗證器。 – BalusC 2012-01-09 12:10:53