Autosize for p:dialog to fit content ?

UI Components for JSF
Post Reply
moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

06 Apr 2011, 05:18

Hello all !

Im a newb with primefaces and currently using 2.2.1.
I notice i have to manually set the width and the height for the p:dialog in order to display all my dialog contents.
Is there a way to automate this, to autosize the popup dialog to fit the dialog's content, but not to become larger than the screen resolution ?

Thank you !

jtrotman
Posts: 49
Joined: 29 Nov 2010, 14:32
Location: United Kingdom

06 Apr 2011, 13:07

Code: Select all

.ui-dialog {
    width: auto !important;
}
Should do the trick.

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

07 Apr 2011, 05:17

Thank you ! Works like a charm.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

07 Apr 2011, 11:38

By the way. I would glad to see it as default in PrimeFaces. I think dialogs were auto-sized before 2.2.1 and now I have to define width: auto; What do you think? Auto-sized components are better than fix-sized.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

kanikman
Posts: 111
Joined: 20 Nov 2009, 02:53
Location: Poland
Contact:

07 Apr 2011, 17:58

I agree with you Oleg. But auto and fixed both should be implemented.

moonblade.wolf
Posts: 48
Joined: 07 Dec 2010, 02:46

08 Apr 2011, 10:13

The above css works cool, until this happens ...
1. I click on a button that reside inside that dialog
2. Validation occurs
3. p:message for each errornous field are displayed
4. some parts of the original become missing, hidden under the scrollbar or stuffs like texts break apart

Would be very cool if the dialog has a fitToSize() javascript function or autofit attribute.

For now i think i need to define fixed size dialog,
preparing the needed spaces for the p:message at the right side of each field

Using p:messages isnt a good idea since the error messages would be displayed above,
and could 'push' the form down, and hide some of the parts

Any comments on this matter ?
Thank you !
:-)

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

26 May 2011, 16:11

Hi,

Auto sized dialogs are possible with this workaround http://ovaraksin.blogspot.com/2011/05/j ... h-and.html

I would propose to introduce an attribute "autoSized" = true / false and include my code into PrimeFaces. It doesn't hirt because the code is only executed for autosized dialogs then. Cagatay?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests