简体   繁体   English

EL表达式中的双重引用

[英]double reference in EL expression

I'm trying to make a "rich:dataTable" with a dynamic number of columns. 我正在尝试创建具有动态列数的“ rich:dataTable”。 I have a bean with a List of columns (with attributes headerName and fieldName) and a list of items to be represented in the table so I have next code: 我有一个带有列列表(具有属性headerName和fieldName)和要在表中表示的项目列表的Bean,所以我有下一个代码:

<rich:dataTable id="data_table" value="#{bean.list}" var="item">

    <c:forEach items="#{bean.columnList}" var="col">

        <rich:column>
            <f:facet name="header">
                <h:outputText value="#{col['headerName']}" />
            </f:facet>
            <h:outputText value="??" />
        </rich:column>

    </c:forEach>

</rich:dataTable>

The problem is that I don't know how to put the value="??" 问题是我不知道如何将value =“ ??” to represent what I want. 代表我想要的 I want something like: 我想要类似的东西:

value="#{item.#{col.fieldName}}"

but I don't know how can I represent it with the correct Expression Language. 但是我不知道如何用正确的表达语言来表示它。

I'm using JSF2.1 and Richfaces 4.3.2 我正在使用JSF2.1和Richfaces 4.3.2

Con somebody help me with this issue? 骗人帮助我解决这个问题?

Use the brace notation #{bean[property]} . 使用大括号符号#{bean[property]} It allows you to use variables instead of constants as property names. 它允许您使用变量而不是常量作为属性名称。

value="#{item[col.fieldName]}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM