Hi
It’s sometime now I know of Vaadin and I tell you: It was love at first sight!
I’m playing a bit with Vaadin. Right now I’m looking at the darkest winding of it. :vader:
The last of it is: what if my client machine crashes, or my client browser closes by mistake or crash?
I (apparently) lose my work, my vaadin UI/session state.
So I put together a (simplistic) vaadin UI that does steal a component from a different UI; with all actual state.
And It works! (quite)
Even between my desktop-browser and android-mobile-browser
First of all: is there a best practice to do it?
Some page to read out?
Something is already working, under the vaadin hood (I’m thinking on annotation @PreserveOnRefresh)
My issue is that after few theft between new sessions my client stops to show the stealed component.
This message is on the console: “A connector with id 6 is already registered”
The aim of all this is to programmatically choose to steal a UI. So hopefully, I’ll be able to show a user his/her sessions and re-take them (like ms rdp sessions)
Here it is the working but not stable code:
package pro.jako.stealui;
import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.server.*;
import com.vaadin.ui.*;
@PreserveOnRefresh
public class StealUI3 extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
setContent(new Comp1());
}
}
class Comp1 extends CustomComponent {
static ComboBox combo = null;
Comp1() {
String id = String.format("ses=%d ui=%d"
, System.identityHashCode(VaadinSession.getCurrent())
, System.identityHashCode(UI.getCurrent()));
synchronized (getClass())
{
if(combo == null){
combo = new ComboBox() ;
combo.setImmediate(true);
combo.addItem("first");
combo.addItem("second");
combo.addItem("third");
combo.addItem(id);
}
}
AbstractOrderedLayout root = new VerticalLayout();
root.addComponent(new Label("steal-ui"));
root.addComponent(new Label(id + " (this new ui)"));
final Button loginBtn = new Button("sign in (yes, without credentials)");
loginBtn.addClickListener((evt) ->
{
loginBtn.setVisible(false);
root.addComponent(combo);
});
root.addComponent(loginBtn);
setCompositionRoot(root);
}
}
I’m using vaadin7-beta11 and tomcat-33
As you can see I’m using lambdas with jdk8.
But I think it’s not the issue!
I was able to port to jdk8-vaadin7 a good portion of this awesome application
http://code.google.com/p/vdbc/
I’ve attached other two tests more stable but simpler than the previous. Plus the source of the previous
It’s my first post, and I’m glad to be here!
Best regards guys!
Great job!!
12711.java (1.05 KB)
12712.java (1.22 KB)
12713.java (1.43 KB)