I like the use of ui:include better than inserting h:panelBoxes like here:
<ui:fragment rendered="#{myBean.yourCondition()}"> <ui:include src="viewA.xhtml"/> </ui:fragment> <ui:fragment rendered="#{not myBean.yourCondition()}"> <ui:include src="viewB.xhtml"/> </ui:fragment> Advantage: Tag handlers do not represent components and never become a part of the component tree once the view has been built. It won't interefere with your CSS - the h:panelBox, in contrary, inserts a div or span.
... Another approach would be c:choose, which works but can cause render phases issues.
<c:choose> <c:when test="#{myBean.yourCondition()}"> <ui:include src="viewA.xhtml"/> </c:when> <c:otherwise> <ui:include src="viewB.xhtml"/> </c:otherwise> </c:choose> Caution: When fiddling with tag handlers (like any c:xxx), be sure to know the difference between UI Components and Tag Handlersdifference between UI Components and Tag Handlers. Namely that UI Components and Tag Handlers are renderend in different phases. That implies that you cannot create a variable in a composite component and use it in a nested tag handler. c:choose and ui:include are both tag handlers, so normally it's not a problem. Read the link, it's a very short example and very insightful.