title: Primefaces programmatic tabMenu action listener
body: <h2>Background and purpose:</h2>
  
  <p>I would like to use use the tabMenu in order to switch some displayed content on the same page according to the selected tab. I chose the tabMenu because it is supporting a model binding, thus enabling me to use a programmatic model. I do not want use the tabMenu for navigation nor  shall the current page be requested again.
  I put my implementation into an composite component (CC) in order to be flexible for the design part in case the CC shall be reused or placed on some other page. My backing bean for this CC implements the ActionListener interface that is added to each primefaces menuItem that is added to the menu model. The implementation of the overridden method is then supposed to update the model in the background in order to have the dynamic content displayed correctly according to the clicked menuItem.
  On the page I am trying to use my CC I am also using an primefaces tabView in order to separate the different contents. In the tab where I want to use my CC I am also using primefaces accordionPanel where my CC is the content of one of its tabs.</p>
  
  <h2>Error situation and expected behaviour:</h2>
  
  <p>Having placed my composite component on my page in one of the accordionPanel's tabs the menu's model is correctly built in my backing bean and displayed. Clicking on one menu item does not result in a triggered action (I can tell because eclipse does not stop at the break point in my processAction method). According to the server log no exception is thrown.</p>
  
  <p>Since the menuItem has an actionListener attribute which can be used for a server side call back I expect the ActionListener which I add to the menuItem with the addActionListener() method to have the same functionality.</p>
  
  <p>I have also tried to place my CC outside the outer tabView with the same result.</p>
  
  <h2>Question:</h2>
  
  <p>Is it possible to acchieve what I intend to do with the tabMenu? Do I have alternatives besides the tabMenu? What do I have to change in order to get the desired behaviour?</p>
  
  <p>Page definition:</p>
  
  <pre><code> &lt;p:tabView id="someTabViewId"&gt;
      &lt;p:tab id="tabViewsFirstTab&gt;
        &lt;p:accordionPanel id="accordionPanelId" multiple="true" cache="false"&gt;
          &lt;p:tab id="someTab1Id" title="someTab1Title"&gt;
  ... someTab1 content here ...
          &lt;/p:tab&gt;
  
          &lt;p:tab id="ccTab" title="ccTabTitle"&gt;
            &lt;ccNameSpace:ccComponentName id="ccId" /&gt;
          &lt;/p:tab&gt;
  
          &lt;p:tab id="someTab2Id" title="someTab2Title"&gt;
  ... someTab2 content here ...
          &lt;/p:tab&gt;
        &lt;/p:accordionPanel&gt;
      &lt;/p:tab&gt;
   &lt;/p:tabView&gt;
  </code></pre>
  
  <p>CC definition:</p>
  
  <pre><code>  &lt;composite:interface&gt;
    &lt;/composite:interface&gt;
    &lt;composite:implementation xmlns:anotherCCNameSpace="http://java.sun.com/jsf/composite/components/someEntity/someSpecialContent"&gt;
      &lt;h:panelGrid style="width:100%;"&gt;
        &lt;p:tabMenu id="test1" model="#{ccBean.tabMenuModel}" /&gt;
        &lt;anotherCCNameSpace:specialComponent id="test" /&gt;
      &lt;/h:panelGrid&gt;
    &lt;/composite:implementation&gt;
  </code></pre>
  
  <p>Bean definition:</p>
  
  <pre><code>@Named
  @ViewScoped
  public class CcBean implements ActionListener, SomeCustomInterface {
  
    private MenuModel menuModel;
  
  ...
  
    @Override
    public void processAction(ActionEvent event) throws AbortProcessingException {
      this.doSomePreparations(event);
    }
  
   @PostConstruct
    public void postConstruct() {
      this.menuModel = new DefaultMenuModel();
      for (SomeGroupEntity groupEntity : this.getAllSomeGroupEntities()) {
        MenuItem menuItem = new MenuItem();
        menuItem.setId("menuItem" + groupEntity.getId());
        menuItem.setUpdate("test1 test");
        menuItem.addActionListener(this);
        menuItem.setImmediate(true);
        menuItem.setValue(groupEntity.getName());
        this.menuModel.addMenuItem(menuItem);
      }
    }
  
  
    public MenuModel getTabMenuModel() {
      return this.menuModel;
    }
  
  ...
  }
  </code></pre>