如何在rich:panel中插入一行HtmlDataTable来获得一个事件选择



我需要改变一个在门户中太慢的例程。这是我的.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>

首先,我要删除这些内联样式。

第二,您可以使用标记来呈现表(单击'view source')。使用它,您应该能够轻松地将侦听器添加到行而不是单元格或任何您想要的。

希望能有所帮助。

相关内容

  • 没有找到相关文章

最新更新