Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java includeViewParams=true不';不能在模板页面中工作_Java_Jsf 2_Facelets_Post Redirect Get - Fatal编程技术网

Java includeViewParams=true不';不能在模板页面中工作

Java includeViewParams=true不';不能在模板页面中工作,java,jsf-2,facelets,post-redirect-get,Java,Jsf 2,Facelets,Post Redirect Get,考虑以下模板: 使用它的此页面(/pages/test.xhtml): 页面的bean: @Named @请求范围 公共类PageBean实现了可序列化 { 公共字符串getFoo() { 返回foo; } 公共void setFoo(字符串foo) { this.foo=foo; } 私人字符串foo; } 这个豆子: @Named @适用范围 公共类Util实现可序列化 { 公共字符串currentPageAction() { 返回FacesContext.getCurrentIn

考虑以下模板:


使用它的此页面(/pages/test.xhtml):


页面的bean:

@Named
@请求范围
公共类PageBean实现了可序列化
{
公共字符串getFoo()
{
返回foo;
}
公共void setFoo(字符串foo)
{
this.foo=foo;
}
私人字符串foo;
}
这个豆子:

@Named
@适用范围
公共类Util实现可序列化
{
公共字符串currentPageAction()
{
返回FacesContext.getCurrentInstance().getViewRoot().getViewId()+
“?面重定向=真&includeDeviceParams=真”;
}
}
当我加载
http://localhost:8080/faces/pages/test.xhtml?foo=bar
在浏览器中单击
,URL将更改为
http://localhost:8080/faces/pages/test.xhtml
。也就是说,视图参数不包括在重定向URL中

但是,当我重构页面使其不使用模板时,它的行为与预期的一样。也就是说,视图参数包含在重定向URL中


我知道
放在facelets模板中不起作用,也不应该起作用。这不是这里发生的事情,所以这是一个不同的问题。规范中没有任何规定不能这样做。事实上,据我所知,没有其他方法可以使用视图参数创建基于模板的页面。

我有一个类似的问题,我解决了这个问题,因为定义“元数据”集元数据在f:view之后立即被注入

<ui:define name="metadata">
   <f:metadata>
           <f:viewParam name="id" .../>
   </f:metadata>
    </ui:define>


template.xhtml

        <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
       xml:lang="en" lang="en">
         <f:view>
    <ui:insert name="metadata"/>
       <div id="container">
    <ui:insert name="content"/>
            </div>
          </f:view>


在中添加了注释。我希望有一天能解决这个问题。我投了赞成票。我对
也有类似的问题,其中包含属性
includeViewParams=“true”
不会产生与使用
条目重复视图参数相同的行为。使用
includeViewParams
时,link/GET请求中的参数值来自
output
页面的支持bean,而不是我认为应该来自提供给当前页面的视图参数。P91意味着这两种方法应该是可互换的。