0

我将 OpenFaces 3.0.0 与 JSF 2.0、Fadelets、Managed Beans 和 Tomcat 服务器一起使用。我有一个 openface 数据表,现在基于行选择,我想在折叠面板或任何其他合适的 openfaces 布局中显示一些不同的数据(数据表中显示的数据除外)。我在 openfaces 表中有一个名为 singleRowSelection 的标签。您能否让我知道配置 openfaces 数据表,以便在行选择时我可以在数据表下方的面板上显示数据?我需要根据行选择显示/隐藏数据请帮助

4

1 回答 1

0

我会看看 o:singleRowSelection http://openfaces.org/documentation/tagReference/o/singleRowSelection.html

这是一个超级基本的例子:

<!DOCTYPE html>

<h:head>
    <title>Example Row Change DataTable</title>
</h:head>

<h:body>

    <h:form prependId="false" id="sampleForm">
        <o:dataTable id="sampleDataTable" value="#{testOpenFacesBean.testStrings}" var="name">                
            <o:singleRowSelection render="somePanel" action="#{testOpenFacesBean.randomize}"/>

        <o:column>
            <h:outputText value="#{name}" />
        </o:column>

    </o:dataTable>
    </h:form>

    <h:panelGroup layout="block" id="somePanel">
        <h:outputText value="#{testOpenFacesBean.randomName}" />
    </h:panelGroup>
</h:body>

package com.test;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "testOpenFacesBean")
@RequestScoped
public class TestOpenfacesBean {

    /**
     * A collection of Strings for testing Openfaces singleRowSelection
     */
    private List<String> testStrings;

    public List<String> getTestStrings() { return this.testStrings; }
    public void setTestStrings(List<String> testStrings) { this.testStrings = testStrings; }

    /**
     * A random name so you can see the data updating
     */
    private String randomString;

    public String getRandomName() { return this.randomString; }
    public void setRandomName(String randomName) { this.randomString = randomName; }

    /**
     * Constructor
     */
    public TestOpenfacesBean() {
    this.testStrings = new ArrayList<String>();
    this.testStrings.add("Beth");
    this.testStrings.add("Jane");
    this.testStrings.add("Doug");
    }

    public void randomize() {
    this.randomString = new BigInteger(62, new SecureRandom()).toString();
    }



}
于 2011-03-01T15:15:56.000 回答