Facelets is a XML based view technology. The whole view has to be syntactically valid XML. XML special characters like &
, <
and >
needs to be escaped as &
, <
and >
when they're supposed to be interpreted as-is.
<f:validateRegex pattern="...&..." />
(here, the ...
represents the remainder of your regex)
A CDATA block won't work as it basically escapes the entire content, including JSF components. Quoting the escaped XML character makes no sense. After being parsed by the Facelets XML parser, the &
becomes &
again.
Update as per your update, the space in {3, 50}
is causing the regex syntax error. Remove it.
<p:inputText id="player_name_register" value="#{login.name}">
<f:validateRegex pattern="[&]{3,50}" />
</p:inputText>
Using CDATA blocks around the JSF component is not the right solution at all. It would XML-escape the entire content, resulting in <p:inputText>
being emitted plain vanilla instead of the component's HTML representation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…