Show/Hide Dialog Extraneous AJAX
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
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?
Are you sure? It's not happening here on show http://www.primefaces.org/showcase/ui/dialogClose.jsf
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Dialog show/hide will not cause an ajax request by default.
If you have an ajax closeListener, then it will do a request.
If you have an ajax closeListener, then it will do a request.
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
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:
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>
-
- Posts: 19
- Joined: 08 Nov 2010, 20:20
Maybe is the type of the p:commandButton, try type="button".
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Yes, type push is not a valid type, push buttons are defined as button as explained in user's guide.
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
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:
I don't want to have a child commandButton in there because it makes the menubar look stupid.
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();"/>
...
-
- Posts: 19
- Joined: 08 Nov 2010, 20:20
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();"/>
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
Yes, that works. Thanks.
This stuff isn't obvious so hopefully it gets documented in the book or guide.
This stuff isn't obvious so hopefully it gets documented in the book or guide.
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
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.
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.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 28 guests