Reputation: 37
im trying to display a form to modify a row in my table when i click an icon but nothing happen when i click , i'm using primefaces 3.4 and i have no problems in my bean , help please
<h:form>
<h1><h:outputText value="List Des Agents De Ministère"/></h1>
<p:dataTable value="#{agentBean.agentministeres }" id="agentList"
paginator="true" rows="10" var="item">
<p:column>
<f:facet name="header">
<h:outputText value="Action"/>
</f:facet>
<!--the problem in this commmandbutton i don't know if display or oncomplete dosn't word -->
<p:commandButton id="selectButton"
oncomplete="PF('dialog').show()"
update="display"
icon="ui-icon-search"
title="View"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="PrenomAgent"/>
</f:facet>
<h:outputText value="#{item.prenomAgent}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="TelAgent"/>
</f:facet>
<h:outputText value="#{item.telAgent}"/>
</p:column>
</p:dataTable>
</h:form>
and this is the form :
<h:form id="display">
<p:dialog header="Details" widgetVar="dialog" resizable="false" id="display"
showEffect="fade" hideEffect="explode" modal="true">
<h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
<h:outputLabel value="NomAgent:" for="nomAgent" />
<h:inputText id="nomAgent" value="#{agentBean.agentministere.nomAgent}" title="NomAgent" />
<h:outputLabel value="PrenomAgent:" for="prenomAgent" />
<h:inputText id="prenomAgent" value="#{agentBean.agentministere.prenomAgent}" title="PrenomAgent" />
<h:outputLabel value="TelAgent:" for="telAgent" />
<h:inputText id="telAgent" value="#{agentBean.agentministere.telAgent}" title="TelAgent" />
<p:commandButton value="Valider" image="ui-icon-disk" action="#{agentBean.enregistrerAgent}" />
</h:panelGrid>
</p:dialog>
</h:form>
Upvotes: 0
Views: 3786
Reputation: 5554
Following points will help you to fix your code.
update="display"
cannot work since display is not available in the namingcontainer. If the form <h:form id="display">
should be updated use update=":display"
Try putting the form inside your dialog, this will solve some problems you will maybe face while if you would update the form via ajax, this would hide the dialog.
<p:dialog widgetVar="dialog">
<h:form id="details">
<!-- input and commandbutton, now form can easily updated on submit -->
</form>
</p:dialog>
You must submit the selected row to the bean to show updates in the detail dialog:
<p:commandButton id="selectButton" icon="ui-icon-search"
update="display"
oncomplete="dialog.show();">
<f:setPropertyActionListener target="#{agentBean.agentministere} value="#{item}"/>
</p:commandButton>
Upvotes: 1