0

将视图参数添加到 a 时出现问题<h:link includeViewParams="true" />- 它们未添加到呈现的链接中。我正在使用 Mojarra 2.3.9。

  • 模板/WEB-INF/templates/main.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:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
  <!-- Some headers -->
</h:head>

<h:body>
    <f:view>
        <ui:insert name="metaContent" />
        <div class="container-fluid" id="mainContent">
            <ui:insert name="mainContent" />
        </div>
    </f:view>
</h:body>
</html> 
  • 在页面test.xhtml上使用的模板
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:o="http://omnifaces.org/ui"
    template="/WEB-INF/templates/main.xhtml">

    <ui:define name="metaContent">
        <f:metadata>
            <f:viewParam name="id" value="#{myBean.obj}" required="true">
                <f:validator validatorId="myIdVvalidator" />
                <f:converter converterId="myConverter" />
            </f:viewParam>
        </f:metadata>
    </ui:define>

    <ui:define name="mainContent">
        <!-- Simply reference current page -->
        <h:link outcome="test.xhtml" includeViewParams="true">
          My link
        </h:link>
    </ui:define>
</ui:composition>

更新

如果我删除以及和子元素的属性value,则链接将按预期呈现。为什么这会导致问题?豆是f:viewParamf:converterf:validatormyBean@RequestScoped

4

0 回答 0