1

Let's say I have a xhtml file ( in a jsf app) containing a navigation menu and a content "frame":

<ul class="nav">
            <li class="nav-item"><a href="#">First</a></li>
            <li class="nav-item"><a href="#">Second</a></li>
            <li class="nav-item"><a href="#">Third</a></li>
</ul>
    </div>
    <div class="col-sm-10" id="content">

    </div>

I'd like to evaluate any options which would allow me to load a destination page in #content mantaining the nav list without reloading a full page with the nav list embedded every time, depending of which element of the menu is selected. I tried to put

<ui:insert>
            <ui:include src="destination.xhtml" />
        </ui:insert>

in #content, but that would always include the same page. Feel free to propose any solution involving facelets, primefaces and/or related tools. If a controller is needed, I'd prefer a js one than a java one. Thanks in advance, let me know if more details are needed.

M. F. C.
  • 41
  • 6
  • 2
    Like this?: https://stackoverflow.com/questions/7108668/how-to-ajax-refresh-dynamic-include-content-by-navigation-menu-jsf-spa – Kukeltje Jul 17 '18 at 10:23
  • @Kukeltje sort of, the main answer sure deserve to be examined, thanks for the quick reply. In regard of that thread I have few questions, like : is ManagedBean Spring stuff? How may I track the proper bean inside the project? Is there any way to avoid (only for now) the java part? Thanks again, – M. F. C. Jul 17 '18 at 11:39
  • No it is not related to spring, ` @ManagedBean` are the JSF managed beans, superseeded by `@Named`. 'Preventing' the java part is sort of possible but then it is not jsf, primefaces or xhtml related and it makes refreshing the page hard with staying on the right page, so I would not focus on that, it is either a premature or even a non-optimization. – Kukeltje Jul 17 '18 at 12:13
  • @Kukeltje, thanks, that was helpful. May I go a bit further? What if I load a standard template in #content, regardless of the item I choose from te menu, and the template have a #content by himself where it must load different pages (based on the choosen item from the menu)? How do I pass the pageName information from the menu page to the template? – M. F. C. Jul 17 '18 at 12:36
  • New questions are better asked in new questions. So others can find out their existence based on the title. But the (sub) pages are part of the whole page and can access any bean. But if you want to pass it in a more generic way, you can pass parameters to the `ui:include`... Several Q/A on this in stackoverflow – Kukeltje Jul 17 '18 at 12:44
  • Possible duplicate of [How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)](https://stackoverflow.com/questions/7108668/how-to-ajax-refresh-dynamic-include-content-by-navigation-menu-jsf-spa) – Kukeltje Jul 17 '18 at 12:45
  • Fine, I'll experiment a bit and eventually open a new question about this new topic. Anyway, thanks a lot. – M. F. C. Jul 17 '18 at 12:59

0 Answers0