• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt - EL

 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From HFSJ,

1) Page 377 in old edition

${musicMap["Ambient"]} is same as ${musicMap.Ambient}

What is the equivalent of ${musicMap[Ambient]}?

Please clarify.

2) Page 376 in old edition

Music is ${musicMap[MusicType[0]]} becomes Music is ${musicMap["Ambient"]}

What should i change in ${musicMap[MusicType[0]]} to make it refer${musicMap[Ambient]}?

Please clarify.
[ December 03, 2008: Message edited by: Shiaber Shaam ]
 
cesar valencia
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shiaber Shaam:
From HFSJ,

1) Page 377 in old edition

${musicMap["Ambient"]} is same as ${musicMap.Ambient}

What is the equivalent of ${musicMap[Ambient]}?

Please clarify.

if i recall correctly, there isn't equivalent. Ambient will evaluate to an attribute if it's not enclosed between quotes.


Originally posted by Shiaber Shaam:
2) Page 376 in old edition

Music is ${musicMap[MusicType[0]]} becomes Music is ${musicMap["Ambient"]}

What should i change in ${musicMap[MusicType[0]]} to make it refer${musicMap[Ambient]}?

Please clarify.

[ December 03, 2008: Message edited by: Shiaber Shaam ]

same as above, it wouldn't evaluate properly.

hopefully someone will correct me if i'm wrong.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

${musicMap["Ambient"]} is same as ${musicMap.Ambient}

What is the equivalent of ${musicMap[Ambient]}?
Please clarify.


Since Ambient is in quotes ${musicMap["Ambient"]} will
a) musicMap.getAmbient(); if musicMap is a Object following java beans naming convention.
OR
b) musicMap.get("Ambient"); Here "Ambient" will be used as key into the MAP refered by musicMap

${musicMap[Ambient]} -> Since Ambient is not in quotes , container will first look for a attribute with name "Ambient" in all the 4 scopes (page/request/session/context) in the given order and use the value of the attribute (that comes first) to process further.
For example if you have Ambient=Light in request scope then
${musicMap[Ambient]} = ${musicMap["Light"]}
${musicMap["Light"]} is further evaluated as explained above.


2)

Music is ${musicMap[MusicType[0]]} becomes Music is ${musicMap["Ambient"]}
What should i change in ${musicMap[MusicType[0]]} to make it refer${musicMap[Ambient]}?


${musicMap[MusicType[0]]} becomes Music is ${musicMap["Ambient"]}
because MusicType[0] has "Ambient".
You cannot change because the MusicType[0] will be treated as a String and never as "Search Attribute with this name in all 4 scopes".

${musicMap[expression]}: The result of expression will always be treated as a string.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic