Search code examples
javajsffacelets

How to avoid nested h:form (s)?


Due to some presentation needs I have got stuck with a h:form tag inside a parent h:form. How should I make this work without disturbing the look of the page ?

    <h:form>
        ....
        ....

        <h:outputText value="Your city not listed? Add here..">
        <p:dialog>
             <h:form>   
                <p:commandButton value="Add" action="#gpController.create()}" />
             </h:form>                 
        </p:dialog>

        ....
        ....
    </h:form>

Solution

  • Just put the dialog outside the form. It really doesn't matter to the UI where the dialog component is located in the view.

    <h:form>
       ...
       <h:outputText value="Your city not listed? Add here..">
       ...
    </h:form>
    <p:dialog>
         <h:form>   
            <p:commandButton value="Add" action="#{gpController.create()}" />
         </h:form>                 
    </p:dialog>