'Integrating JavaScript Components and Extensions' 以及如何将状态更改从 JS 发送回服务器?
'Integrating JavaScript Components and Extensions' and how to send state changes from JS back to server?
按照 https://vaadin.com/docs/-/part/framework/gwt/gwt-javascript.html 上的教程,我为 FullCalendar js 库创建了一个组件。它工作得很好,但我仍然无法弄清楚如何将 JS 端的 getState() 中的更改发送回服务器端以保持不变。 Vaadin 将服务器端状态对象发送到 JavaScript,我可以在我的 JS 组件部分中将其作为 'this.getState().property'
访问。现在,当用户对 Fullcalendar 进行一些浏览器更改时(例如,将视图从月切换到周)并且可以检测到它并将其存储回状态对象 "this.getState().viewName='yyy'"
但是这些更改不会同步回服务器,因此我的服务器端代码可以'在我的状态 JavaBean 中看不到它 ...
我也读过这篇文章 http://vaadinsnippets.blogspot.cz/2012/10/smooth-integration-of-vaadin-7-and.html 但仍然不知道它应该如何工作。有什么提示吗?
您无法在客户端上真正更改 "shared state"。
来自 Vaadin 文档 https://vaadin.com/docs/-/part/framework/gwt/gwt-shared-state.html:
[shared state] should be considered read-only on the client-side, as
it is not serialized back to the server-side.
我想你要找的是 RPC:
RPC calls from the client-side to the server-side are made through an
RPC interface that extends the ServerRpc interface. A server RPC
interface simply defines any methods that can be called through the
interface.
按照 https://vaadin.com/docs/-/part/framework/gwt/gwt-javascript.html 上的教程,我为 FullCalendar js 库创建了一个组件。它工作得很好,但我仍然无法弄清楚如何将 JS 端的 getState() 中的更改发送回服务器端以保持不变。 Vaadin 将服务器端状态对象发送到 JavaScript,我可以在我的 JS 组件部分中将其作为 'this.getState().property'
访问。现在,当用户对 Fullcalendar 进行一些浏览器更改时(例如,将视图从月切换到周)并且可以检测到它并将其存储回状态对象 "this.getState().viewName='yyy'"
但是这些更改不会同步回服务器,因此我的服务器端代码可以'在我的状态 JavaBean 中看不到它 ...
我也读过这篇文章 http://vaadinsnippets.blogspot.cz/2012/10/smooth-integration-of-vaadin-7-and.html 但仍然不知道它应该如何工作。有什么提示吗?
您无法在客户端上真正更改 "shared state"。 来自 Vaadin 文档 https://vaadin.com/docs/-/part/framework/gwt/gwt-shared-state.html:
[shared state] should be considered read-only on the client-side, as it is not serialized back to the server-side.
我想你要找的是 RPC:
RPC calls from the client-side to the server-side are made through an RPC interface that extends the ServerRpc interface. A server RPC interface simply defines any methods that can be called through the interface.