J2V8 icon indicating copy to clipboard operation
J2V8 copied to clipboard

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

Open bing0ye opened this issue 5 years ago • 3 comments

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.

bing0ye avatar Aug 02 '20 05:08 bing0ye

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

gintsgints avatar Nov 30 '20 06:11 gintsgints

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

stephanepechard avatar Aug 22 '23 07:08 stephanepechard

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

caoccao avatar Aug 23 '23 02:08 caoccao