Primefaces Dialog Framework -- DialogReturn Event From Menuitem
I have a primefaces p:datatable in Table.xhtml and have a p:commandbutton on the same page which I am using to open a dialog using dialog framework. The content related to dialog i
Solution 1:
I found the solution on How to trigger hidden JSF commandLink in JavaScript?
The updated version of Table.xhtml contains
<h:form id="form">
<p:dataTable id="colors" var="col" value="#{tableDialog.resourceList}" rowKey="#{col}"
selection="#{tableDialog.selected}" selectionMode="single">
<p:column headerText="Model">
#{col}
</p:column>
</p:dataTable>
<p:contextMenu for="colors">
<p:menuitem value="Add" onclick="triggerHiddenEvent(); return false;"
update=" :form:colors " >
</p:menuitem>
</p:contextMenu>
<p:commandButton id="hiddenCommand" styleClass="button" action="#{tableDialog.updateValue}" style="display:none">
<p:ajax event="dialogReturn" update = ":form:colors" />
</p:commandButton>
<h:outputScript >
function triggerHiddenEvent() {
document.getElementById("form:hiddenCommand").click();
}
</h:outputScript>
</h:form>
Post a Comment for "Primefaces Dialog Framework -- DialogReturn Event From Menuitem"