2011-11-30 70 views
3

我在从<rich:calendar>中选择日期时遇到了渲染data table的问题。我使用<a4j:ajax>进行渲染,但没有任何效果。下面是代码示例: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> 

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

+0

您的标记语法错误。开启和关闭标签不匹配。但是在查看页面时,这已经抛出了Facelets异常。请小心准备片段中的问题:) – BalusC

+0

:>我会记住这一点,感谢:-)) – nyxz

回答

7

由于它位于不同的命名容器父项中,因此需要通过其绝对客户端ID来引用它。要找到它,请在网页浏览器中打开该页面。 Rightclick and 查看源文件。找到由<rich:dataTable id="data_table">生成的HTML <table>元素。它会是这个样子:

<table id="data_table_form:data_table"> 

你需要采取正是ID,与JSF命名容器分隔符(默认为:),并用它在render属性前缀。

<a4j:ajax event="change" render=":data_table_form:data_table" /> 
+0

真的很棒!我一直在努力解决这一整天:X – nyxz

+0

该解决方案的工作.......... thanx Balus –