I am looking for a little bit of guidance today with the issue I am running into.
What I am trying to accomplish is build a page on the fly with validation and all. The end result is to allow the user to configure the fields on the page through administrative functions. Below is a copy of the code that I am using as the test page where I loop through the "Configured" fields and write out the fields using the defined 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 renders and I attempt to submit any values for the field, I get the following message "Regex pattern must be set to non-empty value." which obviously means that the expression is not populated. What makes it interesting to me is that fields that do not have an expression for them will be disabled when the EL is evaluated. I can also take the same code #{field.validationPattern} and put it in the page and the correct value will be written on the page.
So, my question(s) are:
1. Is this possible?
2. At what point does the JSF container look at binding the Pattern for the validate regex?
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…