<f:ajax>侦听器无法在嵌套<p:overlaypanel> </p:overlaypanel> </f:ajax>中工作

时间:2014-07-27 17:30:40

标签: jsf primefaces datatable overlay

我在嵌套数据表中嵌套了覆盖面板。在下面的代码中,ajax无法正常工作。同样的ajax调用工作有时并且下次不起作用。有时它完美有效,有时则不然。

<p:dataTable 
    id="MultipleDataTable"
    var="MultipleDiseasedDetail"
    rendered="#{diseasePatientDetailController.radioButtonSelect == 2}"
    value="#{diseasePatientDetailController.groupedMultiDiseasedPatientsByDiseaseIdList}"
    scrollable="true"
    scrollHeight="235"
    rows="20"
    paginator="true"
    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
    rowsPerPageTemplate="10,20,30"
    paginatorPosition="bottom"
    style="float:left;width:500px;"
    >

    <p:column styleClass="DiseaseNameTableColumn" sortBy="#{MultipleDiseasedDetail.disease_Name}">                                                    
        <f:facet name="header">
            <h:outputText value="Diseases"/>
        </f:facet>
        <h:commandLink id="patient" value="#{MultipleDiseasedDetail.disease_Name}">
            <f:param id="diseaseIdParam" name="diseaseIdParam" value="#{MultipleDiseasedDetail.disease_Id}"/>
            <f:ajax 
                listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
                execute ="patient diseaseIdParam"
                event="click"                                        
                render ="drDiseasesByCountTable"                                        
                />
        </h:commandLink>
        <p:overlayPanel
            id="MultipleDiseasePanel"
            appendToBody="true"
            for="patient"
            hideEffect="fade"
            dynamic="true"
            style="width:600px"
            showCloseIcon="true"
            >
            <p:dataTable 
                id="drDiseasesByCountTable"
                var="drDiseasesByCount"
                value="#{diseasePatientDetailController.groupedMultiDiseasedPatientsByDiseaseGroupList}"
                scrollable="true"
                scrollHeight="175"
                rows="20"
                paginator="true"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                rowsPerPageTemplate="10,20,30"
                paginatorPosition="bottom"
                >

                <p:column styleClass="DiseaseNameTableColumn" sortBy="#{drDiseasesByCount.grp_disease_names}">
                    <f:facet name="header">
                        <h:outputText value="Diseases"/>                                        
                    </f:facet>
                    <h:commandLink id="groupedDiseasesLink" value="#{drDiseasesByCount.grp_disease_names}">                                        
                        <f:param id="grpDiseaseIdsParam" name="grpDiseaseIdsParam" value="#{drDiseasesByCount.grp_disease_ids}"/>                                                  
                        <f:ajax 
                            listener="#{diseasePatientDetailController.drDiseasesByCountTable_RowClickEvent}"
                            execute ="groupedDiseasesLink grpDiseaseIdsParam"
                            event="click"
                            render="groupedDiseasesPatientsTable"
                            />
                    </h:commandLink>
                    <p:overlayPanel 
                        id="MultipleDiseasePatientPanel"
                        appendToBody="true"
                        for="groupedDiseasesLink"
                        hideEffect="fade"
                        dismissable="false" 
                        showCloseIcon="true"
                        dynamic="true" 
                        style="width:600px">

                        <p:dataTable 
                            id="groupedDiseasesPatientsTable"
                            var="drGroupPatient"
                            value="#{diseasePatientDetailController.multiPatientsByGroupDiseaseIDList}"
                            scrollable="true"
                            scrollHeight="150"
                            rows="20"
                            paginator="true"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowsPerPageTemplate="10,20,30"
                            paginatorPosition="bottom"
                            >

                            <p:column styleClass="DiseaseNameTableColumn" sortBy="#{drGroupPatient.patientName}">
                                <f:facet name="header">
                                    <h:outputText value="Patient"/>
                                </f:facet>
                                <h:outputLink value="#{drGroupPatient.patientDashboardUrl}">
                                    <h:outputText id="patient" value="#{drGroupPatient.patientName}" />
                                </h:outputLink>                                            
                            </p:column>
                        </p:dataTable>
                    </p:overlayPanel>
                </p:column>
            </p:dataTable>
        </p:overlayPanel>
    </p:column>
</p:dataTable>

我是否对ajax调用做了任何错误。我已经很好地测试了我的后端控制器。他们工作正常。使用带有嵌套数据表的overlaypanel不是一个好习惯。

感谢您宝贵的时间。

1 个答案:

答案 0 :(得分:2)

要获得完整答案,您的f:ajax应该来自

<f:ajax
  listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
  execute ="patient diseaseIdParam"
  event="click"                                        
  render ="drDiseasesByCountTable"/>

<p:ajax
  listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
  process="patient diseaseIdParam"
  event="click"                                        
  update="drDiseasesByCountTable"/>