Solved

PropertyDescriptor - getting declared field names

Posted on 2007-03-30
2
441 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

749 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