0

I am using a p:accordionPanel instead of a p:dataTable. Every time I change a tab, I would like to reset the active tab's entity ID within the controller. IOW, if the tabs in the accordionPanel correspond to entities whose IDs are 1, 2, 3, when I select one, I want the activeEntityID variable in the controller to be reset to the corresponding ID:

<p:accordionPanel value="#{litigController.appealsForCase}" var="appeal">
    <p:ajax event="tabChange" listener="#{litigController.setSelectedAppeal}"/>
    <p:tab id="#{appeal.appealID}" title="Appellate Court No #{appeal.appelateCourtNo}">

Controller method:

public void setSelectedAppeal(TabChangeEvent event) {
        this.activeAppealID = event.getTab().getId();
        System.out.println("tab change for appealID " + this.activeAppealID);
    }

However, I get an IllegalArgumentException:

 java.lang.IllegalArgumentException: Empty id attribute is not allowed

How can I link identity between each tab in my accordionPanel and the controller. I tried modeling my code after this example, but their example is poor because it uses the tab title and not an id.

amphibient
  • 29,770
  • 54
  • 146
  • 240

1 Answers1

1

You can't use EL in id attribute in this way. JSF dosn't allow it. The id attribute should be available during view build time, but your EL is evaluated during view render time. This is too late, so in the moment that the id is checked, it is empty.

Also take a look at this: Using id="#{...}" causes java.lang.IllegalArgumentException: Empty id attribute is not allowed

Community
  • 1
  • 1
Emil Kaminski
  • 1,886
  • 2
  • 16
  • 26
  • what i really need to do is this: http://stackoverflow.com/questions/27404871/how-to-id-a-tab-inside-paccordionpanel-for-controller-functions – amphibient Dec 10 '14 at 17:20
  • You can still id a tab using static values. So you can call your tabs etc. If you have a dynamic number of tabs, you may want to create those programmatically instead. – Emil Kaminski Dec 11 '14 at 08:09
  • unfortunately, that doesn't really do it for me for the reason i explained in the other thread. thanks for all your ideas though – amphibient Dec 11 '14 at 15:50