Im my web app i have the following form that opens up in a dialog:
<!-- Event edit -->
<p:dialog id="editEvent"
widgetVar="dlgEdit"
modal="true"
resizable="true"
closable="true"
header="Edit event">
<p:panelGrid columns="1"
styleClass="gridNoLine">
<p:panelGrid columns="1">
<p:messages id="mEditMessages"
closable="true"
redisplay="true"/>
</p:panelGrid>
<p:panelGrid columns="2" styleClass="gridNoLine">
<h:outputLabel value="..." />
<p:inputText value="#{eventBean.event.eventName}"
required="true"
requiredMessage="XXX"/>
</p:panelGrid>
<p:panelGrid columns="2" styleClass="gridNoLine">
<h:outputLabel value="..." />
<p:inputTextarea value="#{eventBean.event.eventDescription}"
required="true"
requiredMessage="XXX" />
</p:panelGrid>
...
<p:commandButton id="cbUpdateEvent"
value="Update"
actionListener="#{eventBean.update}"
oncomplete="handleAction(xhr, status, args);"
process="@form"
update="mEditMessages OTHERCONTROLS"/>
</p:panelGrid>
</p:dialog>
This dialog is opened from a commandButton column for each row of a DataTable as the following code shows:
<p:dataTable value="#{eventBean.events}"
var="event">
<p:column styleClass="commandColumn">
<f:facet name="header">
<h:outputLabel value="Editar"/>
</f:facet>
<p:commandButton image="ui-icon-pencil"
title="Edit"
update="editEvent"
oncomplete="dlgEdit.show();"
process="@this">
<f:setPropertyActionListener value="#{event}" target="#{eventBean.event}" />
</p:commandButton>
</p:column>
...
</p:dataTable>
The problem is: When i open the dialog, clear a random field (just to test validation) and click the update button a warning message shows on the dialog. Fine. But when i clear another field and click the update button, the required message associated with that control doesn’t show. And then when i close the dialog and click once again in any alter column of any row nothing happens. I can see the following message on the browser console:
Uncaught SyntaxError: Unexpected token {
OBS: If i click the edit command and do not modify any field and just close, the app works fine and i can view the edit dialog for other records.
UPDATE:
Here is the template.xhtml code:
<h:body>
<div class="structure">
<div class="top">
</div>
<!--Base Menu -->
<h:form id="menu">
<div class="menu">
<p:menubar autoDisplay="true" >
...
</p:menubar>
</div>
</h:form>
<!-- Conteúdo -->
<div class="left_content">
<ui:insert name="content">
</ui:insert>
</div>
...
</div>
</h:body>
And here is the handleAction code:
function handleAction(xhr, status, args){
switch(args.key){
case 'update':
dlgEdit.hide();
break;
}
}
I’ve found the error. I just was importing the primefaces jar twice as pointed here. I had a primefaces-3.4.jar in my WEB-INF/lib folder and in my pom.xml file. I did remove the jar inside WEB-INF/lib and everything went right.