I'm trying to include <f:viewParam>
and <f:viewAction>
tags conditionally in my JSF pages with JSTLs <c:if>
as I don't want to manually specify the viewParams in every single JSF page. Unfortunately it is not working...
metadata_include.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<f:metadata>
<f:viewParam name="from" value="#{loginBean.from}" />
<c:if test="#{detailsId eq 'true'}">
<f:viewParam id="detailsid" name="detailsid" value="#{detailsBean.detailsId}" />
<f:viewAction action="#{detailsBean.onload}" />
</c:if>
</f:metadata>
</ui:composition>
details.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<ui:include src="/WEB-INF/metadata_include.xhtml">
<ui:param name="detailsId" value="true" />
</ui:include>
</h:head>
<h:body>
</h:body>
</html>
Anybody knows what I'm doing wrong or knows a different way how to achieve this kind of behavior?
I also tried it with <h:panelGroup rendered="#{detailsId eq 'true'}">
without success.