A question about Java Bean!
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Joe_Xiao
Posted On:   Tuesday, May 28, 2002 06:40 PM

There is a java bean named User.java, and it has some attibutes. e.g userName (String), birthday (Date), IdNumber (String). That is to say there are getter and setter methods of these 3 fields in User.java. now, in another java class--- Test.java, I want to retrieve User.java object's attributes and its object values. The object values maybe String and maybe Date type. I can get all methods and fields from User.java. But when I want to get the value of the field, i puzzled. for example, In Test.java, I can find an attribute of User.java named birthday, they are Method[] array, and can to String ---"public java.lang.String User.getBirthday()". now , i want to retrieve the relevant birthday object value which is    More>>

There is a java bean named User.java, and it has some attibutes. e.g userName (String), birthday (Date), IdNumber (String). That is to say there are getter and setter methods of these 3 fields in User.java.

now, in another java class--- Test.java, I want to retrieve User.java object's attributes and its object values. The object values maybe String and maybe Date type.
I can get all methods and fields from User.java.
But when I want to get the value of the field, i puzzled.
for example, In Test.java, I can find an attribute of User.java named birthday, they are Method[] array, and can to String ---"public java.lang.String User.getBirthday()".
now , i want to retrieve the relevant birthday object value which is a java.util.Date object. that is to say i want to call the User.getBirthday() method and return a java.util.Date object. I do not want to hard code that, i need a versatile method--- retrieve an attribute name, and auto call the relevant getXXX method and return the object(maybe String, maybe Date in this example).

how can i do that?

pls help me!

   <<Less
About | Sitemap | Contact