h:form outside p:dialog does not get posted

Components, Ajax Framework, Utilities and More.
Post Reply
Turjakas
Posts: 48
Joined: 22 Jan 2010, 17:07

24 Jun 2010, 13:47

If I put a h:form component outside p:dialog and try to post something inside the dialog using p:commandButton (with PrimeFaces AJAX!), nothing gets updated.
Also, putting a nested form inside p:dialog does not work. And yes, I do need the form outside p:dialog.

Nested forms seem to work correctly with plain JSF2 AJAX using h:commandButton and f:ajax, but I want to use PF AJAX as it gives me more control and JSF2 AJAX is not compatible with PF yet.

Here's a simple test case for the problem:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.prime.com.tr/ui">
  <html xmlns="http://www.w3.org/1999/xhtml">
    <h:head>
      <title>Test</title>
    </h:head>
    <h:body>
      <h:outputLink value="javascript:void(0)" onclick="dlg.show()">Show</h:outputLink>

      <h:form>
        <p:dialog header="Name" widgetVar="dlg" resizable="false" width="500">

          <h:panelGrid columns="2" style="margin-bottom:10px">
            <h:outputLabel for="firstname" value="Name:" />
            <h:inputText id="firstname" value="#{backingBean.name}" />
          </h:panelGrid>

          <p:commandButton value="Submit" update=":display" oncomplete="dlg.hide();"/>

        </p:dialog>
      </h:form>

      <p:outputPanel id="display" style="display:block;margin-top:10px;">
        <h:outputText id="name" value="#{backingBean.name}" />
      </p:outputPanel>
    </h:body>
  </html>
</f:view>
If you click the button, nothing happens - the h:outputText does not get updated, and the value of the text field does NOT even get passed to the bean!

As soon as h:form is inside p:dialog (and there is NO h:form outside the dialog -> no nested forms), the example starts to work.

User avatar
optimus.prime
Prime
Posts: 17328
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

25 Jun 2010, 19:05

Strange, can you try update="display" without :.

rafa
Posts: 1
Joined: 28 Jun 2010, 11:49

28 Jun 2010, 12:05

I tried the change you suggested (update="display") on Turjakas code and nothing happens, the behavior is exactly the same. Any other ideas?

Turjakas
Posts: 48
Joined: 22 Jan 2010, 17:07

30 Jun 2010, 08:52

I tried the approach without the colon, but it did not solve the problem.

This is a real showstopper for us in our application development as we cannot use p:dialog at all now...

User avatar
boscooo
Posts: 55
Joined: 07 Apr 2010, 15:48
Location: Brazil

01 Jul 2010, 00:36

I've faced similar problem today: update doesn't reach elements inside a form....

To solve this... i've assigned one id to the form and referred it on update as follows:

Code: Select all

<h:form id="form1">
     <p:outputPanel id="panel2">
     ....

    <p:commandLink .... update="form1:panel2"/>
</h:form>
Try it!
JBoss Seam 2.2.0 GA Web Framework
Mojarra 1.2_15-SNAPSHOT JSF Implementation
PrimeFaces 1.0.2 Final
RichFaces 3.3.3 Final
JBoss AS 4.2.2 GA

Turjakas
Posts: 48
Joined: 22 Jan 2010, 17:07

02 Jul 2010, 08:13

boscooo, your problem is definitely not the same as I'm describing. Adding the form ID does NOT fix the problem with p:dialog.

Also, as you can see, the h:outputText component is OUTSIDE the form in the example, so you cannot use any form ID.

Turjakas
Posts: 48
Joined: 22 Jan 2010, 17:07

27 Jul 2010, 11:33

I've also noticed one additional feature / bug related to p:dialog inside a h:form. As the p:dialog gets replaced with another dialog in a partial update, the next time the dialog is shown you actually get an ADDITIONAL dialog, so that you'll see the original dialog and the one that was put to the page (on top of each other) in the partial update. This goes on and on for every partial update, so you can really get lots of dialogs popping up. Any idea how to fix this?

User avatar
optimus.prime
Prime
Posts: 17328
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Jul 2010, 11:36

Updating dialogs is not suggested, see this discussion;

http://primefaces.prime.com.tr/forum/vi ... lit=dialog

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

27 Jul 2010, 11:43

Yes, I agree too. Updating of entire dialog is not suggested. With YUI dialog there are flickers and semi-transparent mask for modal dialog can not be recalculated.

User avatar
optimus.prime
Prime
Posts: 17328
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Jul 2010, 11:45

Yes, let's think of this way, if you aren't using PrimeFaces and using plain jquery ui or yui dialog or any javascript dialog, will you reinitialize the dialog if you want to update the contents or will you just update the dialogs contents? ;)

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests