Monday, July 16, 2007

Accessing dotted attributes from JSTL EL

One of my friends was in trouble with accessing scope attributes from JSTL expression language.
He wanted to use <c:out value="${myDomain.myObject}"></c:out>, to access an object under the key of "myDomain.myObject"

EL tries to retrieve an object under the myDomain key and then tries to invoke getMyObject() on that object. Obviously that wasnt working.

There is no standart way of accessing such attributes. But if you know which scope your object lives in, you can access like this.

<c:out value="${sessionScope['myDomain.myObject']}" />

A while ago Gavin King blogged about his EE6 wishlist, i add this one to my wishlist...

No comments: