2012-06-29 18 views
3

我有一個XHTML頁面,我有使用f一個outputLink的:在目標頁面PARAMF:PARAM和f:viewparam二傳手不叫

<h:outputLink value="#{formService.getStartFormData(v_process.id).formKey}"> Start <f:param name="processDefinitionKey" value="#{v_process.key}"></f:param> </h:outputLink>

,我有鑑於PARAM

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

    </f:metadata> 

我bean是

@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爲空,二傳不叫 , 怎麼了 ? 有沒有在web.xml或faces-config.xml中添加任何配置? 在同一個項目中,我與primefaces和春季安全

工作,這是整個頁面

<?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">  

感謝您的回覆,請這並不工作

+0

我認爲你缺少的setter此方法:'公開名單 getProcessDefinitionList()'。你可以試試嗎? –

+0

@cacho:在這個特殊情況下,爲什麼要爲這個屬性設置一個setter? – BalusC

+0

@BalusC:因爲我認爲代碼代表一個JSF Java Bean,因此它需要爲每個屬性設置一個getter/setter,對吧? –

回答

2

嘗試更改命名空間像posted already here。在我的情況(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的工作。

如果有人有一個想法,爲什麼這是這樣,我會很高興在這裏。第二個變體應該是我正確的一個,我是read here

1

這是一個JEE7錯誤。 https://java.net/jira/browse/JAVASERVERFACES-2868 作爲工作作爲一種解決方法,我把:

<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> 
+1

只需升級JSF impl。 – BalusC

+0

@BalusC JSF 2.2.1似乎無法通過'updatetool'獲得。 – tbodt