Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBean: Correct use of firePropertyChange  RSS feed

 
Michael Erskine
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to JavaBeans and within my sockets comms beans I use propertychange events to notify other beans of things like the arrival of a new message. I find that in order to get my propertychange events to occur when the message is the same as the previous message, I have to lie about the old value (because it is the same string). I use this technique...

Now, am I breaking any of the rules of property change support? Should I be using another technique to tell interested parties about a new message?
Thanks for your patience,
Michael.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
I feel pretty sure that anyone who has used Beans or Observer to any extent has been confronted with this dillema. I have done the same thing that you are doing countless times and see absolutely no problem with it. Many times, you may have a stateless pseudo-property (ie not actually defined in any bean), which would be tantamount to an event, that you need to notify the listeners about. So don't fret over the need to, as you put it , lie to your beans.
Hope this helps,
Michael Morris
 
Michael Erskine
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Michael,
I'm rather new at this and I tend to use bean property change events to raise events as they are automatically created and wired with NetBeans.
Thanks again,
Michael
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"msemtd" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!