Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL basic

 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HF says the 1st thing in expression is either an implicit object or attribute. But in the following program-let, listElement used inside {} is a variable declared for custom tags.

<c:forEach var='listElement' items="{movieList}">
${listElement}
</c:forEach>

How do you generalize this concept of accepting the custom tag variable?

Thanks
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that variable must be placed as an attribute of some scope for the EL to read it. Play around a with the code a little to see if you can determine which scope holds the variable. What scope would make the most sense? Was the result of your testing what you expected?
 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand 'movieList' should be an attribute. And you are saying 'listElement' should be considered as an attribute because its one of the elements in movieList?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64970
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jibs parap:
And you are saying 'listElement' should be considered as an attribute because its one of the elements in movieList?
No. It might be helpful for you to grab a copy of the JSTL Specification and see what it says about the operation of the <c:forEach> tag with regards to the creation of scoped variables (what you have been calling "attributes").
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And don't forget to put the $ here : items="${movieList}"
 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all; I nearly figured that out.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
No. It might be helpful for you to grab a copy of the JSTL Specification and see what it says about the operation of the <c:forEach> tag with regards to the creation of scoped variables (what you have been calling "attributes").

In my book, scoped variable = attribute because any scoped (as in page, request, session, or application scope) variable is retrievable through a getAttribute method in the API.

The following jsp code (please forgive my scriptlets, Bear ) illustrates that the "var" from c:forEach does get saved as an attribute of some scope (aka scoped variable). I won't reveal which scope - our friend will need to try it out. That's the best way to learn.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic