有条件地包括JSF viewParam

时间:2015-10-30 13:59:47

标签: jsf jsf-2 jstl

我正在尝试在JSTL <f:viewParam>的JSF页面中有条件地包含<f:viewAction><c:if>标记为我不想在每个单独手动指定viewParams JSF页面。不幸的是它没有用......

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>

任何人都知道我做错了什么或知道如何实现这种行为的不同方式?

我也尝试了<h:panelGroup rendered="#{detailsId eq 'true'}">但没有成功。

0 个答案:

没有答案