wood burning stoves
The moose likes JSP and the fly likes EL questions? object method access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "EL questions? object method access" Watch "EL questions? object method access" New topic

EL questions? object method access

Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
If I have a bean that wraps around a map, and has two methods: getValues and getKeySet, would I be able to do
and call the getValues() method? Or does it look for an actual, physical bean property?
Kevin Jones
Ranch Hand

Joined: Oct 29, 2003
Posts: 39
If you have a bean that has a getValues method then ${something.values} will give you whatever getValues returns. Depending on how this is used it may or may not be useful to you. looking at Map, the values() method returns a collection, so if you pass the result of ${something.values} to a tag that is expecting a Map then you will be golden. However if you simply output the value of ${something.values} to the page (in a JSP 2.0 page), then the EL will call toString on the value returned and you will probably get the Object.toString() value printed out.
If you want access to the values or keys of the Map then use the forEach tag from the JSTL.

Kevin Jones<br />Author: <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321136497/jranch-20" target="_blank" rel="nofollow">Servlets and JSP: The J2EE Web Tier</a>
I agree. Here's the link: http://aspose.com/file-tools
subject: EL questions? object method access
It's not a secret anymore!