Solved: Dialog Framework options

Components, Ajax Framework, Utilities and More.
Post Reply
User avatar
andyba
Expert Member
Posts: 2475
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

14 Nov 2014, 14:21

I have recently been changing the way dialogs are used in a PrimeFaces based project so that the Dialog Framework is used.

So far everything has gone well with one rather glaring exception: there is no documentation about the options that can be set for them other than a rather vague "similar to the component attributes like modal, resizable etc." Apart from the fact that this kind of documentation always ends up being the last thing to be done, which is at worst frustrating, it means that I am unable to fulfil a requirement that all dialogs be positioned at the top of the page and centered horizontally. This is easily done using position="center top" with the p:dialog tag but only causes JavaScript errors when I try
The requirement stems from the fact that the app is often used on screens with 1024x640 resolution (tablets) and the dialogs extend down and to the left when they resize to fit content.

Code: Select all

        Map<String, Object> dialogOptions = new HashMap<>();
        dialogOptions.put("modal", Boolean.TRUE); // This works fine
        dialogOptions.put("position", "center top"); // This causes JavaScript to throw tantrums
        RequestContext.getCurrentInstance().openDialog(dialogOutcome, dialogOptions, null);
PrimeFaces version is 4.0.8, Glassfish and JSF version are irrelevant.

Is there any complete list of options and acceptable values around?
If not, how do I get the dialogs to be positioned top and centered?

Edit: User Guide gives the following as list of options: modal, resizable, draggable, width, height,contentWidth, contentHeight.
Looks like I am going to be grinding my teeth in frustration on this one as even 5.1 does not support the full range of options that the p:dialog does.
Last edited by andyba on 20 Nov 2014, 17:05, edited 1 time in total.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

User avatar
andyba
Expert Member
Posts: 2475
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

20 Nov 2014, 17:05

A pragmatic solution was easy to implement

Code: Select all

        <script type="text/javascript">
            function dialogTop(formId, buttonId) {
                var selector = $('#$1\\:$2_dlg'.replace('$1', formId).replace('$2', buttonId));
                if (selector.css('top') !== 'auto') {
                    $(selector).css({top: '0px'});
                } else {
                    setTimeout(function () {
                        dialogTop(formId, buttonId);
                    }, 50);
                }
            }
        </script>
which is executed...

Code: Select all

oncomplete="setTimeout(function () {dialogTop('regionsForm', 'newRegionCommand');}, 50);"
in the button which causes the dialog to be opened.
Note the use of setTimeout, this ensures that attempts are made to reposition the dialog until it is rendered and that the css top: value is != auto.

While this works it is obviously not ideal

- it is not proof against future versions of PrimeFaces
- it relies on css defaults

Do I need to create an issue about this so that the full range of options in normal dialogs are also available for the Dialog Framework or is this on the TODO list.
Obviously some options may not be practical to implement but this one surely is.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

emre
Posts: 14
Joined: 25 Jan 2011, 12:30

18 Sep 2016, 20:33

Hi,
We are still observing the positioning issue with primefaces 6.0. Is anybody aware whether there is an improvement plan for Dialog Framework to support positioning similar to p:dialog component.

Zardo
Posts: 29
Joined: 29 Jul 2015, 15:41

07 Nov 2016, 08:50

I would also be interested in a nice solution for this issue

andrewb
Posts: 7
Joined: 05 Jun 2014, 22:13

19 Apr 2017, 17:52

I too would be interested in a solution for this issue.
PrimeFace 6.0.x, MyFaces 2.2.12, Tomcat 7

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 40 guests