0

I would like to refresh a part of my template using jquery. In my template.xhtml , i have this: `

<h:body>
    <div id="topbar">
        <ui:include src="topbar.xhtml" />
    </div>
    <div id="layoutmenu">
        <ui:include src="layoutmenu.xhtml" />
    </div>

`

In my page.xhtml :

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:pe="http://primefaces.org/ui/extensions"
   xmlns:sec="http://www.springframework.org/security/tags"
   xmlns:f="http://java.sun.com/jsf/core"
   template="/WEB-INF/template.xhtml">

I try to refresh the topbar but when i use this code all the page is refreshed and my menu doesn't work anymore (click event ...). I use this code to load the same div in my controller because i want to refresh my topbar then only reinclude the same file :

RequestContext.getCurrentInstance().execute("$('#topbar').load('#topbar');");

i didn't find a solution in all the documentation i read.The solutions aren't appropiate to my case because i dont want to change the included file but to refresh the same one which is a part of my template but everything is refreshed

I don't want to use a commandlink or commandbutton i juste want to reload the topbar div in my template.xhtml.This is for my currentuser notification. if someone can help me it will be very nice :)

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • No idea why you try it this way but you'd better take a look at https://stackoverflow.com/questions/7108668/how-to-ajax-refresh-dynamic-include-content-by-navigation-menu-jsf-spa. You can use this same approach to refresh instead of loading something new – Kukeltje Jan 30 '18 at 12:17
  • 1
    "I don't want to use a commandlink or commandbutton". Why not? This smells like an XY problem... – Jasper de Vries Jan 30 '18 at 12:22
  • When i try to directly load the page topbar.xhtml , it search it in the path of the current page and returns an error;that's why i tried to load the div. – user2365813 Jan 30 '18 at 12:49
  • I m going to try this approach and hope it ll resolve my problem. It 's the same page i hope it ll refresh it because i ve already read this post and it contain 3different pages then the problem is easy and is not the same . In the controller when i ll change the page by the same value i don't know what will be the result.I was thinking about cache buster but i don't want to complicate the problem. Thank you for your fast answear and your help – user2365813 Jan 30 '18 at 12:54

0 Answers0