How to traverse between tabs
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
How to traverse between tabs  XML
Forum Index -> Components
Author Message
John26

Joined: 30/08/2010 12:58:58
Messages: 3
Offline


I have 3 tabs in a page .In the first tab I have back and continue button.
When I click on Continue the control should go to second tab and when the back button is clicked it should go to previous tab.How to proceed with this scenario .Any help appreciated.
georges.goebel@pch.etat.l


Joined: 23/06/2007 00:00:00
Messages: 276
Offline


Hi


<ice:panelTabSet tabPlacement="top" selectedIndex="#{backingBean.selectedIndex}">
.....
</icepanelTabSet>

When you execute your action when you click on continue, you can change the selectedIndex value (0 -> first tab, 1 -> second tab, ....) and the view should change the shown tab

Regards

Georges Goebel
[Email]
John26

Joined: 30/08/2010 12:58:58
Messages: 3
Offline


Thank you .But I also want how to disable the second tab when I am in first tab.If I click continue then only the second tab has to be enabled.
Unvirtual

Joined: 02/01/2009 00:00:00
Messages: 42
Offline


You could create a list of Enabled Tabs, on click continue u add the tabindex to list and in frontend you can check it by tabs disabled attribute:

Backend:
Code:
 
 /**
  * TODO Florian Hell insert type comment
  *
  * @author Florian Hell
  * @version $Rev$, $Date$
  *
  */
 @Name("anamnesisAction")
 @Scope(ScopeType.CONVERSATION)
 @Stateful
 public class TabAction implements ITabAction {
 		
         @Logger
 	private Log log;
 
 	/** Current selected Tab */
 	@Out
 	private Integer currentTab;
 	
 	
 	/** {@link ArrayList} with currently enabled tabs */
 	private List<Integer> tabsEnabled;
 	
 		
 	/** {@inheritDoc} */
 	public void tabChanged(TabChangeEvent tabChangeEvent) {
 		currentTab = tabChangeEvent.getNewTabIndex();
 		log.info("Current Tab: {0}", currentTab);
 	}
 	
 	/** {@inheritDoc} */
 	public void previousPage(){
 		currentTab = currentTab -1;
 		log.info("Current Tab: {0}", currentTab);
 	}
 	
 	/** {@inheritDoc} */
 	public void nextPage(){
 		tabsEnabled.add(currentTab +1);
 		currentTab = currentTab +1;
 		log.info("Current Tab: {0}", currentTab);
 	}
 
 	
 	/** {@inheritDoc} */
 	public boolean tabEnabled(Integer tabId) {
 		if(tabsEnabled.contains(tabId)) {
 			return true;
 		}
 		return false;
 	}
 	
 	/** {@inheritDoc} */
 	@Remove @Destroy
 	public void destroy() {
 				
 	}
 	
 }
 


And frontend:
Code:
 <ice:form id="tabForm">
 		   <ice:panelTabSet id="tabset" selectedIndex="#{currentTab}" >
 		   
 					<ice:panelTab disabled="#{!tabAction.tabEnabled(0)}" label="Tab 1">
 							
 					</ice:panelTab> 
 					<ice:panelTab disabled="#{!tabAction.tabEnabled(1)}" label="Tab 2">
 							<ui:include src="anamnesisDiseases.xhtml" />   
 					</ice:panelTab> 
 					<ice:panelTab disabled="#{!tabAction.tabEnabled(2)}" label="Tab 3">
 							<ui:include src="anamnesisMedicines.xhtml" />
 					</ice:panelTab> 					  
 		   </ice:panelTabSet>
 		   <ice:commandButton value="#{messages.btnPrev}" rendered="#{currentTab != 0}" action="#{tabAction.previousPage}" />
 		   <ice:commandButton value="#{messages.btnNext}" action="#{tabAction.nextPage}" />
        </ice:form>
 


My example uses seam, so may u have to do it without outjections.

Hope this helps you.

Greetz
Florian Hell
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team