Partial page update when navigating (PrimeFaces ajax)

后端 未结 1 979
情话喂你
情话喂你 2021-01-03 17:34

I have done a basic JSF app, using facelets templates. My template is as follows:



        
相关标签:
1条回答
  • 2021-01-03 18:10

    You can reload content by ajax, but URL will stay the same. If you can afford that, update the code as follows:

    In template.xhtml, replace

    <div id="content">
    

    by

    <h:panelGroup id="content" layout="block">
    

    And in somepage.xhtml, replace

    <p:commandButton value="Create entry" action="create" />
    

    by

    <p:commandButton value="Create entry" action="create" update=":content" />
    

    Finally get rid of the <redirect /> (actually, prefer to get rid of all navigation cases since they make the faces-config.xml file bloated). A redirect can by the way also be specified in the outcome as in action="create?faces-redirect=true".

    This does only not update the <title>. You could however do that with a simple JavaScript line.

    0 讨论(0)
提交回复
热议问题