gpt4 book ai didi

JSF 重新渲染复合组件 : insertChildren problems

转载 作者:行者123 更新时间:2023-12-02 08:45:22 25 4
gpt4 key购买 nike

<分区>

我正在用 JSF 制作我的第一个复合组件,但我被一个行为异常的重新渲染难住了。这是组件实现(它应该是一个弹出窗口):

    <composite:implementation>
<h:outputScript name="nb-popup.js" library="js"/>
<h:outputStylesheet name="nb-popup.compiled.css" library="style"/>
<div id="#{cc.clientId}_container" class="nb_popup_container">
<div style="width:#{cc.attrs.width};height:#{cc.attrs.height};" id="#{cc.clientId}" class="nb_popup">
<div id="#{cc.clientId}_header" class="nb_popup_header">
<span class="nb_popup_header_content">
<composite:renderFacet name="header"/>
</span>
<span class="nb_popup_header_controls">
<composite:renderFacet name="controls"/>
</span>
</div>
<div id="#{cc.clientId}_content" class="nb_popup_content">
<composite:insertChildren/>
</div>
</div>
</div>
<script>popup('#{cc.clientId}');</script>
</composite:implementation>

例如假设我们有:

<nb:popup id="extract">
test
</nb:popup>

生成的 HTML 没问题:

    <div id="extract_container" class="nb_popup_container">
<div style="width:auto;height:auto;" id="extract" class="nb_popup">
<div id="extract_header" class="nb_popup_header">
<span class="nb_popup_header_content">
</span>
<span class="nb_popup_header_controls">
</span>
</div>
<div id="extract_content" class="nb_popup_content">
test

</div>
</div>
</div>

现在假设我有一个按钮:

    <h:commandLink value="reload">
<f:ajax render=":extract"/>
</h:commandLink>

按下后,我得到以下部分响应,其中实际内容显然不在应有的位置:

    <div id="extract_container" class="nb_popup_container">
<div style="width:auto;height:auto;" id="extract" class="nb_popup">
<div id="extract_header" class="nb_popup_header">
<span class="nb_popup_header_content">
</span>
<span class="nb_popup_header_controls">
</span>
</div>
<div id="extract_content" class="nb_popup_content">
</div>
</div>
</div>
<script>popup('extract');</script>
test
]]>

现在假设我将 insertChildren 移动到标题:

            <div id="#{cc.clientId}_header" class="nb_popup_header">
<span class="nb_popup_header_content">
<composite:renderFacet name="header"/>
<composite:insertChildren/>
</span>
<span class="nb_popup_header_controls">
<composite:renderFacet name="controls"/>
</span>
</div>

初始加载再次正常:

            <div id="extract_header" class="nb_popup_header">
<span class="nb_popup_header_content">
test

</span>
<span class="nb_popup_header_controls">
</span>
</div>

但在重新加载时,内容会再次移动:

            <div id="extract_header" class="nb_popup_header">
<span class="nb_popup_header_content">
</span>
<span class="nb_popup_header_controls">
test

</span>
</div>

知道是什么导致了在 ajax 重新渲染后看似随机放置 insertChildren 吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com