[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

"Notify Property Change"

I was created a bean which has two properties called provider and algorithm. I was created the tag property editors for both the properties. The property provider takes values "sun","DSTC". The property algorithm takes values "DSA","RSA","DH" etc. The provider "sun" is providing algorithms "DSA","RSA". and The provider "DSTC" is providing algorithms "DSA","RSA","DH". Here my problem is When ever I set the provider property as "SUN", the algorthm property should show only "DSA" and "RSA". If i changed my provider property as "DSTC", The algorithm property should contain values "DSA","RSA","DH". How can i notify the one property change to other of the same bean.Please remember that i used  tag editors for the both the properties. Please help me as early as possible.
0
ksreddy
Asked:
ksreddy
  • 13
  • 11
1 Solution
 
heyhey_Commented:
my answer is - 'you can't implement this with property editors'

properties are supposed to be 'independent'

you can probably implement it using Customizer.
0
 
ksreddyAuthor Commented:
In customizer interface we had a function called setObject(Object bean). From which we can get the bean reference. Is there any way to get the object reference in propertyEditors.
0
 
heyhey_Commented:
Property Editor is supposed to edit some property i.e. some kind of data / object.

you should be able to use the same Property editor when you edit property of the same 'type' on some other Bean.

so - the answer is clear. no

properties are independent entities. they don't know anything about the Bean or some other properties of the same bean

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ksreddyAuthor Commented:
What is the use of listeners support in the editors.
0
 
heyhey_Commented:
usually the builder tool creates new Editor, sets its value using setValue() (that is the value of the property - as far as I remember, you'd better make a copy of this information) than registers listener to your editor and when it detects property change it asks the editor for the new value (using getValue()) and sets it to the Object.

debugging property-editor was one of the most painfull experiences ...

if you don't make a Copy of the Value, you'll have the real Propertiy object, which may have a reference to its's bean, so in theory, you can manipulate directly the bean. practicaly - it probably won't work in all the 'builder tools' and is very DANGEROUS.


0
 
heyhey_Commented:
>> if you don't make a Copy of the Value

the enviroment will probably call
editor.setValue(obj) with the real property object that is party of the bean. you'd better make a copy of this information (otherwise, you'll act directly on the Bean object which is highly unrecomeneded). when the user changes the value of the property inside your property editor, you should fire PropertyChangeEvent - the enviroment will ask your editor about the new value of the property and use the appropriate set method of the bean.
0
 
ksreddyAuthor Commented:
For a single bean howmany customizers we can have?
0
 
heyhey_Commented:
as far as I remember - one


'public interface Customizer
A customizer class provides a complete custom GUI for customizing a target Java Bean.
Each customizer should inherit from the java.awt.Component class so it can be instantiated inside an AWT dialog or panel.
Each customizer should have a null constructor.'

'public class BeanDescriptor
extends FeatureDescriptor
A BeanDescriptor provides global information about a "bean", including its Java class, its displayName, etc.

 public Class getCustomizerClass()
Returns:
The Class object for the bean's customizer. This may be null if the bean doesn't have a customizer.'


0
 
heyhey_Commented:
you have a lot of questions :)
0
 
ksreddyAuthor Commented:
Thank you. what was the design logic behind this. Like the customiser geting the reference of Bean, why are the property editors not passed this reference..
0
 
ksreddyAuthor Commented:
I would like to know background design of the beans. Books does not providing the complete information about internals of beans. They dont give internal details
0
 
ksreddyAuthor Commented:
I would like to know background design of the beans. Books does not providing the complete information about internals of beans. They dont give internal details
0
 
heyhey_Commented:
properties have 'types' (in fact as far as I remember 'type' = 'Java class')

you may have a lot of beans that have propery (or even more than one property) of the same type - for Example - java.awt.Color.

so you can implement nice ColorEditor, but this editor is supposed to edit only the property value (the Color) - it does not know what's the current bean, and can't (at least SHOULD not) interact directly with the bean.

Customizer is Component that is responsible for editing the whole bean at once.

the simplest workaround (in you case) is to use a single property editor (combo)with values


Sun DES
Sun RSA
DSTC DES
...

as you can see my English is quite bad :(, so I can't present the whole architecture (I even don't know it quite well). all these opinions are based on personal experience / not a single book.

0
 
ksreddyAuthor Commented:
What is the use of the beancontext. How can we use that?
0
 
heyhey_Commented:
7 questions.

I don't know what is beancontext.
and I don't have any documentation at the moment.
0
 
ksreddyAuthor Commented:
What is the use of the beancontext. How can we use that?
0
 
heyhey_Commented:
I have posted enought information for 100 points.
and I've described one solution + one workaround of your problem.

it's time for answer.
0
 
ksreddyAuthor Commented:
Adjusted points to 200
0
 
heyhey_Commented:
> How can i notify the one property change to
> other of the same bean.

you CAN'T

use single property editor with all the pairs
Sun DES
Sun RSA
DSTC DES
...

That's you ANSWER.
0
 
ksreddyAuthor Commented:
I would like to know the complete architecture of the bean? How the listeneres are working? What is the bean context? where it was used?
0
 
heyhey_Commented:
ok
take a look at the Java Beans specification first.
that's where the 'bean architecture' is defined'

http://java.sun.com/beans/spec.html
0
 
heyhey_Commented:
if you have more questions, I'll be glad to help you.
0
 
peter_bCommented:
hahaha LOL !
0
 
ksreddyAuthor Commented:
What do you ment by hahaha LOL !
0
 
heyhey_Commented:
      > How can i notify the one property change to
       > other of the same bean.

       you CAN'T

       use single property editor with all the pairs
       Sun DES
       Sun RSA
       DSTC DES
       ...

       That's your ANSWER.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 13
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now