Javabean 101 13

zhaozj2021-02-11  182

Javabean 101, Part 2 (3)

Author: Translation: Liaozheng Date: March 8, 2001

Add attribute

In the previous course, demonstrate how to add simple properties into the bean, and how to compile and test in Beanbox. In this section, we learn how to implement other types of properties in the bean, including:

Association (binding) attribute constraint properties

These types of more complicated properties require the ability to communicate with each other between the beans. Recalling that we have learned in front, Beans use events to communicate with each other. A source bean sends events, and one listening bean can accept or process the event once it is registered in the source bean.

Association property

The association property enables the JavaBean to notify another JavaBean when a value value in the JavaBean changes. For example, you have designed a button in a javabean. Once the button is pressed, another bean can display some information.

Once a bean is changed, other beans are notified, which requires a communication mechanism. This communication mechanism is made through an event. Once the associated property is changed, the event will be sent. These events are called attribute change events.

Once you set an associated property, you also set other beans to a listener that is interested in the change of the associated properties. Later, once the value of the associated attribute of the first JavaBean changes, the notification will be sent to beans that appear as the identity of the listener that is interested.

Let's take a look at the bean named myButton, which uses the associated property. MyButton contains the code of the BEAN of interest once attribute changes. Once we have written myButton, you can set a listening bean to respond to changes in properties in MyButton.

转载请注明原文地址:https://www.9cbs.com/read-4753.html

New Post(0)