I have defined by custom Validator (implements javax.faces.validator.Validator interface and defined in faces-config). I need my custom component to call this validator within my component code ( Renderer class).
I want to make my xhtml as clean as possible and don’t want to invoke the validator separately in my xhtml by embedding
<f:validator validatorId='xx' />
within my component tag.
Just like how I can implement
getConvertedValue(FacesContext context, UIComponent component, Object submittedValue)
within my Renderer to handle conversion, can I do something similar to handle validation within Renderer?
Thanks
This is to be done at the UI component level, not at the renderer level. Your custom input component must surely already extend
UIInput, otherwise you’ve many other (future) problems and/or you’ll waste time in writing repeated code. If your custom input component extendsUIInput, then you can just add theValidatorby the inheritedUIInput#addValidator()method in for example the component’s constructor.The already-implemented
UIInput#validate()method will do all the conversion, validation and message handling automagically.