javaspringdata-bindingaspects

Is there a data binder using aspects and annotations?


I want to write a java application using swing, spring and hibernate.

I want to use a data binder to populate the gui with the values of a bean, and I also want it to reflect updates of the bean in the gui.

It seems there is a way to do that in spring, using the DataBinder, but as far as I understand you need to implement the property-change code in the beans yourself, and you need to connect the properties of the bean to the setter methods of the gui using strings which I dislike.

I came across this to prevent the manual implementation of the property-change support in the beans:

https://github.com/damnhandy/Handy-Aspects

Now I'm looking for a data binding framework that I can use together with this, which also supports annotations to minimize and ease the configuration of the binder.

I would hope that I can annotate the setters of the gui with an annotation which takes the name of the property - or, even better, if it has the same name like the property, it wires up automatically.

For example, if I have a Person class with properties name and age, I would like to configure the gui like that:

@GUI
public class PersonGui{

    [...]

    @BoundField
    public void setName(String name){
        ...
    }

    @BoundField(property="age")
    public void setTheAge(int theAge){
        ...
    }

}

Is there anything like this?


Solution

  • I wrote a library that uses spring data binding for Swing using the "same name convention".

    Sample code is in https://github.com/chelu/jdal-samples/tree/master/library

    Maybe you are interested on trying it.