Refresh issue

Hello, I am new one here, and I’ve got a problem with my application, now vaadin is in debug mode, when i first run application, everything works fine, before i press refresh button, and i get this problem:

2019-03-26 15:42:14 ERROR c.v.flow.server.DefaultErrorHandler - 
java.lang.IllegalStateException: Can't move a node from one state tree to another
	at com.vaadin.flow.internal.StateNode.doSetTree(StateNode.java:657) ~[flow-server-1.2.4.jar:1.2.4]

	at com.vaadin.flow.internal.StateNode.lambda$setTree$3(StateNode.java:364) ~[flow-server-1.2.4.jar:1.2.4]

	at com.vaadin.flow.internal.StateNode.visitNodeTree(StateNode.java:616) ~[flow-server-1.2.4.jar:1.2.4]

	at com.vaadin.flow.internal.StateNode.setTree(StateNode.java:364) ~[flow-server-1.2.4.jar:1.2.4]

	at com.vaadin.flow.internal.StateNode.setParent(StateNode.java:264) ~[flow-server-1.2.4.jar:1.2.4]

Hi Гасан

Are you trying to reconnect a component into the session after the ‘refresh’?

If you are, you can’t :slight_smile: :slight_smile:

S.

how can i fix it? or what shall i do after deploy?

We need to know more about what your application is doing.

Main Layout

@Route
@Theme(Material.class)
@Push
public class CEO_page extends VerticalLayout {
	
	
	
	@Autowired
	private CEOForm ceoform;
	
	@Autowired
	private CEOService service;
	
	private RadioButtonGroup<String> group = new RadioButtonGroup<>();
	private String[] radioButtons= {"Физ. Лицо","Юр. Лицо"};
	
	
	
	
    public CEO_page(CEOForm ceoform, CEOCheckState state, CEOService service) {
    	this.ceoform=ceoform;
    	this.service=service;
    	
    	ActivityManager();
    	group.setItems(radioButtons);
    	
		H1 title = new H1("HELLO");
		
		addComponentAsFirst(title);
		
		add(group);
		
		
	}
    @PostConstruct
    public void ActivityManager() {
    	group.setItems(radioButtons);
    	group.addValueChangeListener(event ->{
    		if(event.getValue().equals(radioButtons[0]
)) {
    			getUI().ifPresent(ui->ui.access(()->this.add(ceoform)));
    		}
    		else {
    			//BLA BLA BLA
    		}
    	});
    }

Form that is added:

@SpringComponent
@UIScope
public class CEOForm extends FormLayout{
	
	/**
	 * 
	 */
	
	public static CEOMessage message = new CEOMessage();
	public static TextField surname = new TextField("Фамилия");
	public static TextField name = new TextField("Имя");
	public static TextField region = new TextField("Регион");
	public static TextField city = new TextField("Город");
	public static TextField subdisctrict = new TextField("Область");
	public static TextField address = new TextField("Адрес");
	public static TextField sex = new TextField("Пол");
	//public static DatePicker birthday = new DatePicker("Дата Рождения");
	public static TextField mail = new TextField("Адрес электронной почты");
	public static ComboBox<String> comboboxCity = new ComboBox<String>();
	public static ComboBox<Sex> comboboxSex = new ComboBox<Sex>();
	public static Binder<CEOMessage> binder = new Binder<>();
	
	@Autowired
	public CEOForm(CEOService Service,CityService CityService,sService sService) {
	
	
		
		comboboxCity.setItems(CityService.getCityNames());
		comboboxS.setItems(sService.getAll());
		
		super.add(name,
				surname,
				//region,
				city,
				subdisctrict,
				address,
				sex,
				comboboxCity,
				comboboxS,
				mail
				//birthday
				);
		binder.setBean(message);
		//binder.forField(region).bind(CEOMessage::getRegion,CEOMessage::setRegion);
		binder.forField(surname).bind(CEOMessage::getSurname,CEOMessage::setSurname);
		binder.forField(name).bind(CEOMessage::getName,CEOMessage::setName);
		binder.forField(mail).bind(CEOMessage::getMail,CEOMessage::setMail);
		//binder.forField(birthday).bind(CEOMessage::getBirthday,CEOMessage::setBirthday);
		
		
		
		this.add(new Button("Commit", 
	                event ->  
		Service.generate(message)));
	}

Its because you are using ‘static’ components. Remove the static keyword.

Thank u

Phew! This tip was a lifesaver. Spent a lot of hours debugging this issue.

Some of the Vaadin tutorials have declared static components. I started with the tutorial as my base.