I've now tried several "solutions" but no one worked for me. First i introduce the problem.
I have a strictly html 5 template which i use fo my project so it is not possible to change here anything. The Framework used is JSF 2.0
The Problem:
I have a xhtml template like this:
template.xhtml
<h:head>
<title>SOME MAIN TITLE | <ui:insert name="title" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name='viewport' content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="much css files here" rel="stylesheet" type="text/css" />
<ui:insert name="stylesheet" />
<ui:insert name="script" />
</h:head>
<h:body styleClass="skin-blue">
<ui:insert name="header">
<ui:include src="header.xhtml" />
</ui:insert>
<ui:insert name="lsidebar">
<ui:include src="leftsidebar.xhtml" />
</ui:insert>
<ui:insert name="content" />
<ui:insert name="footer">
<ui:include src="footer.xhtml" />
</ui:insert>
</h:body>
and a header.xhtml
<body>
<ui:composition>
<header content here>
</ui:composition>
</body>
and so on and a leftsidebar.xhtml where are links to the pages
<body>
<ui:composition>
<!-- This is the collapse menu item with subitems -->
<li class="treeview">
<h:link fragment="#">
<h:panelGroup id="management">
<h:outputText value="#{msg['sidebar.navLink.management']}" />
</h:panelGroup>
</h:link>
<ul class="treeview-menu">
<!-- This is one menu subitem -->
<li>
<h:link outcome="/pages/subfolder/content1.xhtml">
<h:outputText value="Click me to navigate to 1" />
</h:link>
</li>
<!-- This is another menu subitem -->
<li>
<h:link outcome="/pages/subfolder/content2.xhtml">
<h:outputText value="Click me to navigate to 2" />
</h:link>
</li>
</ul>
</li>
</ui:composition>
</body>
and last but not least a content page with:
content.xhtml
<h:body>
<ui:composition>
<ui:define name="title">
<h:outputText value="#{msg['content.pageTitle']}" />
</ui:define>
<ui:define name="stylesheet"/>
<h:outputStylesheet name="some.css" library="css" />
</ui:define>
<ui:define name="script"/>
<h:outputScript name="some.js" library="js" />
</ui:define>
<ui:define name="content">
<Some content here>
</ui:define>
</ui:composition>
</h:body>
Now I want to navigate from a link or commandLink or something else what renders to an a href (without any other jsf added tags) from the leftsidebar.xhtml to load the templated content.xhtml with only rendering this content.xhtml maybe by
<f:ajax render=":some_id_in_the_content_page">
The reason why to do that is that the links in the left menu are inside another list ul element which collapse down and shows these sublinks. But when the page is loaded the menu is closed again.
Before you come across with all the links i have already visited: I've tried the commandlink and ajax solution from here: how-to-ajax-refresh-the-main-content-part-by-navigation-menu
and the solution of balusC from here: tricky include
and also the extended solution of BalusC from here: how-to-do-partial-page-rendering-center-content-with-jsf2-templating-via-ajax
To short this. Solution 1 did not work
<li>
<h:commandLink action="/pages/subfolder/content1.xhtml">
<f:ajax render="contentOnly">
<h:outputText value="Click me to navigate to 1" />
</h:commandLink>
</li>
<li>
<h:commandLink action="/pages/subfolder/content2.xhtml">
<f:ajax render="contentOnly">
<h:outputText value="Click me to navigate to 2" />
</commandLink>
</li>
and also with a form outside and put the ajax tag to the form did not work.
Solution 2 is in fact no alternative for me, caused by security, js etc issues
<li>
<h:commandLink action="#{navBean.setPage('content1.xhtml')">
<f:ajax render="contentOnly">
<h:outputText value="Click me to navigate to 1" />
</h:commandLink>
</li>
<li>
<h:commandLink action="#{navBean.setPage('content2.xhtml')">
<f:ajax render="contentOnly">
<h:outputText value="Click me to navigate to 2" />
</commandLink>
</li>
with the template
<h:body styleClass="skin-blue">
<ui:insert name="header">
<ui:include src="header.xhtml" />
</ui:insert>
<ui:insert name="lsidebar">
<ui:include src="leftsidebar.xhtml" />
</ui:insert>
<ui:insert name="content">
<h:panelGroup rendered="#{navBean.page == 'content1'}">
<ui:include src="content1.xhtml" />
</h:panelGroup">
<h:panelGroup rendered="#{navBean.page == 'content2'}">
<ui:include src="content1.xhtml" />
</h:panelGroup>
</ui:insert>
<ui:insert name="footer">
<ui:include src="footer.xhtml" />
</ui:insert>
</h:body>
The last solution wants me also to put my template files outside the WEB-INF folder to access them directly from the url. That might not be a solution to me. But I read about a post where a user had the same problem and found a solution by himself. But he did not post the solution - just a border of a solution and I wanted to ask you whether you know what he has done here: a sounds good half solution or if anyone has an idea of what i can do else.
Thank you very much