• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Mock] [EL]

 
Sam Sun
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Select 4 choices:

1. The "." operator is used to access bean properties.
2. The "." operator is used to access bean methods.
3. The "[]" operator is used to access bean properties.
4. The "." operator is a generation of the "[]" operator.
5. The "[]" operator is used to access objects stored in maps, lists and arrays.
6. The "." operator cannot be used to access objects stored in maps, lists and arrays.


The answer is: 1, 3, 5, 6

I have question on choice 6. I think the "." operator can be used to access objects stored in maps. We can take a look at HF book page 423 exercise 15 choice D.

params is a property of myBean and it's a java.util.Map type.
D. ${myBean["params"].a} is correct. This "." operator is used to access objects stored in maps.

Please update me.
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the dot operator can not always be used for accessing the objects stored in the Maps. This is the case when the key to an object stored in a Map is not a valid identifier....

e.g. map.putValue("1","Integer");

Here the key is 1, now if you try to access it from an EL expression it would be ${map.1}, which is not correct...

hope you understand my point....

Regards

Sushma
 
Sam Sun
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic