This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes What is Correct EL Syntax for ArrayList Bean Property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "What is Correct EL Syntax for ArrayList Bean Property" Watch "What is Correct EL Syntax for ArrayList Bean Property" New topic
Author

What is Correct EL Syntax for ArrayList Bean Property

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
The following gives the error:

E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: An exception was thrown by one of the service methods of the servlet [/Sampling/SamplingInspectionItemFaxFormV6.jsp] in application [QMSWebAppEAR]. Exception created : [javax.el.MethodNotFoundException: java.lang.NoSuchMethodException: java.util.ArrayList.get(java.lang.Long)

The bean property is an ArrayList<String> with two elements, '100','true'

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Point #1: A List seems like a spectacularly poor way to model the data. Why isn't it a bean, or at worst a Map, that associates key names with the values? Using position 1 in a List to represent a value is a really poor way to do things. The data is clearly not a list, and using magic numbers into the list to represent disparate values is not acceptable.

That said, Point #2: the notation would be ${sidocObj.samplesizedata[1]} assuming samplesizedata is the list. But don't do it this way; see above.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Bear Bibeault wrote:Point #1: A List seems like a spectacularly poor way to model the data. Why isn't it a bean, or at worst a Map, that associates key names with the values? Using position 1 in a List to represent a value is a really poor way to do things. The data is clearly not a list, and using magic numbers into the list to represent disparate values is not acceptable.

That said, Point #2: the notation would be ${sidocObj.samplesizedata[1]} assuming samplesizedata is the list. But don't do it this way; see above.


Thanks Bear. I created bean properties as you suggested.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

That'll keep the code much more readable and clear. :thumbup:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Correct EL Syntax for ArrayList Bean Property
 
Similar Threads
Struts display:column when/otherwise
value of boolean set in bean in jstl
What's wrong with this JSP code?
At the same request property is instantiated and becomes null. Why?
Copy and past link problem