Synchronise State from Client Component

Hi All,

In our application we have a RichTextArea that we have built an extension for to allow some additional editing support. We a using the extension to update the HTML stored in the widget.

richTextArea = (VRichTextArea) ((ComponentConnector) target).getWidget();
...
richTextArea.rta.setHTML(newHtml);

The problem we have is that the new HTML text is not synchronised with the server side component, until you make another edit of the text ( eg addign a then removing a blank space somewhere in the text field)

I want to force the client to synchronise the new text with the server so that if the action is the last thing the user does that new html is available in the server side component for further processing. How do i force a synchronisation like this?

use the @push at the start of your application.

@Push(PushMode.MANUAL)

Cfr: https://vaadin.com/docs/framework/advanced/advanced-push.html

and just after setting the value of your richText,
call UI.getCurrent().push()

That will force the client to refresh.

Hi Philippe,

If i am not mistaken that is for pushing a change made in the server side component to the client side widgets.

I am looking for something in the other direction. Pushing changes made client side to the server.

I can simply send the new text via a custom rpc, and then set it in the server side component, which will then sync back to the client… but that seems like a round-a-bout way of doing it.