Page 1 of 2

multiple <h:form> for one tabview

Posted: 08 Sep 2010, 10:53
by chsi
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... :?

Thank's

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 12:32
by Daedalus
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

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 14:01
by cagatay.civici
Can you post your code?

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 14:51
by chsi
Here ma code:

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

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

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 15:05
by goutham.rao
Have you tried the Wizard(p:wizard) component?

Cheers,
Goutham

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 15:49
by chsi
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...

Thank's

Re: multiple <h:form> for one tabview

Posted: 08 Sep 2010, 20:32
by cagatay.civici
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.

Re: multiple <h:form> for one tabview

Posted: 09 Sep 2010, 08:42
by chsi
For partial processing, I do this with ajax ?? or it is possibly with other way

Thank's

Re: multiple <h:form> for one tabview

Posted: 09 Sep 2010, 10:11
by chsi
I found a solution.. :) Thank's for all.

Re: multiple <h:form> for one tabview

Posted: 09 Sep 2010, 11:06
by cagatay.civici
Partial processing is used with ajax yes, glad you found your solution.