【发布时间】:2012-07-01 04:27:21
【问题描述】:
我有一个 xhtml 页面,其中有一个带有 f:param 的输出链接
<h:outputLink value="#{formService.getStartFormData(v_process.id).formKey}">
Start
<f:param name="processDefinitionKey" value="#{v_process.key}"></f:param>
</h:outputLink>
在目标页面,我有视图参数
f:metadata>
<!-- bind the key of the process to be started -->
<f:viewParam name="processDefinitionKey" value="#{processList.processDefinitionKey}"/>
</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;
}
}
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">
谢谢你的回复,请这个没有用
【问题讨论】:
-
我认为您缺少此方法的设置器:
public List<ProcessDefinition> getProcessDefinitionList()。你可以试试吗? -
@cacho:为什么在这种特殊情况下需要该属性的设置器?
-
@BalusC:因为我认为代码代表一个 JSF Java Bean,因此,它需要为每个属性都有一个 getter/setter,对吗?
-
@cacho:不。只输出值不需要设置器。此外,如果缺少的二传手真的是原因,你会得到一个
PropertyNotWritableException,但这远不是这里的原因。 -
我已经编辑了我的问题,我的页面中有 f:metadata,而不是模板页面 .config 文件或 spring security,primefaces 或 jsf 版本是否会产生影响?感谢您的回复,如果您有任何想法,请帮忙
标签: jsf el viewparams