Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:40:58+00:00 2026-05-25T13:40:58+00:00

I am using the Facelet Templating Technology to layout my page in a JSF

  • 0

I am using the Facelet Templating Technology to layout my page in a JSF 2 app that I am working on.

In my header.xhtml, primefaces requires that menubar be enclosed in h:form.

<h:form>
    <p:menubar autoSubmenuDisplay="true">
        Menu Items here!
    </p:menubar>
</h:form>

So, in my contents pages, I will have another h:form or more.

Will it just work if I just place the h:form in my template.xhtml?

<h:body>
    <h:form>
        <div id="top">
            <ui:insert name="header"><ui:include src="sections/header.xhtml"/></ui:insert>
        </div>
        <div>
            <div id="left">
                <ui:insert name="sidebar"><ui:include src="sections/sidebar.xhtml"/></ui:insert>
            </div>
            <div id="content" class="left_content">
                <ui:insert name="content">Content</ui:insert>
            </div>
        </div>
        <div id="bottom">
            <ui:insert name="footer"><ui:include src="sections/footer.xhtml"/></ui:insert>
        </div>
    <h:form>
</h:body>

I am actually thinking of a use case where I need multiple h:form in a page.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:40:59+00:00Added an answer on May 25, 2026 at 1:40 pm

    You can safely use multiple forms in a JSF page. It’s not different than when using plain HTML.

    Nesting <form> elements is invalid in HTML. Since JSF just generates a bunch of HTML, it’s not different in JSF. Nesting <h:form> is therefore also invalid in JSF.

    <h:form>
        ...
        <h:form> <!-- This is INVALID! -->
            ...
        </h:form>
        ...
    </h:form>
    

    The browser behavior as to submitting a nested form is unspecified. It may or may not work the way you expect. It may for instance just refresh the page without invoking the bean action method. Even if you move the nested form (or a component that contains it) outside of the parent form with dom manipulation (or by e.g. using the PrimeFaces appendTo="@(body)"), it still won’t work and there should be no nested forms at time of loading the page.

    As to which forms you need to keep, having a single “god” <h:form> is actually a poor practice. So, you’d best remove the outer <h:form> from the master template and let the header, sidebar, content etc sections each define its own <h:form>. Multiple parallel forms is valid.

    <h:form>
        ...
    </h:form>
    <h:form> <!-- This is valid. -->
        ...
    </h:form>
    

    Each form must have one clear responsibility. E.g. a login form, a search form, the main form, the dialog form, etc. You don’t want to unnecessarily process all other forms/inputs, when you submit a certain form.

    Note thus that when you submit a certain form, other forms are NOT processed. So, if you intend to process an input of another form anyway, then you’ve a design problem. Either put it in the same form or throw in some ugly JavaScript hacks to copy the needed information into a hidden field of the form containing the submit button.

    Within a certain form, you can however use ajax to limit the processing of the inputs to a smaller subset. E.g. <f:ajax execute="@this"> will process (submit/convert/validate/invoke) only the current component and not others within the same form. This is usually to be used in use cases wherein other inputs within the same form need to be dynamically filled/rendered/toggled, e.g. dependent dropdown menus, autocomplete lists, selection tables, etc.

    See also:

    • commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated – point 2
    • What is <f:ajax execute="@all"> really supposed to do? It POSTs only the enclosing form
    • Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes
    • <p:commandbutton> action doesn't work inside <p:dialog>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with JSF and PrimeFaces and I am using Facelets as view technology.
Let's say that you have the following Facelet ( Using Facelets 1.1.12 ): edit_item.xhtml
I a working on a JSF2/Spring3/JPA2 project using facelets as view technology. javax.faces.DEFAULT_SUFFIX is
I'm using PrimeFaces 3.0 and JSF 2.0. In my webapp, I display a modal
I'm using facelet templating and I think I'm running into an issue with ui:define
I'm trying to reuse a jsf page by including using facelets into another jsf
I am using Eclipse ide, i am creating .xhtml pages using facelets and JSF,
I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object)
Using Richfaces 3.3.0GA, jsf 1.2_14 and facelets. I have a richfaces ModalPanel with an
I'm using JSF 1.2 with Richfaces and Facelets. I have an application with many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.