Show/Hide Dialog Extraneous AJAX

UI Components for JSF
User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

11 Nov 2010, 16:06

The dialog show and hide actions each cause an ajax request. Using Firebug to snoop, it appears the requests and responses are basically empty. Are these requests necessary?

callahan
Posts: 768
Joined: 27 May 2010, 22:52

11 Nov 2010, 16:16

Are you sure? It's not happening here on show http://www.primefaces.org/showcase/ui/dialogClose.jsf

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Nov 2010, 17:38

Dialog show/hide will not cause an ajax request by default.

If you have an ajax closeListener, then it will do a request.

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

11 Nov 2010, 18:05

This is very strange. I see that the problem is not present on the showcase here:

http://www.primefaces.org/showcase/ui/dialog.jsf

However, if I use the code below in my local workstation I see the issue:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <f:view contentType="text/html" encoding="UTF-8">
        <h:head>
            <link type="text/css" rel="stylesheet" href="./resources/themes/sunny/skin.css"/>
        </h:head>
        <h:body>
            <h:form>
                <p:commandButton type="push" value="Open" onclick="testDlg.show();"/>
            </h:form>
            <p:dialog header="Test" widgetVar="testDlg" width="500" height="350" resizable="false">
                <h:form>
                    <p:commandButton value="OK" type="push" onclick="testDlg.hide();"/>
                </h:form>
            </p:dialog>
        </h:body>
    </f:view>
</html>

Leandro Borges
Posts: 19
Joined: 08 Nov 2010, 20:20

11 Nov 2010, 18:15

Maybe is the type of the p:commandButton, try type="button".

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Nov 2010, 18:16

Yes, type push is not a valid type, push buttons are defined as button as explained in user's guide.

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

11 Nov 2010, 19:27

Yes, that was it. Thanks so much.

I checked the user guide here: http://www.primefaces.org/documentation.html and all it says is that the type attribute of a commandButton can be one of "submit" or "Reset".

I didn't just make the "push" thing up. I grabbed it from the showcase toolbar example here: http://www.primefaces.org/showcase/ui/toolbar.jsf

OK, now what about the menuitem? I'm actually using a menuitem to open the dialog and the problem persists with it:

Code: Select all

<p:menubar>
    <p:submenu label="File">
        <p:menuitem value="Open" onclick="testDlg.show();"/>
        ...
I don't want to have a child commandButton in there because it makes the menubar look stupid.

Leandro Borges
Posts: 19
Joined: 08 Nov 2010, 20:20

11 Nov 2010, 20:30

You can use the url value, since when you set the url the action are not submitted.

Code: Select all

<p:menuitem value="Open" url="javascript:testDlg.show();"/>

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

11 Nov 2010, 22:50

Yes, that works. Thanks.

This stuff isn't obvious so hopefully it gets documented in the book or guide.

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

12 Nov 2010, 14:50

I ran into a snag with using the url attribute to open the dialog. If the site uses sessions (almost all do) and the application server decides to append a jsessionid to the url then the open dialog won't work and the user will get a JavaScript error.

For some reason when I first navigate to the application the first response puts a jsessionid in the url. The requests and responses afterwards do not have jsessionid. Weird. Anyways, I assume some clients may not allow cookies at all in which case the jessionid will always be there.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests