Lothar Mueller
Lothar Mueller

Reputation: 2528

xpages: how to build my own requiredValidator using java

I've built several custom validator beans and registered them through the database's faces-config. This is mostly working as expected.

I tried both methods that are described in Jeremy Hodges blog post:

a) calling a managed bean through the control's validator attribute as in

validator="#{myBean.validate}"

b) binding the validate method to the control's xp:validator complex attribute as in

<xp:this.validators>
  <xp:validator validatorId="myValidator"></xp:validator>
</xp:validators>

Validation works as expected as long as the control to be validated contains a value; it's not firing at all if the control's value is null. This leads me to the conclusion that somehow a standard required validator (xp:validateRequired) must be invoked somehow differently from other validators. Question is: how can I get my customValidator to be called in a situation where a requiredValidator would be fired?

Upvotes: 2

Views: 57

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

Yes, requiredValidators have to be handled differently. Have you tried Sven Hasselbach's advice on his blog? http://hasselba.ch/blog/?p=764

Also, Sven's answer on this quesstion about custom validators might be worth considering when creating validators customValidator without requiredValidator?.

Upvotes: 1

Related Questions