Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces dynamic overlayPanel showing only once

I have a form with a button that opens a Primafaces overlayPanel. In the panel there is another button that performs an Ajax action and then closes the overlay.
Here is a simplified version with no Ajax action at all:

<h:form>
    <p:commandButton id="button1" value="Open overlay" type="button"/>
    <p:overlayPanel for="button1" widgetVar="ovl" dynamic="true">
        <p:commandButton value="Close" oncomplete="ovl.hide();"
                         update="@form"/>
    </p:overlayPanel>
</h:form>

Please note that the panel must have dynamic="true" because dynamic content must be fetched in the real application, and update="@form" is needed in order to update other form components.

The problem is: if I have both attibutes, dynamic="true" and update="@form" the overlay shows up only the first time. After clicking the "close" button, if I try to click on "open overlay" once more, the panel won't show up.

What am I doing wrong?

(Using PrimeFaces 3.5 and GlassFish 3.1.2.2)

like image 626
yankee Avatar asked Mar 27 '13 10:03

yankee


1 Answers

Use onclick="widgetVar.loadContents()" in the button dropping down the overlaypanel, where widgetVar is the var of the overlayPanel.

like image 59
Marcus Oblak Avatar answered Oct 19 '22 14:10

Marcus Oblak