Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observable property - feature request #78

Closed
jvmlet opened this issue Sep 9, 2014 · 5 comments
Closed

Observable property - feature request #78

jvmlet opened this issue Sep 9, 2014 · 5 comments

Comments

@jvmlet
Copy link

jvmlet commented Sep 9, 2014

Hi
Would you please add "Observable property" feature by invoking firePropertyChange in generated setter method?
This also requires to generate addPropertyChangeListener and removePropertyChangeListener methods ,plus PropertyChangeSupport field.

This could be controlled by extending @PropertyDefinition with "observable=true" attribute.

Thanks
Alexander

@jodastephen
Copy link
Member

An interesting thought, which I assume is for swing? I haven't used swing myself in a while, and adding this does add complexity, but it is a natural project extension.

@jodastephen
Copy link
Member

I had a look at doing this. It gets quite tricky relatively quickly. Joda-Beans has many different ways to generate a setter. In theory, to make this change work, all those ways would need a parallel observable version, and the current code structure isn't especially amenable to that.

Making it work for just simple setters would not be too hard I suspect.

jodastephen added a commit that referenced this issue Oct 9, 2014
@jvmlet
Copy link
Author

jvmlet commented Oct 29, 2014

which I assume is for swing?

Actually, I'm working with Vaadin which intensively uses "property" pattern for binding.
Currently trying to implement Vaadin's Property over joda-beans generated properties.. looks promising.
According to "change" notification - it will be much cleaner to get notification event from model bean rather than from UI component.

Waiting forward for the next release with Listener support.
Thanks for your work.
Alexander

@reggiepierce
Copy link

Hi All,

I'd like to second this request for use in Vaadin. I'd be glad to help any way I can. I'm assuming that it could be done via something in the generated setter, and perhaps defined with an annotation?

    @PropertyDefinition(validate = "notEmpty", notifyOnSet=true)
    private String userId;

public void setUserId(String userId) {
        JodaBeanUtils.notEmpty(userId, "userId");
        this.userId = userId;
        //this would have to be generated
        firePropertyChange("userId");
    }
'''

jodastephen added a commit that referenced this issue May 17, 2015
jodastephen added a commit that referenced this issue May 17, 2015
Add basic support for bound properties
Implementation only handles non-final properties
See #78
@jodastephen
Copy link
Member

Basic support for bound properties added, intended for simple mutable properties only:

@PropertyDefinition(set = "bound")

The PropertyChangeSupport field is generated, but not the add/remove listener methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants