Ajax-呈现一个不同形式的表

nyx*_*yxz 3 ajax richfaces jsf-2

data table在选择日期时遇到问题<rich:calendar>.我<a4j:ajax>用于渲染但没有效果.这是代码示例:

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

    <rich:panel header="#{lang.reportPanelHeader}" id="panel" rendered="#{navigation.reportRendered}" width="700px" style="margin-left:250px">
        <a4j:status onstart="#{rich:component('statPane')}.show()" onstop="#{rich:component('statPane')}.hide()" />
        <h:form id="data_table_form">
            <rich:dataTable value="#{validateReportAction.reportList}" var="report" iterationStatusVar="it" id="data_table" rows="5">
               <rich:column>
                   <f:facet name="header">#</f:facet>
                   #{it.index  + 1}
               </rich:column>

               <rich:column>
                   ....
               </rich:column>

                <f:facet name="footer">
                    <rich:dataScroller page="#{validateReportAction.page}" />
                </f:facet>
            </rich:dataTable>
        </h:form>

        <rich:popupPanel id="statPane" autosized="true" style="border: none; background-color: #e6e6e6;">
            ....
        </rich:popupPanel>

        <div id="bottom">
            <h:form id="calendarForm">
                <div id="left">                
                    <div class="input" id="test_cal">
                        <rich:calendar 
                            dataModel="#{calendarModel}"
                            value="#{validateReportAction.selectedDate}"
                            boundaryDatesMode="scroll"
                            required="true" 
                            requiredMessage="#{lang.dateRequiredMsg}" 
                            mode="ajax"
                            id="date"
                            datePattern="dd.MM.yyyy"
                            popup="false">

                            <a4j:ajax event="change" render="@all"/>

                        </rich:calendar>

                        <span class="error_msg">
                            <rich:message for="date" ajaxRendered="true"/>
                        </span>
                    </div>
                </div>
            </h:form>
        </div>
    </rich:panel>

</ui:composition>
Run Code Online (Sandbox Code Playgroud)

我被迫在日历中使用@all,<a4j:ajax event="change" render="@all"/> 但我想只渲染data table.我怎样才能做到这一点?

Bal*_*usC 7

由于它位于不同的命名容器父级中,因此您需要通过其绝对客户端ID来引用它.要找到它,请在webbrowser中打开页面.右键单击并查看源代码.找到<table>生成的HTML 元素<rich:dataTable id="data_table">.它看起来像这样:

<table id="data_table_form:data_table">
Run Code Online (Sandbox Code Playgroud)

您需要使用该ID,前缀为JSF命名容器分隔符(默认为:)并在render属性中使用它.

<a4j:ajax event="change" render=":data_table_form:data_table" />
Run Code Online (Sandbox Code Playgroud)