2011-02-03 53 views
1

我想知道是否存在某種方法將某個webbean獲得的列表傳遞給JSF 2.0中的組件? webbean getList應該返回一個客戶端列表到組件。例如:將bean方法傳遞給複合

組件:

<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:composite="http://java.sun.com/jsf/composite"> 
<head> 
    <title>This will not be present in rendered output</title> 
</head> 
<body> 

<composite:interface> 
    <composite:attribute name="list" required="true"/> 
</composite:interface> 

<composite:implementation> 
    <h:dataTable id="clients" value="#{list}" var="client"> 
    <h:column> 
     <f:facet name="header"> 
     <h:outputText value="Client"></h:outputText> 
     </f:facet> 
     <h:outputText value="#{client.username}"></h:outputText> 
    </h:column> 
    .... 
    </h:dataTable> 
</composite:implementation> 
</body> 
</html> 

的userpage應通過它返回一個列表對象的webBean的位置。

.... 
<components:list-client list="webBean.getList"/> 
.... 

你能舉個例子嗎?

致以問候

回答

2

只有兩件事情需要改變。

訪問值應該發生 「像往常一樣」:

<components:list-client list="#{webBean.list}" /> 

的實施需要通過#{cc.attrs.attributeName}訪問屬性:

<h:dataTable id="clients" value="#{cc.attrs.list}" var="client"> 

更多用法示例,檢查tag documentation