0

I have a bean which returns me map of key-value pairs ( String,String) . In my jsff, I need to access the map's value based on key which is a a dynamic El expression

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

I am unable to evalue the key for the map. I tried,

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

However , this works

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

Kindly help me

Rhiya
  • 251
  • 5
  • 21
  • What is the type of imageUrlPair? – Simon Arsenault Mar 12 '13 at 00:03
  • The first line is valid syntax. The others are plain invalid syntax. I don't do ADF, but this problem suggests to have same grounds as explained for PrimeFaces `` here: http://stackoverflow.com/questions/8207325/display-image-from-database-with-pgraphicimage/12452144#12452144 – BalusC Mar 13 '13 at 12:44

3 Answers3

0

You didn't specify JSF EL version, so here's a JSF2 EL2.2 snippet that will work:

source="#{pageFlowScope.ImagesBean.imageUrlPair.get(entity.displayName)}
Simon Arsenault
  • 1,487
  • 18
  • 33
  • I am using JSF 1.2 , this #{pageFlowScope.ImagesBean.imageUrlPair.get(entity.displayName)} gives me a syntax error at get() – Rhiya Mar 11 '13 at 23:18
0

It is unclear from your question if you iterating over a map or list , if it is a map then try the below code , if it is a list then it looks good to me.

  <af:image id="i2" source="#  {pageFlowScope.ImagesBean.imageUrlPair
[entity.value.displayName]}"
        shortDesc="user info" inlineStyle="width:50px;height:50px;"/>
Avinash Singh
  • 2,564
  • 1
  • 14
  • 20
0

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

Billy Bob Bain
  • 2,754
  • 14
  • 12