Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL - get method not found error  RSS feed

 
Ariel Valentin
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code...


Produces the following error:

Is using a get method with a parameter a limitation of EL?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a "limitation" of the JavaBean specification. Property accessors must have no arguments.
[ February 20, 2005: Message edited by: Bear Bibeault ]
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure. Maybe you made a mistake?

class A{
private HashMap myHash = new HashMap(); // !!!property is private
//... make pretend myHash is populated with assorted ArrayList types
public ArrayList getPropertyValue(String name){
return (ArrayList) myHash(name);
}
}
//...
//...
<c: out value="${applicationScope.a.myHash['MyKey']}" /> <!-- will not work
maybe you wanted to do this: -->
<c: out value="${applicationScope.a.propertyValue('MyKey')}" /> <!-- will not
work either -->

Yes, there are some limitations.
Possible simple solution:

class A{
private HashMap myHash = new HashMap();
public HashMap getMyHash (){
return Collections.unmodifiableMap(myHash);
}
}
<c: out value="${applicationScope.a.myHash['MyKey']}" />

I think this should work
[ February 20, 2005: Message edited by: Eugene Lucash ]
 
Ariel Valentin
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear and Eugene,

Thank you for your responses and in fact you are both correct. My original c ut was a typo (thanks for catching that) I meant to write a.propertyValue['key'] which would not work because I my intention is to retrieve the ArrayList not the map. Makes sense to return the entire map and the iterate through the list in this case.

Thanks Again
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!