I have in my .xhtml
form an element into which I am appending html elements through javascript
.
When I trigger an ajax commandButton
, these appended elements are lost.
I have tried to exclude this element from my ajax update
and make my submit partial
(following this practice How to exclude child component in ajax update of a parent component?) , but in vain, the newly added elements are lost after the update takes place.
Is there any way to avoid this? Thanks in advance :)
Code sample:
<h:form id="formID">
<p:commandButton
value="ajax_button" partialSubmit="true"
update="@(#divOfElement :not(.notupdate))"
ajax="true">
<f:actionListener binding="#{myBean.myAction()}"/>
</p:commandButton>
</h:form>
<p:outputPanel id="divOfElement">
<!-- other things i want to be updated-->
<p:outputPanel id="panel_not_to_update"styleClass="notupdate">
<!-- this div is filled with other elements from javascript code which will be destroyed when the ajax update takes place -->
</p:outputPanel>
</p:outputPanel>
Here, I want divOfElement
to be updated through the command button in the ajax call, but exclude the div with id panel_not_to_update
so it's child elements added through javascript code will not be lost.
I am using JSF 2.2 and Primefaces 7.0.