Dean Pullen wrote:
> Seeing the replies that have been posted in the last few days, I'm
surprised noone is able to help with this? :(
>
> On 13/03/06, Dean Pullen <[EMAIL PROTECTED]> wrote:
>> Still not made any progress with this, and having looked through the
achieves a few times I still haven't made any head way :-/
>> I need to get hold of the current row object's key, but only the
current row/bean's properties are accessbile. Surely there must be away
using the EL to get the key?
Dean:
I think the sad reason for that is that there is no direct easy way to get
the key that you want. For a nice graphic illustration, I've attached a
hideous JSP file that I cooked up to show the various attributes available
in all scopes.
Note that the technique I use in here, of enumerating all of the
attributes from every scope available, is actually useful in more than
just this situation. It can be really helpful to figure out why you are
or are not seeing particular results from EL. I use it an awful lot.
Anyways, there's a Map containing Acegi User objects (this just happened
to be a POJO I had available on the classpath, you can substitute whatever
you want for illustration). These are stored in the map by a key
unrelated to the bean names or propety values or anything. If you look at
the huge Objects column, you'll see that the only place that those names
(object1, object2, etc.) show up is in the map itself.
But this also contains a work around that you can use to get the key for
the current row. There are a number of caveats:
* You have to do some pre-processing. This is where I grab the map keys
and convert them into a list, then set that as a request attribute:
List<String> keys = new ArrayList<String>(map.keySet());
request.setAttribute("keys", keys);
* You can then reference the list with an EL expression using the
item_rowNum attribute. You have to subtract one, since the list is
0-based and the iteration counter is 1-based:
${keys[item_rowNum - 1]}
So there is no implicit object generated for the Map key. You just have
to jump through some hoops to get it yourself.
This would actually be a nice thing to have, so that if the named object
is a Map, create an extra implicit object called name_key, just like
name_rowNum. This would be cool for IDs, anchors, other things like
that...
--
Rick Herrick
[EMAIL PROTECTED]
I haven't got time for inner peace.
"No reasonable definition of reality could be expected to permit
this."--Albert Einstein, Boris Podolsky and Nathan Rosen in 1935
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user