Results 1 to 5 of 5
- 01-12-2011, 02:15 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
JSTL accessing properties on an object that extends ArrayList
I have an object that extends ArrayList and adds a bunch of properties (like title).
When I do this
<c:forEach items="${linkSet}" var="link" varStatus="status">
${linkSet.title}
</c:forEach>
I get this error :
<Error 500: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
Which implies that JSTL is treating "title" as an index value to get a value from the List - i.e. it's treating my extended List object as a simple List object.
Is there anyway to get JSTL to see it as a property on an the extended List object and not an index on the underlying List class ?
- 01-12-2011, 03:13 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Not too sure extending ArrayList is the right idea, though I agree that it does appear that . is acting like [] here, which I hadn't noticed before.
My suggestion is that your extended class should actually have an ArrayList as an attribute, and not extend ArrayList.
- 01-12-2011, 03:57 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
Well, yes, I had thought of that. Except that this is an old and large code base being extended. This class is used all over the place, so re-factoring is not a small thing to do... was hoping to avoid that.
- 01-12-2011, 03:59 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Ah, an old mistake.
So this is just a new JSP then?
Could you wrap the extended List into another object at the start of the JSP (with a note)?
- 01-13-2011, 10:07 AM #5
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Iterate over Map object using JSTL
By syncFool in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 10-21-2010, 06:25 AM -
Finding an object of given properties in an ArrayList
By sonny in forum New To JavaReplies: 5Last Post: 05-17-2010, 01:13 PM -
Accessing Properties File
By java_men in forum Java ServletReplies: 0Last Post: 05-11-2010, 11:34 AM -
add object to ArrayList (object is from extends other class)
By mBull in forum Java AppletsReplies: 3Last Post: 03-15-2010, 08:44 PM -
Accessing to file roots and their properties
By JVega in forum Advanced JavaReplies: 3Last Post: 01-25-2010, 12:25 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks