【发布时间】:2018-04-05 13:44:22
【问题描述】:
我正在开发基于 web 的 java 应用程序,我正在使用 jsf 2.2 和 prime faces, 我面临这个问题:我有两个按钮,第一个是删除,另一个是编辑,删除按钮打开一个确认对话框,还有另外两个按钮是/否,编辑按钮打开一个编辑对话框,我的问题是当我单击确认对话框中的“是”按钮,它不起作用,但是当我从代码中删除编辑对话框并重新启动程序时,“是”按钮工作正常。 我希望找到一个解决方案,可以帮助我将编辑对话框保留在代码中并使“是”按钮正常工作。
页面代码示例:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:hftl="http://hftl.org"
xmlns:hf="http://xmlns.jcp.org/jsf/composite/tags"
template="../../templates/template.xhtml"
xmlns:e="http://primefaces.org/extension">
<ui:param name="pageTitle" value="#{messages['account.search']}" />
<ui:define name="content">
<h:form>
<p:commandButton value="delete" onclick="PF('deletedlg').show()"
id="delBtn" />
<p:commandButton value="edit" onclick="PF('editDlg').show()" id="edtBtn"/>
<p:dataTable var="admin" value="#{adminBean.getLazyDataModel()}"
paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink}
{PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" id="dataTable" lazy="true"
binding="#{adminBean.dataTable}"
selection="#{adminBean.selectedEntity}" selectionMode="single">
<p:column headerText="id">
<h:outputText value="#{admin.id}" id="xxxx" />
</p:column>
<p:column headerText="username">
<h:outputText value="#{admin.username}" id="asdssasd" />
</p:column>
</p:dataTable>
<p:dialog header="Notice" widgetVar="deletedlg" modal="true"
showEffect="fade" hideEffect="fade" resizable="false" id="deletedlg">
<p:outputPanel style="text-align:center;">
<h:outputText value="are you sure you want to delete" />
<p:commandButton value="Yes"
actionListener="#{adminBean.onDleteClicked()}" id="yesBtn" />
<p:commandButton value="No" onclick="PF('deletedlg').hide()" id="noBtn" />
</p:outputPanel>
</p:dialog>
<p:dialog header="Edit" widgetVar="editDlg" modal="true"
showEffect="fade" hideEffect="fade" resizable="false" id="editDlg">
<p:outputPanel style="text-align:center;">
<hf:textBox componentId="userNameTxt" label="username"
value="#{adminBean.entity.username}"
placeholder="enter user name here" />
<hf:textBox componentId="passwordTxt" label="passsword"
value="#{adminBean.entity.password}"
placeholder="enter password here" isPassword="true" />
<hf:textBox componentId="rPasswordTxt" label="passsword"
value="#{adminBean.rPassword}" placeholder="enter password here"
isPassword="true" />
<p:commandButton value="save"
actionListener="#{adminBean.onEditSaveClicked()}" id="saveBtn"/>
</p:outputPanel>
</p:dialog>
</ui:define>
【问题讨论】:
-
请将您的标题更改为具体问题,这需要您创建一个minimal reproducible example。
标签: spring jsf primefaces