cancel
Showing results for 
Search instead for 
Did you mean: 

Validator with several methods

hgonzalez_
Confirmed Champ
Confirmed Champ

I have a validator class with a validate() method, I added another method [validate2()] to validate another field. How can I specify in Studio to call the second method?

1 ACCEPTED ANSWER

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

Hi,

If you're using a standard JSF validator (e.g implementing the interface javax.faces.validator.Validator), it means you're declaring it as a validator to the JSF context and using its identifier to use it inside an input tag, using the "f:validator" tag for instance. Other methods that you could add to this implementation will not be called as they're not part of the Validator interface.

That's why it's much easier to use a standard Seam component, and declare any number of methods that will be used as validation methods, provided you follow the expected signature: "a validator method must be a public method that takes FacesContext, UIComponent, and Object parameters, with a return type of void".

Once you've done that, in Studio you can reference this method in the "validator" property of the widget where you'd like the validation to occur, using a method binding like "#{mySeamComponent.validate2}" for instance.

View answer in original post

2 REPLIES 2

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

Hi,

If you're using a standard JSF validator (e.g implementing the interface javax.faces.validator.Validator), it means you're declaring it as a validator to the JSF context and using its identifier to use it inside an input tag, using the "f:validator" tag for instance. Other methods that you could add to this implementation will not be called as they're not part of the Validator interface.

That's why it's much easier to use a standard Seam component, and declare any number of methods that will be used as validation methods, provided you follow the expected signature: "a validator method must be a public method that takes FacesContext, UIComponent, and Object parameters, with a return type of void".

Once you've done that, in Studio you can reference this method in the "validator" property of the widget where you'd like the validation to occur, using a method binding like "#{mySeamComponent.validate2}" for instance.

OK, thanks, I will try with the Seam component.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.