amphibient
amphibient

Reputation: 31248

Why can't I set ID for each p:tab in p:accordionPanel

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.

Upvotes: 0

Views: 1297

Answers (1)

Emil Kaminski
Emil Kaminski

Reputation: 1885

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

Upvotes: 1

Related Questions