【发布时间】:2022-01-05 21:15:46
【问题描述】:
我有一个嵌套的数据表,它有一个编辑命令按钮,显示一个对话框模式,
<p:commandButton value="Edit" oncomplete="PF('editStudy').show()" type="button">
<p:ajax event="click" listener="#{queryStudiesBean.setRenderDialog(true)}" update="editDialogStudy" />
<p:ajax event="click" listener="#{queryStudiesBean.setEditableStudyIndex(studyIndex)}" update="editDialogStudy: />
<p:ajax event="click" listener="#{queryStudiesBean.setEditablePatientIndex(patientIndex)}" update="editDialogStudy" />
</p:commandButton>
我正在修复更新后保持子数据表行扩展的问题,我正在关注这个answer,但我遇到了另一个问题,即一旦我加载数据表页面,甚至在我点击编辑按钮之前,具有更新属性的对话框命令按钮被评估,
<p:commandButton process="@form" update="@form,:form2:patient-dt:#{queryStudiesBean.editablePatientIndex}:study-dt" action="#{queryStudiesBean.updateStudy()}" oncomplete="PF('editStudy').hide()" value="Save" styleClass="fixed-button-size" />
,这给出了空错误,因为patientIndex 仍然为空,因为我什至没有点击数据表的编辑按钮来设置patientIndex。
所以我设法通过在对话框中添加rendered="#{queryStudiesBean.renderDialog}" 属性来解决这个问题。
现在我很难在编辑按钮操作中将此布尔值设置为 true,对话框现在不显示,在上面的代码中,我使用了 oncomplete,并在 action 属性和 <f:setPropertyActionListener> 对我不起作用,我认为布尔值将在调用 oncomplete 之前设置为 true,所以对话框显示,但这没有发生,有人可以向我解释为什么? 我看了很多帖子,但没有人为我工作。
我正在使用: 素面6.2, java8
【问题讨论】:
-
找不到
parentIndex。如果您的update="@form,:form2:patient-dt:#{queryStudiesBean.editablePatientIndex}:study-dt引用了 parentIndex,则在呈现按钮时它已经被调用。 1. 您的update="editDialogStudy"必须是update=":editDialogStudy",因为它位于数据表的一行中。 2.你更新了表单,但是rendered在表单之外,所以不会更新。在对话框周围放置<h:panelGroup并更新 panelGroup -
谢谢,它成功了,是的,parentIndex 的意思是可编辑的PatientIndex,我编辑了我的问题并重命名了它,把你的评论作为答案,我会接受它。
标签: jsf primefaces