2013-03-11 50 views
0

我有一个bean,它返回键值对(String,String)的映射。在我jsff,我需要访问基于关键地图的值,它是一个动态的EL表达式地图中的动态El表达式评估

<af:iterator id="i1" value="#{bindings.leaderBoardEntities.collectionModel}" 
var="entity" rows="#{bindings.leaderBoardEntities.rangeSize}"> 

    <af:image id="i2" source="# {pageFlowScope.ImagesBean.imageUrlPair[entity.displayName]}" 
    shortDesc="user info" inlineStyle="width:50px;height:50px;"/> 
</af:iterator> 

我不能安勤为地图的关键。 我试过了,

source="#{pageFlowScope.ImagesBean.imageUrlPair[entity.displayName]} 
source="#{pageFlowScope.ImagesBean.imageUrlPair['#{entity.displayName}']} 
source="#{pageFlowScope.ImagesBean.imageUrlPair['${entity.displayName}']} 
source="#{pageFlowScope.ImagesBean.imageUrlPair[#{entity.displayName}]}--this is  syntactically wrong 

然而,这个工程

source="#{pageFlowScope.ImagesBean.imageUrlPair['Twitter']} 

请帮我

+0

什么是imageUrlPair的类型? – 2013-03-12 00:03:29

+0

第一行是有效的语法。其他的是明显无效的语法。我不做ADF,但是这个问题表明与PrimeFaces''有相同的理由:http://stackoverflow.com/questions/8207325/display-image-from-database-with- pgraphicimage/12452144#12452144 – BalusC 2013-03-13 12:44:05

回答

0

没有指定 JSF EL版本,所以这里是一个 JSF2 EL2.2片段那将起作用:

source="#{pageFlowScope.ImagesBean.imageUrlPair.get(entity.displayName)} 
+0

我使用JSF 1.2,这个#{pageFlowScope.ImagesBean.imageUrlPair.get(entity.displayName)}在get() – Rhiya 2013-03-11 23:18:22

+0

上给我一个语法错误。这个特性是特定于EL,而不是JSF:http: //stackoverflow.com/a/8326551 – BalusC 2013-03-13 12:42:21

0

从你的问题来看,如果你迭代地图或列表,如果它是一张地图,然后尝试下面的代码,如果它是一个列表,那么它对我来说看起来不错,这是不清楚的。

<af:image id="i2" source="# {pageFlowScope.ImagesBean.imageUrlPair 
[entity.value.displayName]}" 
     shortDesc="user info" inlineStyle="width:50px;height:50px;"/> 
0

尝试source="#{pageFlowScope.ImagesBean.imageUrlPair[entity.dataProvider.displayName]}"