wood burning stoves 2.0*
The moose likes JSP and the fly likes Display ArrayList size using JSTL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Display ArrayList size using JSTL?" Watch "Display ArrayList size using JSTL?" New topic
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: 60780
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display ArrayList size using JSTL?
 
Similar Threads
schema error : undefined value for 'type' encountered
Error when using Map.values() in dataTable
how to do submit the Dynamic produced element in Struts
size of the list
Doubts regarding ArrayLists