[英]p:ajax update of ID that doesn't exists
I'm using PrimeFaces and I have a line: 我正在使用PrimeFaces而且我有一条线:
<p:ajax update="toUpdate">
the problem is, that this ID not always exists on the page. 问题是,该ID并不总是存在于页面上。 ( the page is dynamic and sometimes it contains a part that have this specific ID and sometimes not) When it exists, it works great, but when the ID doesn't exist, the component crash - (probably it's some validation issue) (该页面是动态的,有时它包含具有此特定ID的部分,有时不包含)当它存在时,它工作得很好,但是当ID不存在时,组件崩溃 - (可能是一些验证问题)
How can I fix it? 我该如何解决?
Is it a well known issue? 这是一个众所周知的问题吗?
Thanks! 谢谢!
You need to provide an always rendered component to update, for example: 您需要提供一个总是呈现的组件来进行更新,例如:
<p:ajax update="toUpdate">
<h:panelGroup id="toUpdate">
<p:dataTable id="tableID" rendered="#{bean.someCondition>"...
</h:panelGroup>
So, if you have a component that can be o or not visible, do not use it for update, because can be out of components tree. 因此,如果您有一个可以是o或不可见的组件,请不要将它用于更新,因为它可能超出组件树。 Instead, use a component (container) that your are sure that be rendered and present in the components tree. 相反,使用您确定要呈现并存在于组件树中的组件(容器)。
Try this code 试试这个代码
<f:ajax render="toUpdate">
<h:outputText id="toUpdate">
<!-- do something -->
</h:outputText>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.