如何在.xhml中的rich:panel中插入一行HtmlDataTable进行事件选择

时间:2013-04-15 12:54:37

标签: jsf richfaces

我需要更改门户中速度太慢的例程。这是我的.xhtml文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jstl/core">
    <ui:composition>
    <a4j:outputPanel id="pending">
        <rich:panel

        style="border:none;background:transparent; width:100%; height:100%; padding:0px; margin:0px;"
        rendered="#{dataTableBean.noItemFound}" id="noItemFoundPanel">
        <ui:include src="/templates/message/noItemFound.xhtml" />
    </rich:panel>

    <rich:panel
        style="border:none;background:transparent; width:100%; height:100%; padding:0px; margin:0px;"
        rendered="#{detectTreeSelectedNode.hasNoSelectedNode}" id="noItemSelectedPanel">
        <ui:include src="/templates/message/noItemSelected.xhtml" />
    </rich:panel>

    <rich:panel
        style="border:none;background:transparent; width:100%; height:50%; padding:0px; margin:0px;position:absolute;overflow:auto;"
        panelTable>
    </rich:panel>

    <a4j:outputPanel ajaxRendered="true" layout="block"
        style="border:none;background:transparent; position:absolute; bottom:0px; left:0px; right:0px; height:50%; overflow:auto;"
        id="panelDetail">
            <div id="panelDetailContents" style="width:100%; height:100%;"><f:verbatim>#{htmlContentService.content}</f:verbatim></div>
        </a4j:outputPanel>
    </a4j:outputPanel>
</ui:composition>
</html>

ID为panelTable的面板,在Java代码中以这样的方式接收org.richfaces.component.html.HtmlDataTable

public void updatePanelTable() {

    detectTreeSelectedNode.setHasNoSelectedNode(false);
    //mount the dynamic datatable
    HtmlDataTable dataTable = getHtmlDatatable();
    SelectedDocuments.clear();

    HTMLContentService service = SessionUtils.findBean("htmlContentService");
    service.updateContent(null);

    UIComponent panel = (UIComponent) FacesContext.getCurrentInstance().getViewRoot()
            .findComponent("principal:panelTable");

    panel.getChildren().clear();
    panel.getChildren().add(dataTable);

    panel = (UIComponent) FacesContext.getCurrentInstance().getViewRoot().findComponent("principal:panelDetail");
    panel.getChildren().clear();        
}

实际上这个HtmlDataTable上的每个单元都有一个监听器,在我看来错误的方式,我想得到事件行选择,没有监听器并调用处理行选择的方法,我该怎么办,进入.xhtml,小组的孩子并得到他的活动?

pom.xml仅供参考:

<dependency>
 <groupId>javax.faces</groupId>
 <artifactId>jsf-api</artifactId>
 <version>1.2_12</version>
 <scope>provided</scope>
</dependency>
<dependency>
 <groupId>javax.faces</groupId>
 <artifactId>jsf-impl</artifactId>
 <version>1.2_12</version>
 <scope>provided</scope>
</dependency>
<dependency>
 <groupId>com.sun.facelets</groupId>
 <artifactId>jsf-facelets</artifactId>
 <version>1.1.14</version>
 <scope>compile</scope>
</dependency>
<dependency>
 <groupId>org.richfaces.framework</groupId>
 <artifactId>richfaces-impl</artifactId>
 <version>3.3.1.GA</version>
</dependency>
<dependency>
 <groupId>org.richfaces.framework</groupId>
 <artifactId>richfaces-api</artifactId>
 <version>3.3.1.GA</version>
</dependency>
<dependency>
 <groupId>org.richfaces.ui</groupId>
 <artifactId>richfaces-ui</artifactId>
 <version>3.3.1.GA</version>
</dependency>

提前致谢。

1 个答案:

答案 0 :(得分:0)

首先,我会删除那些内联样式。

其次,您可以使用markup to render the table(点击“查看来源”)。使用它,您应该能够轻松地将侦听器添加到行而不是单元格或任何您想要的内容。

希望它有所帮助。