Why do I need to nest a component with rendered=“#{some}” in another component when I want to ajax-update it?

前端 未结 1 402
北荒
北荒 2020-11-22 01:10

So I\'ve found a few answers close to this, and I\'ve found enough to fix the problem I had. But even so, I\'m curious as to understand the workings around this. Let me il

相关标签:
1条回答
  • 2020-11-22 01:26

    Ajax updating is performed by JavaScript language in the client side. All which JavaScript has access to is the HTML DOM tree. If JSF does not render any component to the HTML output, then there's nothing in the HTML DOM tree which can be obtained by JavaScript upon Ajax update. JavaScript cannot get the desired element by its ID.

    It will only work if you wrap the conditionally JSF-rendered component in another component which is always rendered to the HTML output and thus always present in the HTML DOM tree and thus always obtainable by JavaScript. Reference that wrapper component instead during ajax render/update.

    See also:

    • Communication in JSF2 - Ajax rendering of content which is by itself conditionally rendered
    0 讨论(0)
提交回复
热议问题