4

I think my problem is simple enough, but I can't seem to overcome it. I'm using an input text for emails like this:

<h:outputLabel value="Mail:" for="mail" />
                 <p:inputText id="mail" value="#{UtilisateurBean.mail}"
                    title="Mail" validator="#{UtilisateursValidate.email}"
                    validatorMessage="ecrivez un mail valide">
                    <f:validateRegex
                       pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                    <f:validateLength minimum="2" />

The problem is that it doesn't support the dot character before the @ like nouraty.n@mail.com (which is usually the case for gmail). I tried stuff like:

pattern="[\w\.-]*[a-zA-Z0-9._%-]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"

pattern="[\w\.-]*[a-zA-Z0-9\._%-]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"

But no luck. Can anyone suggest a solution for this issue?

Keplah
  • 954
  • 2
  • 13
  • 26
nouraty
  • 156
  • 1
  • 14
  • 1
    works for me just fine (tested with nouraty.n@mail.com) – Daniel Jul 25 '12 at 13:20
  • :s then could their be any other reason why nouraty@mail.com works but not nouraty.n@mail.com?? even thow i doubt it! – nouraty Jul 25 '12 at 13:42
  • What exactly is `validator="#{UtilisateursValidate.email}"` doing? Isn't it performing the validation against an invalid pattern? What if you remove that attribute? Note that validators are executed in the order as they're declared on the component, starting with the `validator` attribute as the first one. – BalusC Jul 25 '12 at 14:08
  • that's me trying somthing and forgot to take it off, i've been looking at it so much that i'm not seing the obvious. than you so much it was actualy another validation in a class that was taking controle. – nouraty Jul 25 '12 at 14:23
  • Okay. I reposted it as an answer so that you can accept it. – BalusC Jul 25 '12 at 14:55

1 Answers1

1

JSF validators are executed in the order as they're declared on the component, starting with the one in the component's validator attribute, if any. You've there a validator="#{UtilisateursValidate.email}". If it's validating against a different (and wrong) pattern and throwing a ValidatorException, then you'll still keep seeing the validator message.

Removing or fixing that validator should solve your problem.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555