?
Solved

PropertyDescriptor - getting declared field names

Posted on 2007-03-30
2
Medium Priority
?
509 Views
Last Modified: 2008-02-26
Hi Experts,

If I use PropertyDescriptor, is there any way that I can get declared field names (not setter/getter method names)?

PropertyDescriptor pd[] = PropertyUtils.getPropertyDescriptors(aForm);

aForm is ActionForm and I want to get all the fields in that class.

thx,
0
Comment
Question by:dkim18
2 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 1000 total points
ID: 18825542
Declared field names will be private. You will have to derive the names I guess. Obtain a list of all getters. If a method is called getName (), then remove out the 'get' and change the case of the first character to make it 'name' and that would be the name of the property. Same way, for boolean properties, it could be like isValid ()
0
 

Author Comment

by:dkim18
ID: 18825838
I used getName() and I got what I wanted. Somehow, I applied getName() by using java.lang.reflect.Method variable and getting method name and I was wondering. My bad...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question