Board index JavaServer Faces General h:form outside p:dialog does not get posted

h:form outside p:dialog does not get posted

Components, Ajax Framework, Utilities and More.


Posts: 48
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:
<?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.


Posts: 15103
Location: Cybertron

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


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


Posts: 48
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...


Posts: 55
Location: Brazil
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:

<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


Posts: 48
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.


Posts: 48
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?


Posts: 15103
Location: Cybertron

Updating dialogs is not suggested, see this discussion;

viewtopic.php?f=3&t=3473&start=0&hilit=dialog
PrimeFaces Lead

Oleg User avatar
Expert Member

Posts: 3715
Location: Russia, Siberia => Germany, Black Forest
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.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 15103
Location: Cybertron

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? ;)
PrimeFaces Lead


Return to General