Validation: What Am I Missing
leesy Sep 29, 2008 5:10 PMHi all,
I'm just trying to get my validation working on my page but I'm not having much luck. I must be missing something simple so could someone have a quick look at my code below and see if you notice anything out of place.
Thanks,
Lee
The error message is created using:
getFacesMessages()
.addToControlFromResourceBundleOrDefault(
"customerName",
SEVERITY_ERROR,
"CustomerExternalIdDuplicate",
"A customer with an external ID of {0} already exists. Please choose another",
getInstance().getExternalId());My page - a modal dialog included via a4j:include. (I've tested the code out of the modal dialog though and still no luck):
<h:form id="modalForm">
<h:messages globalOnly="true" />
<fieldset>
<s:validateAll>
<f:facet name="aroundInvalidField">
<s:span styleClass="errors" />
</f:facet>
<f:facet name="afterInvalidField">
<s:div styleClass="errors">
<s:message />
</s:div>
</f:facet>
<ul class="layout form">
<li>
<label for="customerName">Name:</label>
<s:decorate>
<h:inputText id="customerName" value="#{customerHome.instance.externalId}" />
</s:decorate>
</li>
<li>
<label for="customerDisplayName">Display Name:</label>
<s:decorate>
<h:inputText id="customerDisplayName" value="#{customerHome.instance.displayName}" />
</s:decorate>
</li>
<li>
<label for="customerAccountManager">Account Manager</label>
<s:decorate>
<h:selectOneListbox id="customerAccountManager" value="#{customerHome.instance.accountManager}">
<s:selectItems var="item" value="#{accountManagersList}" label="#{item.displayName}" hideNoSelectionLabel="true"/>
<s:convertEntity />
</h:selectOneListbox>
</s:decorate>
</li>
<li>
<label for="customerDemo">Demo Customer?</label>
<s:decorate>
<h:selectBooleanCheckbox id="customerDemo" value="#{customerHome.instance.demo}" />
</s:decorate>
</li>
<li>
<a4j:commandButton value="Add New Customer" action="#{customerHome.persist}" reRender="resultsTable"/>
</li>
</ul>
</s:validateAll>
</fieldset>
</h:form>I'm just constantly getting the error
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=modalForm:j_id103:customerName[severity=(ERROR 2), summary=(A customer with an external ID of abc already exists. Please choose another), detail=(A customer with an external ID of abc already exists. Please choose another)]
The form input described in that error does exist, it just can't seem to link the message to it. So - any suggestions?