Jsf 2 如何将验证器方法传递给复合组件

Jsf 2 如何将验证器方法传递给复合组件,jsf-2,composite-component,customvalidator,Jsf 2,Composite Component,Customvalidator,我创建了自己的inputText复合组件,它封装了Primefaces 3.4.5中的p:inputText。它工作得很好,但我不知道如何将bean验证程序方法传递给p:inputText中的validator属性。我已经读过关于在复合组件中使用f:validator标记的内容,但是我确实需要在p:inputText上使用validator属性。如果我从xhtml中删除复合组件,只使用常规的p:inputText,那么方法和验证代码就可以正常工作 我的cc属性是: <composite:a

我创建了自己的inputText复合组件,它封装了Primefaces 3.4.5中的p:inputText。它工作得很好,但我不知道如何将bean验证程序方法传递给p:inputText中的validator属性。我已经读过关于在复合组件中使用f:validator标记的内容,但是我确实需要在p:inputText上使用validator属性。如果我从xhtml中删除复合组件,只使用常规的p:inputText,那么方法和验证代码就可以正常工作

我的cc属性是:

<composite:attribute name="validator" method-signature="void f(javax.faces.context.FacesContext,
                                     javax.faces.component.UIComponent,
                                     java.lang.Object)" targets="inputTextField"/>
但是,我确实在视图范围的控制器bean中定义了该方法:

public void validateCode(FacesContext context, UIComponent component, Object value) throws ValidatorException {
 ... code ....
}
有人知道我错过了什么吗

我正在使用Mojarra 2.1.21


谢谢

谢谢的可能副本。你是对的。我的错误是在cc:attribute中添加了'targets'属性。一旦我把它去掉,一切都正常了。@WanLi我的解决方案是在cc:attribute中添加
targets
属性,但不要在输入字段中声明validator属性(请参见我的答案:)
Exception type: class javax.el.PropertyNotFoundException
Exception message: /view/configuration/dictionaryupdate/DictionaryItem.xhtml @27,123        validator="#{dictionaryUpdateController.validateCode}": The class 'com.ntst.caremanager.feature.dictionaryupdate.controllers.DictionaryUpdateController' does not have the property 'validateCode'.
public void validateCode(FacesContext context, UIComponent component, Object value) throws ValidatorException {
 ... code ....
}