Win a copy of Head First Android this week in the Android 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

EL basic

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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").
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all; I nearly figured that out.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
You showed up just in time for the waffles! And this tiny ad:
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
reply
    Bookmark Topic Watch Topic
  • New Topic