1

I am using a f:validateRegex in my JSF to ensure that the user enters a value in the h:inputText that starts with 2 uppercase letters, followed by 6 digits and then 2 uppercase letters. However, when I enter a value of “a45” the f:validateRegex does not flag it as an error.

Here is the source code:

<h:column>
                        <f:facet name="header">Part Number</f:facet>
                        <h:inputText id="pnumber"
                            value = "#{p.number}"
                                    size = "15"
                                    rendered = "#{p.canUpdate}">
                        <f:validateRegex
                            pattern="^[A-Z]{2}[0-9]{6}[A-Z]{2}"
                            for="pnumber"
                            />
                    </h:inputText>
                        <h:outputText value = "#{p.number}"
                                      rendered = "#{not p.canUpdate}" />
                    </h:column>

Any idea, how to make this work?
Thanks

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Darvin
  • 148
  • 8
  • @BalusC: Thanks for the hint. I am trying to learn the JSF coding by following examples in EE7 Tutorial documentation that I downloaded from Oracle in pdf format. In chapter 10 section 10.2.7 there is an example on f:validateRegex without any submit button or an ajax keyup listener. All provided is a f:converter and f:validateRegex inside the h:inputText. I am a bit lost here, would you point me to a complete example so I can see a bigger picture? Thanks – Darvin Dec 10 '20 at 17:58
  • Please avoid using Oracle or Apache documentations. They are extremely esoteric, obscure, containing poor phrasing (typically produced by off-shore resources), most often archaic and in general the abomination. If I want to understand how something works, I just google (i.e. example of f:validateRegex) and this produces a few good comprehendible examples with clear explanations. This eliminates the need to post a question on here and perhaps to deal with sinde remarks. – Anthony Dec 10 '20 at 18:12
  • Thanks Anthony, following your recommendation,I did find an example on mkyong.com and now my code works. If you put your comment in the answer, I will mark it. – Darvin Dec 10 '20 at 18:32

1 Answers1

0

Please avoid using Oracle or Apache documentation. They are extremely esoteric, obscure, containing poor phrasing (typically produced by off-shore resources), most often archaic and in general the abomination. If I want to understand how something works, I just google (i.e. example of f:validateRegex) and this produces a few good comprehendible examples with clear explanations.

Anthony
  • 135
  • 1
  • 14