0

OpenFaces3.0.0をJSF2.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 に答える