开发者

How to show a panel or any other GUI object in OpenFaces 3.00 Datatable upon row selection?

I am using OpenFaces 3.0.0 with JSF 2.0, Fadelets, Managed Beans and Tomcat server. I have a openface datatable and now on the basis of row selection, I want to show some different data (other than the data displayed in the datatable) in a folding panel or any other suitable openfaces layout. I have tag called singleRowSelection in the openfaces table. Could you please let me know to configure openfaces datat开发者_StackOverflow中文版able so that on row selection I can show data on a panel below the datatable? I need to show/hide data based on row selection Please help


I'd take a look at o:singleRowSelection http://openfaces.org/documentation/tagReference/o/singleRowSelection.html

Here is a super basic example:

<!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();
    }



}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜