Page 1 of 1

h:form outside p:dialog does not get posted

Posted: 24 Jun 2010, 13:47
by Turjakas
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.

Re: h:form outside p:dialog does not get posted

Posted: 25 Jun 2010, 19:05
by cagatay.civici
Strange, can you try update="display" without :.

Re: h:form outside p:dialog does not get posted

Posted: 28 Jun 2010, 12:05
by rafa
I tried the change you suggested (update="display") on Turjakas code and nothing happens, the behavior is exactly the same. Any other ideas?

Re: h:form outside p:dialog does not get posted

Posted: 30 Jun 2010, 08:52
by Turjakas
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...

Re: h:form outside p:dialog does not get posted

Posted: 01 Jul 2010, 00:36
by boscooo
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!

Re: h:form outside p:dialog does not get posted

Posted: 02 Jul 2010, 08:13
by Turjakas
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.

Re: h:form outside p:dialog does not get posted

Posted: 27 Jul 2010, 11:33
by Turjakas
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?

Re: h:form outside p:dialog does not get posted

Posted: 27 Jul 2010, 11:36
by cagatay.civici
Updating dialogs is not suggested, see this discussion;

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

Re: h:form outside p:dialog does not get posted

Posted: 27 Jul 2010, 11:43
by Oleg
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.

Re: h:form outside p:dialog does not get posted

Posted: 27 Jul 2010, 11:45
by cagatay.civici
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? ;)