Reputation: 1831
I am creating a documentation page for my JSF web app and would like to include parts of the documentation as in a p:tooltip in the actual web page. Is there a way to only include certain divs in a ui:include? If this is the code of my documentation page:
<h:body>
<div id="thisOne">
<h:outputText value="should show"/>
</div>
<div id="notthis" >
<h:outputText value="This shouldn't show"/>
</div>
</h:body>
How would I do a ui:include which only includes the div with the id: "thisOne"?
Upvotes: 0
Views: 1452
Reputation:
How would I do a ui:include which only includes the div with the id: "thisOne"?
You would create a page wrapped in the templating tag ui:composition
, then use the tag ui:include
to include it in the main page.
Like this (with files in the same folder) :
thisOne.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<div id="thisOne">
<h:outputText value="should show"/>
</div>
</ui:composition>
main.xhtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<h:body>
<h:form >
<ui:include src="thisOne.xhtml" />
</h:form>
<div id="notthis" >
<h:outputText value="This shouldn't show"/>
</div>
</h:body>
</html>
Upvotes: 2