I want to update a part of a page by PPR. This is the part of page that i want to update:
<h:panelGroup id="aggiungiAuto"
rendered="#{!autoBean.operazioneOk}">
<ui:include src="../component/aggiungi_auto.xhtml"/>
</h:panelGroup>
While this is the commandButton present in aggiungi_auto.xhtml
<p:commandButton value="Submit"
update="growl aggiungiAuto aggiungiFoto"
actionListener="#{autoBean.insert}"/>
Any Idea?
JS/Ajax works on the client side, not on the server side. JSF works on the server side, not on the client side. When you instruct JSF to not render the component to HTML, then nothing will be present in the client side, so JS/Ajax will be unable to locate the HTML element to refresh/update.
You need to wrap it in another <h:panelGroup>
.
<h:panelGroup id="aggiungiAuto">
<h:panelGroup rendered="#{!autoBean.operazioneOk}">
<ui:include src="../component/aggiungi_auto.xhtml"/>
</h:panelGroup>
</h:panelGroup>
This way the <span id="aggiuniAuto">
is always present in the client side, so JS/Ajax will be able to update it with the new HTML data generated by JSF.
So I was having this kind of a problem with PrimeFaces (the above answer not being sufficient this time), and I also discovered a solution.
Part of the problem I think was that I was using ui:include
recursively. For whatever reason, PrimeFaces was irrationally causing UI components to be bound to the backend data out-of-sync; e.g., when an "Add" button was clicked, a new value would be created in the UI, but then the data for it would be ripped out of the values for the section below, etc...
The explanation? "[O]n a viewscoped bean, a hidden field is added to the form to hold post-back data[;] if that field is not included with the process, then the bean will lose context." This particular problem is prevalent with ui:include
recursion especially. Solution (all regarding the p:commandButton
or other actionable component):
update
and process
are pointing to a JSF component, not a regular HTML component.update
the next scope up if it breaks (goes out-of-sync with the binding).styleClass
's for update (not e.g. PF ID's or @this:@parent
kind of stuff), so that jQuery is utilized instead of PF, e.g.: @(.fieldset-class)
.process
whatever scope is being updated. (This is needed for the post-back data so that the Bean keeps its context for the update...) process="@this"
is not needed here, provided that the button is contained by the process value component.immediate="true"
.ui:include
recursion), set process="@this"
, immediate="true"
, and update="@none"
, and then oncomplete="remoteCommandName();"
, and have a p:remoteCommand
instead with that name with the process
, immediate
, and update
mentioned in the above points.ui:include
recursion)... wrap a h:panelGroup
around the next c:forEach
up and then update the PrimeFaces ID of that in the button itself while keeping its remoteCommand
call afterwards, as specified above.p:commandButton(s)
: oncomplete="$('.FixButtonSC').click();"
p:fieldset
with a style class of FieldsetSC: <!-- Fix (hidden) button. -->
<p:commandButton id="FixButton" styleClass="FixButtonSC"
process="@this" update="@(.FieldsetSC)" style="display: none;" />
Hope that helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With