I am looking for some guidance today with the problem I am facing.
What I'm trying to do is build a page on the fly with validation and all. The end result is to allow the user to customize the fields on the page using administrative functions. Below is a copy of the code that I use as a test page, where I go through the "Configure" fields and write out the fields using certain criteria.
<ui:repeat var="field" value="#{eventMgmt.eventFields}" varStatus="status">
<div class="formLabel">
<h:outputLabel value="#{field.customName}:"></h:outputLabel>
</div>
<div class="formInput">
<h:inputText id="inputField" style="width:# {field.fieldSize gt 0 ? field.fieldSize : 140}px;">
<f:validateRegex disabled="#{empty field.validationPattern}" pattern="#{field.validationPattern}"></f:validateRegex>
</h:inputText>
<h:message for="inputField" showDetail="true" errorClass="errorText"></h:message>
</div>
</ui:repeat>
After the page is displayed and I try to pass any values ββfor the field, I get the following message: "The Regex template must be set to a non-empty value." which, obviously, means that the expression is empty. I am wondering that fields that do not have an expression for them will be disabled when EL is evaluated. I can also take the same code # {field.validationPattern} and put it on the page, and the correct value will be written on the page.
So my questions are: 1. Is this possible? 2. At what point does the JSF container look at the template binding for the validate regular expression? 3. What am I doing wrong or What is the right way to do this?
I am running Tomcat 7.0.22, Mojarra 2.1.5 and Eclipse as my IDE.
Miker source
share