Enabling/disabling tabs programatically

As I was reading the JBoss RichFaces forum, I saw this post. Here is one possible solution.





		Tab 1
		Tab 2
		Tab 3

TestBean.java class:

package test;

import java.util.HashMap;
import javax.annotation.PostConstruct;
import javax.faces.event.ActionEvent;

public class TabsBean {

   private HashMap tabsMap;
   private Boolean value;

   // setters and getters

   public void create (){
	tabsMap = new HashMap ();
	tabsMap.put("tab1", false);
	tabsMap.put("tab2", false);
	tabsMap.put("tab3", false);

   public void disable (ActionEvent event) {
	String id = event.getComponent().getId();
	tabsMap.put(id, value);
   public TabsBean() {}

Bean registration in JSF configuration file (manage bean in session scope in order to remember enabled/disabled tab state between requests):


One thought on “Enabling/disabling tabs programatically

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s