Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java Bean help

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
I have a 40 java bean each with about 20 -30 different get and set methods.
I want to get the names and values of all the methods in one bean at a time .
And then reformat that data.Is there any thing similar to jdbc getMeataData where you get column name s and it's values. I want to avoid writing 20-30 getProperty statements.
Any help is highly appreciated.
Thanks,
peter
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like reflection.
Check out myBean.getClass().getMethods() which will return an array of java.lang.reflect.Method objects representing all the public methods defined in myBean. You can then walk thru them and test their names, parameters, return types, etc.
You can even use method.invoke() to run the methods.
Check out Sun's reflection tutorial
http://java.sun.com/docs/books/tutorial/reflect/index.html
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also download the Beanbox prototype tool from Sun. It has a Report feature that not only lists all the property-oriented methods in a Bean, but also groups the listings between Properties, Event Sets, and other methods. It also tags expert options and a few other things. It's part of the BDK which is available here.
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to both of you for all your help.
could you please help me what should i add to what i have now( i am going thorough the documents but it will take little long for me to get it to work)

Thanks,
peter
--edited for code format and capitalization. mfe --
[ November 15, 2002: Message edited by: Michael Ernest ]
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic