Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable Method names

 
Yo Bagus
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if there's a way to do something like this:

MyObject = [an object with 'getDescription()' method]
String methodName="getDescription()";
String description= MyObject.methodName;

In java or jstl or with El, whatever.

Thank you!
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the Java Reflection API. If I understand your question, you can do what you are looking to do using reflection. Java Reflection in Action does a nice job of covering the API. Chapter 1 is available as a sample chapter download at the publishers website: http://manning.com/forman/. It will allow you to get up an running.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic