eclipsesource / J2V8

Java Bindings for V8
2.55k stars 355 forks source link

How to bind a JAVA object's property to a javascript object's property #522

Open bing0ye opened 4 years ago

bing0ye commented 4 years ago

Such as, there is a Java class like

class Screen {
    private double _width;
    public double getWidth {
        return _width;
    }
    public void setWidth(width) {
        _width = width;
    }
}

I want to bind a Screen object to javascript, and use like "screen.width = 200.0;" in the javascript environment. The Java Object method "setWidth" method is called When the assignment occurs. How to implement it? I will glad to receive your answer.

gintsgints commented 3 years ago

I am also interested in this. Some example would be very nice.

stephanepechard commented 1 year ago

Hi, Also need this at the moment, did anyone find a way to do this? Thanks

caoccao commented 1 year ago

It's not implemented in J2V8, I suppose. If you really want that feature, you may try Javet that allows @V8Property.