Hey,
I have problems with @AssertTrue in my JSF backing bean. What I need is to check whether email address is unique, but the corresponding method in the backing bean is not called. If I understand it right, it should be called automaticaly. Validation on the getMailboxAddress function works just fine. What is wrong?
Here is the code of the backing bean
Code:
@Pattern(regex = "^[a-zA-Z0-9._%+-]+$")
public String getMailboxAddress() {
if (mailbox == null) {
return null;
}
if (mailbox.getAddress() != null) {
int indexOfDomain = mailbox.getAddress().indexOf(mailbox.getMailDomain().getDescription()) - 1;
return mailbox.getAddress().substring(0, indexOfDomain);
}
return null;
}
@AssertTrue(message = "{addressIsNotUnique}")
public boolean isAddressUnique() {
if (mailbox == null) {
return false;
}
EmailService emailService = new EmailService();
if (emailService.findMailboxByAddress(mailbox.getAddress()) == null) {
return true;
}
return false;
}
Here is the xhtml page:
Code:
<h:inputText id="username" label="#{emailBundle.mailboxAddress}" required="true" value="#{modules$email$MailboxEditBean.model.mailboxAddress}">
<rich:beanValidator/>
</h:inputText>
I am using Hibernate Validator 3.0.0.GA.
Thanks for any help!