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

我是研究僧i 提交于 2020-01-06 14:39:53

问题


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.


回答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



来源:https://stackoverflow.com/questions/27393187/why-cant-i-set-id-for-each-ptab-in-paccordionpanel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!