I’m trying to implement a custom text editor / viewer which handles large chunk of characters (for example a lengthy article) on client-side and upon user request (click a button) send the content to server side. The editor is able to annotate texts and automatically scroll to certain texts, etc… so it cannot be implemented by RichTextArea.
And I found this post with the same questions asked by Roland, it’s very valuable and clearified a lot questions that I have.
However, if Vaadin 7 is phasing out a little the concept of non-immediate fields, I still cannot just send the whole chunk of characters to the server everytime user changes just a little bit… server does not need to know the small changes, and that may be a lot of characters to send through the wire…
So, my custom widget needs to know when to send the text. That is, upon user click a button.
Then, one solution is: user click a button, event sent to server, server call MyEditor to update its event, which is send back to MyEditor at client side, MyEditor make a RPC call, send the text. Ok, so I assume that RPC is IMMEDIATE, right? Otherwise I need to wait user click something immediate to receive the text.
Another solution, I include that button with my text editor and react on the button. That’s strange, why a TextField should come with a button?
I think we cannot ignore the fact that there’s an Internet between the client and server, and cannot just pretend the browser is like a display connected to the server. Maybe the “immediate” mechanism is insufficient to reflect the application logic. May I propose another model for consideration of Vaadin?
How about createing something called a “TransactionUnit”? It has server-side and client-side. Serverside UI components can be associated with a server-side TransactionUnit, and therefore the corresponding client-side widgets are also associated with the corresponding client-side TransactionUnit, so they form a group. (1) the client side TransactionUnit cache state change from client widget, queue RPC calls, etc. (2) when any of the widget in the group asks to flush the queue (immediate), everything is sent to server, (3) TransactionUnit also allows certain logic being executed in client side, for example, change of one component results update of another. This is like “grouped immediate”. And it does not need to change the current API. When developer does not use this mechanism, everything is associated with a default TransactionUnit, which behaves the default way.