• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

El question in HFSJ - Page 380

 
Ram Gokul
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have questions about EL . should the [] contain "" or not ?
Page 375 says tat if there are no quotes inside brackets , container evaluates by searching for an attribute.
But for drop magnet question in Page 380 , toys[1].name is given as the correct answer. I was expecting toys["1"].name since without "" , container would start searchnig for an attribute.
And book also warns that rules of java generally dont apply to EL .So I thought , plain Java array addressing of toys[1].name cannot be inside a ${} expression.

Can someone clarify this ? Thanks
 
Alankar Yannam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ram,

You can use either way, both toys[1].name or toys["1"].name works. Index can be used with quotes or without quotes for List and Array objects. Here getToys returns array of Toy objetcs. You can see the details on page 372.

Hope this helps.

Alankar Yannam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic