How to specify a validator for an input component inside a composite component?

后端 未结 3 1200
天命终不由人
天命终不由人 2020-12-06 07:44

Should I register a custom validator in faces-config.xml if I\'m using JSF 2.0.4? My custom validator uses Validator interface which is javax.faces.valida

3条回答
  •  难免孤独
    2020-12-06 08:37

    As per the code example in your updated question, you seem to not be delegating the validator to the right input at all, so the validator is simply ignored altogether.

    You need to define the desired input (for which you'd like to attach a validator) as a in the .

    
        
        ...
    
    
        ...
        
        ...
    
    

    The above basically tells that any must be applied on the . So, the following should then do it:

    
        
    
    

    You can even use the same value in name and targets, but the key point is that there must be a present so that JSF knows on what input component exactly the validator should be targeted, there can namely be more than one input component in the composite, you see.

提交回复
热议问题