Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to position a p:dialog in Prime Faces after its resizing

I have a Prime Faces p:dialog that has been resized while new components are inserted when opened ('show' state). However its position doesn't change and it's size is increasing from the down left corner until the page bottom.

I need to reposition it every time I render new components dynamically. Is there any JavaScript function I can call to its widget to reposition?

I'm using PrimeFaces 3.5 with Mojarra 2.1.13.

like image 321
Adriano Castro Avatar asked May 15 '13 23:05

Adriano Castro


1 Answers

I had a similar situation with a TabView inside a dialog. The TabView content was dynamically loaded.

<p:dialog widgetVar="dialogWidgetVar">
    <p:tabView value="#{tabBean.tabs}" var="tabsVar"
            onTabShow="PF('dialogWidgetVar').initPosition();" dynamic="true">
        <p:tab id="Tab#{tabsVar.id}" title="#{tabsVar.name}">
            ...
        </p:tab>
    </p:tabView>
</p:dialog>

As you can see it will call the function initPosition() with every change of a Tab. This function will reposition your dialog. You can use this function in several cases.

  1. http://forum.primefaces.org/viewtopic.php?f=3&t=16893
like image 146
kdoteu Avatar answered Oct 03 '22 23:10

kdoteu