2011-02-03 98 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