Primefaces嵌套号码:对话框DOM节点重复嵌套、节点、对话框、号码

2023-09-10 19:43:27 作者:鼻毛打摩斯

我有一个 P的内侧列表元素的详细信息表单开口道:对话框。这号码:又对话框显示另一个列表。从这个名单,我可以打开它的任何元素的细节嵌套 P的内侧:对话

I have a list element detail form opening inside a p:dialog. This p:dialog in turn shows another list. From this list, I can open any of its element's details inside a nested p:dialog.

的问题是:每次打开一个对话框,一组新的id的在嵌套对话框中的元素的生成,用相同的值。

The problem is: every time I open a dialog, a new set of ids for the elements in the nested dialog is generated, with the same value.

我结束了我的DOM什么,当我尝试选择从嵌套对话框,如 $('#manageIssue \\:newEventComment)的特定ID; ,是一个阵列具有相同ID的元素。

What I end up with in my DOM when I try to select a particular id from the nested dialog, such as $('#manageIssue\\:newEventComment');, is an array of elements with the same id.

我已经确定有每个每个我打开一个对话框,一次一个副本,加上另外一个是从那里开始。

I have determined there is one copy per each time I open a dialog, plus another one which is there from the beginning.

当嵌套对话框关闭嵌套的对话框DOM节点没有被破坏,正在生成一组全新的重叠IDS每次打开一个对话框时间

这个问题是关系到 primefaces更新属性不工作模态对话框,模态对话框打开。

This question is related to primefaces update attribute not working on modal dialog opened from modal dialog.

(我解决了原来的问题,通过从形式 prependId 属性,但是这其中仍然存在。)

(I solved the original problem by removing the prependId attribute from the form, but this one remained.)

由于这个问题是一个有点难以重现,我建立了一个MCVE。所有的东西(支持bean,观点,pom.xml的,等等),加起来〜500线code,所以我分享它在github上回购:的 https://github.com/el$c$cdocle/testt

Because this problem is a little difficult to reproduce, I have built a MCVE. All the stuff (backing beans, views, pom.xml, etc.) adds up to ~500 lines of code, so I have shared it on a github repo: https://github.com/elcodedocle/testt

这里的问题归结为:

我怎样才能让这个MCVE工作(即有评论从一个委员会的问题清单从佣金名单事件添加到一个问题),如果没有这一行:

How can I make this MCVE work (i.e. add events with comments to an issue from a list of issues of a commission from a list of commissions), without this line:

https://github.com/el$c$cdocle/testt/blob/fbfeb7fca474c66c202c92e469ca185c6bf569c2/src/main/webapp/views/widgets/issue_detail_edit.xhtml#L21

推荐答案

此问题是由嵌套的<电话号码:。对话框>

<p:dialog id="commissionDetail">
    ...
    <p:dialog id="issueDetail">
        ...
    </p:dialog>
</p:dialog>

这是不允许的。该技术的原因是,再$ P $中的HTML DOM元素psenting对话框是JavaScript的搬迁到&LT的尽头;身体GT; ,以保证最佳的跨浏览器兼容作为计算的z索引和偏移。然后,当你AJAX的更新对话框,不能在DOM原来的父元素,因此只需一个新的被添加到DOM(然后再次获得搬迁到身体的目的,等等)发现现有的对话。

This is not allowed. The technical reason is, the HTML DOM element representing the dialog is by JavaScript relocated to the very end of <body> in order to ensure best cross browser compatibility as to calculating the z-index and offset. Then, when you ajax-update the dialog, the existing dialog couldn't be found in its original parent element in the DOM, so simply a new one is added to DOM (which then get relocated to end of body again, etc).

您真的需要调整你的模板,所以你最终落得像

You really need to restructure your templates so you ultimately end up like

<p:dialog id="commissionDetail">
    ...
</p:dialog>
<p:dialog id="issueDetail">
    ...
</p:dialog>