Render rich:extendedDataTable

2019-08-29 02:35发布

问题:

I need a rich:popup that shows a rich:extendedDataTable, and when the user presses a button, the popup should be shown, and the extendedDataTable must be re-rendered, here is the code:

<rich:popupPanel id="popupId" show="false" modal="true">
    <h:form>
        <rich:extendedDataTable
            value="#{bean.list}"
            var="item" rows="5" id="table">
            <rich:column>
                <h:outputLabel value="#{item}" />
            </rich:column>
        </rich:extendedDataTable>

        <a4j:commandButton value="x" immediate="true"
            oncomplete="#{rich:component('popupId')}.hide(); return false;"/>
    </h:form>

</rich:popupPanel>


<h:form>
    <a4j:commandButton value="show"
        oncomplete="#{rich:component('popupId')}.show(); return false;"
        render="table" immediate="true" />
</h:form>

The first time I press the show it works fine, but when I close the panel with the X button and press again the show button, the extendedDataTable appears empty (It's rendered but appear empty, see image below).

The problem is fixed if I add an empty extendedDataTable before the popup, like this:

<rich:extendedDataTable />
<rich:popupPanel>
     ...

With rich:dataTable the problem doesn't exits, but I need a extendedDataTable.

And aditional extrange behaviour is when I resize the browser, the data appears.

Platform

  • RichFaces: 4.2.2.Final
  • Spring: 3.1.1.RELEASE

Cheers

回答1:

Use onclick instead of oncomplete. ExtendedDataTable doesn't render properly inside invisible elements (it's a bug) so the popupPanel has to be made visible before the rerendering.



回答2:

I had kinda the same issue.

I solved it in a not 100% richface correct way:

<a4j:commandButton 
  value="show"
  action="#{actionForm.setShowEditor('true')}"
  oncomplete="javascript:location.reload(true)"/>

<a4j:region layout="block" rendered="#{actionForm.showEditor}" id="panelArea">
   <rich:popupPanel id="#{popupID}" modal="true" show="true" domElementAttachment="parent">
   ....
   tabel
   buttons
   ....
   </rich:popupPanel>
</a4j:region>

The popup is always shown (show="true") inside the a4j:region. But the a4j:region is only shown if variable to show the popup = true.

The full page refresh was in my case needed because otherwise my ckeditor had some initialisation errors. It should also work if you only rerender the a4j:region after you set the "#{actionForm.setShowEditor('true')}.