How to create sub properties within a Bean??

I have been looking for some info about this topic but still nothing. I'm creating a JavaBean with two properties but one of them depends on the other one, so if the first one has a value 'false' the other one should be disabled but the problem is that i don't know how to do that!!! Since I'm using Sun One IDE i have notice that for example, when you create a JForm, within the properties sheet, into the Code tab, if I change the form size policy, some extra properties appear, so I guess it can be done for any other property, like a enable/disable, but as I mentioned I don't know how to do it. Can someone give some help, give one example, or put me in the right direction at least???
drodalejoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Maybe they're properties just setting other properties when a PropertyChangeListener fires?
0
Giant2Commented:
propertyA with values a,b,c,d
propertyB with values true or false (true if propertyA is a or b, false otherwise)

Your bean code could be like:
getPropertyA(){
return propertyA;
}

getPropertyB(){
if (propertyA==a || propertyA==b) return true;
return false;
}

On the client side you must follow what CEHJ told before. Here is an example:
http://www.javaworld.com/javaworld/jw-06-1998/jw-06-beans-p3.html

Bye, Giant.
0
drodalejoAuthor Commented:
Ok guys! I appreciate your interest in my problem, so i'm going to use the example gived by Giant to illustrate what I have. As in the example, I have:

propertyA with values a, b, c, d
propertyB with valules true or false

(if propertyA is a or b, propertyB could be true or false, but if propertyA is c or d, propertyB must be false)

so, in order to do this,

propertyA fires a propertyChange
propertyB fires a vetoableChange

i have the listeners and the needen code to handle each event; i have created my bean and when I test it into the beanbox everything is fine, I mean:

a) if propertyA is a or b i can change propertyB to false or true
b) if propertyB is false and propertyA is c or d, i cannot change propertyB to true (it's vetoed)
c) if propertyB is true and propertyA is a or b, but I change propertyA to c or d, automatically propertyB change to false (as expected) due to the propertyChange used

in conclusion, everything works as I wish. the problem is that when I load my bean into Sun One 4 or Java Studio 8 i get a different behaviour, i mean:

a) if propertyA is a or b i can change propertyB to false or true
b) if propertyB is false and propertyA is c or d, i cannot change propertyB to true (it's vetoed)

BUT....

c) if propertyB is true and propertyA is a or b, but I change propertyA to c or d, propertyB doesn't change to false or at least this new value is not reflected into the properties view.

Any ideas???
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Giant2Commented:
Seems a refresh problem
0
drodalejoAuthor Commented:
I'm agree with you because if i click on any other component and then i click again my bean the properties sheet displays the correct values for the two properties...

So, is there a way to programatically refresh the properties sheet?? or am i missing something into my bean??

I have tested my bean with the beanbox and Netbeans getting the desired behaviour, but with SunOne 4 and Java Studio Enterprise 8 i cannot say the same.

0
Giant2Commented:
See here:
http://java.sun.com/docs/books/tutorial/javabeans/properties/constrained.html
at "Write a property's setter method to fire a property change event when the property is changed."
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.