为什么我不能为p:accordionPanel中的每个p:tab设置ID [英] Why can't I set ID for each p:tab in p:accordionPanel

查看:47
本文介绍了为什么我不能为p:accordionPanel中的每个p:tab设置ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是p:accordionPanel而不是p:dataTable.每次更改标签时,我都想在控制器中重置活动标签的实体ID. IOW,如果AccordionPanel中的选项卡对应于ID为1、2、3的实体,则当我选择一个时,我希望将控制器中的activeEntityID变量重置为相应的ID:

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}">

控制器方法:

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

但是,我得到一个IllegalArgumentException:

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

如何在手风琴面板中的每个选项卡和控制器之间链接身份.我尝试在此示例之后对代码进行建模,但是它们的示例较差,因为它使用标签标题而不是ID.

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.

推荐答案

您不能以这种方式在id属性中使用EL. JSF不允许这样做. id属性应该在视图构建期间可用,但是在视图渲染期间会评估您的EL.为时已晚,因此在检查ID的那一刻,它为空.

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.

也看一下这个: 使用id =#{...}"导致java.lang.IllegalArgumentException:不允许使用空的id属性

这篇关于为什么我不能为p:accordionPanel中的每个p:tab设置ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆