【问题标题】:Passing bean method to a composite将 bean 方法传递给组合
【发布时间】:2011-02-03 21:18:38
【问题描述】:

我想知道是否有某种方法可以将某个 webbean 获取的列表传递给 JSF 2.0 中的组件? webbean getList 应将客户端列表返回给组件。例如:

组件:

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

用户页面应传递返回 List 对象的 webBean 的位置。

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

你能举个例子吗?

最好的问候

【问题讨论】:

    标签: jsf jsf-2 composite-component


    【解决方案1】:

    只有两件事需要改变。

    访问值应该“像往常一样”:

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

    实现需要通过#{cc.attrs.attributeName}访问属性:

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

    更多使用示例,请查看tag documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-11
      • 2016-01-22
      • 2018-11-16
      • 2013-02-26
      • 2011-07-24
      • 2010-10-23
      • 2012-11-13
      • 1970-01-01
      相关资源
      最近更新 更多