我是jsf中的新手,我想使用primeface的contextMenu来删除方法。但是从不调用delete方法。这里是代码的一部分。我不知道我错在哪里
<p:dataTable id="dataTable" var="bon" widgetVar="bonTable" value="#{bonEssenceBean.allBonEssence}" rowKey="#{bon.idBon}" selection="#{bonEssenceBean.bonEssence}" selectionMode="single" sortMode="single" rows="10" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,15,25">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search:" style="Height:30px"/>
<p:inputText id="globalFilter" onkeyup="bonTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<!-- <p:ajax event="rowEdit" listener="#{bonEssence.updateBon}" /> -->
<!-- <p:ajax event="rowEditCancel" listener="#{tableBean.onCancel}" update=":form:messages" /> -->
<p:column sortBy="#{bon.idBon}" headerText="ID Bon" filterBy="#{bon.idBon}" filterMatchMode="contains">
#{bon.idBon}
</p:column>
<p:column sortBy="#{bon.vehicule.immat}" headerText="Vehicule:" filterBy="#{bon.vehicule.immat}" filterMatchMode="contains">
#{bon.vehicule.immat}
</p:column>
<p:column sortBy="#{bon.quantite}" headerText="Quantité:" filterBy="#{bon.quantite}" filterMatchMode="contains">
#{bon.quantite}
</p:column>
<p:column sortBy="#{bon.prix}" headerText="Prix" filterBy="#{bon.prix}" filterMatchMode="contains">
#{bon.prix}
</p:column>
<p:column sortBy="#{bon.dateBon}" headerText="Date" filterBy="#{bon.dateBon}" filterMatchMode="contains">
#{bon.dateBon}
</p:column>
<p:column>
<p:commandButton value="Imprimer" icon="ui-icon-search" oncomplete="printDialog.show()" >
<f:setPropertyActionListener target="#{bonEssenceBean.bonEssence}" value="#{bon}"></f:setPropertyActionListener>
</p:commandButton>
</p:column>
<p:column>
<h:commandButton value="Delete" update="dataTable" icon="ui-icon-close" actionListener="#{bonEssenceBean.deleteBo}" >
<f:setPropertyActionListener target="#{bonEssenceBean.bonEssence}" value="#{bon}"></f:setPropertyActionListener>
</h:commandButton>
</p:column>
<!-- <h:column headerText="delete">
<h:commandLink id="Delete" actionListener="#{bonEssenceBean.deleteBon}">
<h:outputText value="Delete" />
<f:param id="deleteId" name="id" value="#{bonEssence.idBon}" />
</h:commandLink>
</h:column>-->
</p:dataTable>
</h:form>
管理
public void deleteBon(ActionEvent event){
System.out.println("delete");
essenceService.deleteBon(bonEssence);
}
和deleteBon从未调用
答案 0 :(得分:0)
如果你不打算使用ActionEvent,那么你可以试试这个:
<h:commandLink id="Delete" action="#{bonEssenceBean.deleteBon()}">
public void deleteBon(){
System.out.println("delete");
essenceService.deleteBon(bonEssence);
}