Updating p: commandButton does not work in ui: include

I want to refresh part of the PPR page. This is the part of the page I want to refresh:

 <h:panelGroup id="aggiungiAuto"
                  rendered="#{!autoBean.operazioneOk}">
        <ui:include src="../component/aggiungi_auto.xhtml"/>
 </h:panelGroup>

While this commandButton is present in aggiungi_auto.xhtml

 <p:commandButton value="Submit"
                  update="growl aggiungiAuto aggiungiFoto"
                  actionListener="#{autoBean.insert}"/>

Any idea?

+4
source share
2 answers

JS / Ajax runs on the client side, not the server side. JSF runs on the server side, not the client side. When you tell JSF not to display the component in HTML, there will be nothing on the client side, so JS / Ajax will not be able to find the HTML element to update / 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>

, <span id="aggiuniAuto"> , JS/Ajax HTML, JSF.

+7

PrimeFaces ( ), .

, ui:include , ui:include . - PrimeFaces ; , "" , ..


? "[O] , [;], , ". ui:include . (, p:commandButton ):

  • , update process JSF, HTML.
  • update , ( ).
  • styleClass (, PF ID @this:@parent), PF jQuery, : @(.fieldset-class).
  • process . ( , ...) process="@this" , , .
  • , immediate="true".
  • ( "", , - ui:include recursion), process="@this", immediate="true" update="@none", oncomplete="remoteCommandName();" p:remoteCommand , immediate process update .
  • ( , , - , ui:include)... h:panelGroup c:forEach up PrimeFaces remoteCommand , .
  • ( )... :
    • p:commandButton(s): oncomplete="$('.FixButtonSC').click();"
    • p:fieldset FieldsetSC:
          <!-- Fix (hidden) button. -->
          <p:commandButton id="FixButton" styleClass="FixButtonSC"
            process="@this" update="@(.FieldsetSC)" style="display: none;" />

, ...

0

Source: https://habr.com/ru/post/1782336/


All Articles