Hi !
Could someone explain me why these three situations work/don’t work ?
I’ve got an extension for VerticalLayout called TMarkerExtension - it draws something on it (using Canvas) and provides ClientRPC interface(TMarkerClientRPC) with two example functions :
- public void setTimeRatioFactor(double _trFactor);
- public void foo();
They are implemented in constructor of TMarkerConnector, setTimeRatioFactor just assigns _trFactor to variable trFactor (member of TMarkerConnector), foo only calls Window.alert(“foo”) - quite simple right ?
I also added on client side click handler to print value of trFactor on my Canvas.
Moreover there is a ServerRPC interface(TMarkerRPC) where I put one function :
- public void getTrFactor();
Its implementation looks like this :
{
getRpcProxy(TMarkerClientRPC.class).setTimeRatioFactor(newTrFactorValue); // newTrFactorValue changes by other button click
getRpcProxy(TMarkerClientRPC.class).foo();
}
And it’s properly registered in TMarkerExtension construtor.
And now these three situations :
-
Somewhere on the page I have a button with ClickListener that makes RPC calls :
{
getRpcProxy(TMarkerClientRPC.class).foo();
getRpcProxy(TMarkerClientRPC.class).setTimeRatioFactor(2);
}
In Chrome console I can see messages:
INFO: Server to client RPC call: 335:pl.waw.itl.vaadineditor.core.widgetset.client.markercomponent.TMarkerClientRPC.foo()
INFO: Server to client RPC call: 335:pl.waw.itl.vaadineditor.core.widgetset.client.markercomponent.TMarkerClientRPC.setTimeRatioFactor([2]
)
but nothing happens more - alert window doesn’t appear and value of trFactor on client side doesn’t change(I print that value on Canvas when I click somewhere on layout (…) ) -
I changed client side click handler a little bit - it calls rpc.getTrFactor() and then it prints trFactor value - now it works like a charm, alert window prints “foo” and trFactor changes as it should.
-
Using shared state mechanism - trFactor changes properly.
Why does it behave like this ?