I'm developing application with JSF and PrimeFaces, that allows editing row of p:dataTable inside p:dialog. Since I've added validation to the input fields I'm having difficulties with keeping dialog open when the errors occurs, and displacing error messages inside the dialog. What is happening, after I click the commandButton the dialog closes and the messages aren't visible. When I reopen dialog, the field is red but the messages are still not visible.
<!-- Dialog box for editing row -->
<p:dialog id="editDialogWindow" header="Row Editing" widgetVar="editDialog" modal="true">
<p:panelGrid columns="5">
<p:outputLabel>Title</p:outputLabel>
<p:outputLabel>Author</p:outputLabel>
<p:outputLabel>Number Of Pages</p:outputLabel>
<p:outputLabel>Year Of Publication</p:outputLabel>
<p:outputLabel>Price</p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.title}" id="titleInput" required="True" requiredMessage="You must give the title" />
<p:inputText value="#{libraryBean.selectedBook.author}" id="authorInput" required="True" requiredMessage="You must give the author" />
<p:inputText value="#{libraryBean.selectedBook.numberOfPages}" id="numberOfPagesInput" required="True" requiredMessage="You must give the number of pages" />
<p:inputText value="#{libraryBean.selectedBook.year}" id="yearInput" required="True" requiredMessage="You must give the date of publication" >
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
</p:inputText>
<p:inputText value="#{libraryBean.selectedBook.price}" id="priceInput" required="True" requiredMessage="You must give the price" >
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</p:inputText>
<p:commandButton value="Submit Changes" oncomplete="if(!args.validationFailed) {editDialog.close()}" update=":form" actionListener="#{libraryBean.incrementCounter}"/>
<p:commandButton value="Cancle" onclick="editDialog.close()" update=":form" process="@none" immediate="true"/>
</p:panelGrid>
<p:message for="titleInput" />
<p:message for="authorInput" />
<p:message for="numberOfPagesInput" />
<p:message for="yearInput" />
<p:message for="priceInput" />
</p:dialog>
EDIT
I have solved all problem and I'm providing working code for references.
<!-- Dialog box for editing row -->
<p:dialog id="editDialogWindow" header="Row Editing" widgetVar="editDialog" modal="true">
<h:form id="dialogForm">
<p:panelGrid columns="5" rendered="#{!(libraryBean.selectedBook==null)}" id="panelGrid">
<p:outputLabel>Title</p:outputLabel>
<p:outputLabel>Author</p:outputLabel>
<p:outputLabel>Number Of Pages</p:outputLabel>
<p:outputLabel>Year Of Publication</p:outputLabel>
<p:outputLabel>Price</p:outputLabel>
<p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.title}" id="titleInput"
required="True" requiredMessage="You must give the title" />
<p:message for="titleInput" />
</p:outputLabel>
<p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.author}" id="authorInput"
required="True" requiredMessage="You must give the author" />
<p:message for="authorInput" />
</p:outputLabel>
<p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.numberOfPages}" id="numberOfPagesInput"
required="True" requiredMessage="You must give the number of pages"
converterMessage="This must be a number"/>
<p:message for="numberOfPagesInput" />
</p:outputLabel>
<p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.year}" id="yearInput"
required="True" requiredMessage="You must give the date of publication"
converterMessage="The date format is dd/mm/yyyy" >
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
</p:inputText>
<p:message for="yearInput" />
</p:outputLabel>
<p:outputLabel>
<p:inputText value="#{libraryBean.selectedBook.price}" id="priceInput"
required="True" requiredMessage="You must give the price"
converterMessage="This must be a number " >
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</p:inputText>
<p:message for="priceInput" />
</p:outputLabel>
<p:commandButton value="Save" oncomplete="if(!args.validationFailed) editDialog.hide()" update="dialogForm, :form" actionListener="#{libraryBean.incrementCounter}"/>
<p:commandButton value="Exit" onclick="editDialog.hide()" update="dialogForm" process="@this" immediate="true">
<p:resetInput target="dialogForm:panelGrid"/>
</p:commandButton>
</p:panelGrid>
</h:form>
</p:dialog>