Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:ajax update of ID that doesn't exists

I'm using PrimeFaces and I have a line:

<p:ajax update="toUpdate">

the problem is, that this ID not always exists on the page. ( 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)

How can I fix it?

Is it a well known issue?

Thanks!

like image 529
Dvir Avatar asked Oct 18 '25 06:10

Dvir


1 Answers

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. Instead, use a component (container) that your are sure that be rendered and present in the components tree.

like image 142
C.P.O Avatar answered Oct 21 '25 12:10

C.P.O



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!