I would like to get the time at which user have clicked the button. I am making my application offline. So when user clicks a button, i would like to use that time stamp.
Currently, I am able to write executeJs code which adds a attribute to the button with date time. is it possible to read this attribute in java? I tried
e.getSource().getElement().getAttribute(“click-at”)
but it’s returning null. on UI i see the value updated on dom.
The attribute and property values are not automatically synced to the server. There are couple of ways you can do this. If you are implementing a custom component you could use property instead of attribute and use getElement().addPropertyChangeListener(“click-at”, “event”, e → { … }); which listens to property change and synchronizes it to the server when event “event” happens.
Another option is to make async fetching of the attribute getElement().executeJs(“return this.getAttribute()”).then(result → { … });
You can also set the listener fully in JavaScript and use client callable to handle both the event and the value.