Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix width and height of primefaces dialogbox

In my web application i want to fix height and width of primefaces dialogbox in the way in which the dialogbox appears exactly in the middle of my web page, and if one want to minimize the window then the dialogbox should also be minimised. i mean middle of my one of the frame not whole window.

i.e. dynamic sized dialog box like % width and height

thanks for any help...

like image 714
Annu Avatar asked Apr 07 '11 11:04

Annu


3 Answers

You can use following code to make it of fixed dimension,

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" width="300" height="200">  
    <h:outputText value="This is a Modal Dialog." />  
</p:dialog>    

and to make minimize functionality. you can play with javascript to get it done.

See Also

  • Primefaces Show case
like image 145
jmj Avatar answered Nov 20 '22 06:11

jmj


Try this, use a attribute style (or styleclass):

<p:dialog ... modal="true" style="width:50% !important; height:40% !important; top:25% !important; left: 30% !important;">
  <!-- any components -->
</p:dialog>

See more here.

like image 26
Máťa - Stitod.cz Avatar answered Nov 20 '22 08:11

Máťa - Stitod.cz


If you are using p-dialog, then you will want to use the built-in styleClass attribute.

.my-style-class {
    width: 50%;
    height: 70%;
}
<p-dialog styleClass="my-style-class"><p-dialog>
like image 1
nanoTitan Avatar answered Nov 20 '22 06:11

nanoTitan