adam bien's blog

Netbeans 6.1rc1 - nice, indirect support for Eclipse / Netbeans RCP DataBinding (for the model layer) 📎

Proprietary Eclipse RCP as well as JSR-295 (Beans Binding) databinding frameworks require the realization of PropertyChangeSupport in the "model" entities. Otherwise changes in the JPA-layer wouldn't be automatically propagated to the UI.

Netbeans 6.1rc1 is able to generate the properties,  the PropertyChangeSupport (listeners) as well as the accessors for you. You only need to enter the key-combination "Alt+Insert" and choose the "Add Property" option.  In the popup select the option "Bound" - this will activate the generation of the PropertyChangeSupport.

 

For the generation of the following code (except the annotations and the class declaration) I had only to execute the wizard twice. Onces for the "name" and second time for the "description" attribute.

 

@Entity

public class Entity {

   

    @Id

    protected String name;

    protected String description;

   

    private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport();;

   

    public static final String PROP_DESCRIPTION = "description";

    public static final String PROP_NAME = "name";

   

    public String getDescription() {

        return description;

    }

 

    public void setDescription(String description) {

        String oldDescription = description;

        this.description = description;

        propertyChangeSupport.firePropertyChange(PROP_DESCRIPTION, oldDescription, description);

    }

    public String getName() {

        return name;

    }

 

    public void setName(String name) {

        String oldName = name;

        this.name = name;

        propertyChangeSupport.firePropertyChange(PROP_NAME, oldName, name);

    }

}

 

Of course Netbeans 6.1RC1 is able to generate the whole code for you from the database with UI, binding and persistence. To try this, just use in the new project wizard the option "Desktop Application -> Database Application" and choose an existing table from the database.