0

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).

Flow

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

Arturo Volpe
  • 3,442
  • 3
  • 25
  • 40
  • Have you tried putting everything inside one ``? – Makhiel Feb 19 '14 at 13:21
  • @Makhiel the problem persists with one global form. And I need two forms (in the real case, the `show` button is very nested) – Arturo Volpe Feb 19 '14 at 13:28
  • Probably a bug in RichFaces. The `extendedDataTable` is sensitive to visibility (that's why the data appears on resize), so maybe you can have the popup "always open" and just re-locate it off screen (`position:absolute; left:-2000px;`)? – mabi Feb 19 '14 at 15:01
  • 1
    Yeah, it's a bug. The render has to happen after the popup is shown. `onclick` instead of `oncomplete` seems to work. – Makhiel Feb 20 '14 at 11:02
  • @Makhiel yeah! it works!, thanks, can you post as an answer so I can mark as accepted? – Arturo Volpe Feb 20 '14 at 12:48

2 Answers2

2

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.

Makhiel
  • 3,874
  • 1
  • 15
  • 21
1

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')}.

W vd L
  • 625
  • 9
  • 26
  • Wouldn't this re-render the page and thus "close" the popup again? – mabi Feb 20 '14 at 09:48
  • Yes, it does. My solution here provided is a bit inclompete. adding the full solution to the post – W vd L Feb 20 '14 at 13:30
  • The point is: this re-renders *everything* inside the popup, which may not be desired. – mabi Feb 20 '14 at 13:46
  • @mabi, I don't deny that. thats why i said at the top that my solution ain't 100% richface correct. In my case, it has been so far the only possible solution (known to me). – W vd L Feb 20 '14 at 13:56