multiple <h:form> for one tabview

UI Components for JSF
chsi
Posts: 57
Joined: 01 Sep 2010, 08:08

08 Sep 2010, 10:53

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

User avatar
Daedalus
Posts: 164
Joined: 28 Jan 2010, 12:03

08 Sep 2010, 12:32

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,

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Sep 2010, 14:01

Can you post your code?

chsi
Posts: 57
Joined: 01 Sep 2010, 08:08

08 Sep 2010, 14:51

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

goutham.rao
Posts: 24
Joined: 29 Jan 2010, 16:27
Location: Newbury,United Kingdom

08 Sep 2010, 15:05

Have you tried the Wizard(p:wizard) component?

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

chsi
Posts: 57
Joined: 01 Sep 2010, 08:08

08 Sep 2010, 15:49

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Sep 2010, 20:32

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.

chsi
Posts: 57
Joined: 01 Sep 2010, 08:08

09 Sep 2010, 08:42

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

Thank's

chsi
Posts: 57
Joined: 01 Sep 2010, 08:08

09 Sep 2010, 10:11

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Sep 2010, 11:06

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests