Board index JavaServer Faces General multiple <h:form> for one tabview

multiple <h:form> for one tabview

Components, Ajax Framework, Utilities and More.

Posts: 57
Hello, it is possible to have one form by tab??? Because i would like to validate tab by tab. With just one form for all the tabview --> i validate the first tab , the second tab is also validate... :?


Posts: 164
Yes I also noticed this problem.

Solution 1:
Set <p:tabView dynamic="false" >
Now all your tabs are loaded, switching is done only by JS and your <p:tabView> doesn't need to be surrounded by a form element.

Solution 2:
Use Ajax to validate your input fields. Just update the necessary elements with ajax and there is no need to submit a complete form
PrimeFaces 3.0, Glassfish 3.1.2, Mojarra 2.1.6,

Posts: 17226
Location: Cybertron

Can you post your code?

Posts: 57
Here ma code:

<p:tabView dynamic="true" cache="false" activeIndex="#{tabManager.activeIndex}" >
<p:tab title="Employeur - Travailleur" id="firstTab" >
<ui:include src="./tab1.xhtml"/>
<p:tab title="Occupation" id="secondTab" >
<ui:include src="./tab2.xhtml"/>
<p:tab title="Summary" id="ThirdTab" >
<ui:include src="./tab3.xhtml"/>

These 3 tabs share a managed bean called "article" with just properties like ( (name and description on first tab, price and quantity on second tab...).

The scenario is --> i'am on the first tab --> i go to the second tab without validate the first --> i'm back to the first then i valide and i receive error messages from data inside first tab(logic) but also error messages from second tab.. :? (problem).

my actions business is found in the article managedbean and i access via EL.

I hope that you can help me. Thank's

Posts: 24
Location: Newbury,United Kingdom
Have you tried the Wizard(p:wizard) component?

Primefaces 2.2.1
GlassFish V3.0, JSF 2.0.3
EJB 3.1,HIbernate 3.5
Coding on Netbeans 6.9.1

Posts: 57
No because the requirements for my webapp is

- The user can back to the first tab when he is on the fourth tab. (no back button back to the third tab then the second for finally arrive in the first tab).

- And the user can known how many tabs he must to fill before arrive to the end.

The tabview seems to be the best solution for that but...


Posts: 17226
Location: Cybertron

You can implement this with tabview as well.

Tabview has client side api like selectTab to show a tab so on client side depending on outcome from server you can switch between tabs. If you need to use dynamic tabs, a form should encapsulate the tabview and tabs should not have forms. In non-dynamic table this will not matter.

Also you would need partial processing as you want to process only current tab and ignore other tab contents.

Posts: 57
For partial processing, I do this with ajax ?? or it is possibly with other way


Posts: 57
I found a solution.. :) Thank's for all.

Posts: 17226
Location: Cybertron

Partial processing is used with ajax yes, glad you found your solution.


Return to General