gpt4 book ai didi

jsf-2 - JSF 2/素面 : p:panel not rendered with ajax?

转载 作者:行者123 更新时间:2023-12-03 23:05:01 25 4
gpt4 key购买 nike

我不确定这种行为是否正常。
我希望我的 panel只有在点击触发 ajax 的按钮后才会呈现要求。

不使用 Ajax 工作正常:

  • p:panel id="myPanel" rendered="#{myBean.flag}"
  • p:commandButton ajax="false" action="#{myBean.setFlagToTrue}"
  • 点击按钮前,myPanel不显示(flag = false)
  • 单击按钮,将标志设置为 true,并且 myPanel 呈现良好

  • 使用 ajax 失败:
  • p:panel id="myPanel" rendered="#{myBean.flag}"
  • p:commandButton ajax="true" action="#{myBean.setFlagToTrue}" update="myPanel"
  • 点击按钮前,myPanel不显示(flag = false)
  • 单击按钮,将标志设置为 true(如我的日志文件所示),以及 myPanel 未呈现

  • 我试过省略渲染属性,确实 ajax 工作正常。
    我可以通过查看面板内部反射(reflect)的变化来判断。

    最佳答案

    将带有条件渲染的面板放在另一个面板中并更新它。像这样:

    <p:outputPanel id="toUpdate">
    <p:panel id="myPanel" rendered="#{myBean.flag}">
    </p:panel>
    <p:outputPanel>

    <p:commandButton update="toUpdate"/>

    这是一个已知的问题。如果元素不存在于 DOM 中,则无法更新该元素。

    关于jsf-2 - JSF 2/素面 : p:panel not rendered with ajax?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4525671/

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