Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Doubt - EL

 
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 ]
 
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.
 
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.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic