Jsf 未调用f:param和f:viewparam设置器

Jsf 未调用f:param和f:viewparam设置器,jsf,el,viewparams,Jsf,El,Viewparams,我有一个xhtml页面,其中有一个带有f:param的输出链接 开始 在目标页面中,我有view参数 f:metadata> <!-- bind the key of the process to be started --> <f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}"/> </f:met

我有一个xhtml页面,其中有一个带有f:param的输出链接


开始

在目标页面中,我有view参数

f:metadata>
        <!-- bind the key of the process to be started -->
        <f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}"/> 

    </f:metadata>
f:metadata>
我的豆子是

@Named
@RequestScoped
public class ProcessList{

private String processDefinitionKey ; 

@Inject
private RepositoryService repositoryService;

@Produces
@Named("processDefinitionList")
public List<ProcessDefinition> getProcessDefinitionList() {
return repositoryService.createProcessDefinitionQuery()
        .list();
}

public void setProcessDefinitionKey(String processDefinitionKey1) {
  System.out.println("setProcessDefinitionKey "+processDefinitionKey1);
this.processDefinitionKey = processDefinitionKey1;
}

public String getProcessDefinitionKey() {
  System.out.println("getProcessDefinitionKey______ "+processDefinitionKey);
return processDefinitionKey;
}


}
@Named
@请求范围
公共类进程列表{
私有字符串处理定义密钥;
@注入
私人寄存服务寄存服务;
@产生
@命名(“processDefinitionList”)
公共列表getProcessDefinitionList(){
return repositoryService.createProcessDefinitionQuery()
.list();
}
public void setProcessDefinitionKey(字符串processDefinitionKey1){
System.out.println(“setProcessDefinitionKey”+processDefinitionKey1);
this.processDefinitionKey=processDefinitionKey1;
}
公共字符串getProcessDefinitionKey(){
System.out.println(“getProcessDefinitionKey+processDefinitionKey);
返回processDefinitionKey;
}
}
processDefinitionKey为null,未调用setter,怎么了? web.xml或faces-config.xml中是否有要添加的配置? 在同一个项目中,我与primefaces和spring security合作

这是整页

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/template.xhtml">

<ui:define name="metadata">
    <f:metadata>
        <!-- bind the key of the process to be started -->
        <f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}" />
    </f:metadata>
</ui:define>

<ui:define name="content">      


感谢您的回复,请尝试更改名称空间,如。在我的案例(glassfish 4.0)和案例链接中,它必须

xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
但是试试看

xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
这对我来说对Tomcat很有效

如果有人知道为什么会这样,我很乐意在这里。第二个变体应该是正确的,它是一个JEE7 bug。 作为一项工作,我提出:

<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:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:oldf="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/template.xhtml">
<oldf:metadata>
    <oldf:viewAction action="#{chooseRoleBean.init()}" />
</oldf:metadata>


我认为您缺少此方法的setter:
public List getProcessDefinitionList()
。你能试试吗?@cacho:为什么在这种特殊情况下该属性需要setter?@BalusC:因为我认为代码代表一个JSF Java Bean,因此,每个属性都需要一个getter/setter,对吗?@cacho:不。setter对于仅输出的值不是必需的。此外,如果丢失的setter是真正的原因,您可能会得到一个
PropertyNotWritableException
,但这远远不是原因。我编辑了我的问题,a在我的页面中有f:元数据,而不是在模板页面中。配置文件或spring security、primefaces或jsf版本是否会产生影响?感谢您的回复,如果您有一个想法,请帮助升级JSF impl。@BalusC JSF 2.2.1似乎无法通过
updatetool
获得。