| Author |
Display ArrayList size using JSTL?
|
Thomas Autera
Greenhorn
Joined: Nov 10, 2003
Posts: 14
|
|
Hello All, I am trying to display an ArrayList size. The ArrayList has been stored as a request attribute called "units". When I used the fmt syntax below I get an error. <fmt:formatNumber value="${units.size}" type="number" pattern="###,##0" /> Here's the error: An error occurred while evaluating custom action attribute "value" with value "${units.size}": 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. (null) Thanks lots for your time and expertise! Tom
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56167
|
|
Since the size() method of the object is not bean-patterned, in which case it would be getSize(), it is not accessible via the EL. If you are using JSP 2.0 and JSTL 1.1, there is a JSTL function to obtain this value. Under JSP 1.2 and JSTL 1.0, if you need this value on-page, your servlet controller will have to set it as a separate scoped variable.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Thomas Autera
Greenhorn
Joined: Nov 10, 2003
Posts: 14
|
|
Bear, Thanks for your input. I am using JSP 1.0 and JSTL 1.1, but I have decided to generate another request attribute containing an Interger object, which will have the number I'm looking to display. I did not know JSTL functions existed until you mentioned them. The book I have "JSTL IN ACTION", does not mention JSTL fucntions. Thanks for the education! I did find some more info on the same issue I am running up against where the fellow that posted was wrestling with the same issue.: http://forum.java.sun.com/wireless/thread.jsp?thread=511513&forum=45&message=2434169 Again thanks for your help and time! Tom
|
 |
Thomas Autera
Greenhorn
Joined: Nov 10, 2003
Posts: 14
|
|
Sorry correction see bold: Bear, Thanks for your input. I am using JSP 2.0 and JSTL 1.1, but I have decided to generate another request attribute containing an Interger object, which will have the number I'm looking to display. I did not know JSTL functions existed until you mentioned them. The book I have "JSTL IN ACTION", does not mention JSTL fucntions. Thanks for the education! I did find some more info on the same issue I am running up against where the fellow that posted was wrestling with the same issue.: http://forum.java.sun.com/wireless/thread.jsp?thread=511513&forum=45&message=2434169 Again thanks for your help and time! Tom
|
 |
 |
|
|
subject: Display ArrayList size using JSTL?
|
|
|