【问题标题】:dynamic El expression evaluation in map地图中的动态 El 表达式评估
【发布时间】:2013-03-11 21:59:32
【问题描述】:

我有一个 bean,它返回键值对 (String,String) 的映射。在我的 jsff 中,我需要根据 key 访问地图的值,这是一个动态 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']}

请帮帮我

【问题讨论】:

  • imageUrlPair的类型是什么?
  • 第一行是有效的语法。其他是明显无效的语法。我不做 ADF,但这个问题表明与 PrimeFaces &lt;p:graphicImage&gt; 这里解释的理由相同:stackoverflow.com/questions/8207325/…

标签: jsf map el oracle-adf jdeveloper


【解决方案1】:

您的问题不清楚您是否遍历地图或列表,如果是地图,请尝试以下代码,如果是列表,那么它对我来说看起来不错。

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

【讨论】:

    【解决方案2】:

    你没有指定 JSF EL 版本,所以这里有一个 JSF2 EL2.2 sn-p 可以工作:

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

    【讨论】:

    • 我使用的是 JSF 1.2,这个 #{pageFlowScope.ImagesBean.imageUrlPair.get(entity.displayName)} 在 get() 处给我一个语法错误
    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2014-06-21
      • 1970-01-01
      • 2020-04-06
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-15
      相关资源
      最近更新 更多