Change UI with JavaScript

Well, okay, there are several mistakes in that script. The good script is this:

String script = "if (!window.vaadin) alert('Failed to load the bootstrap JavaScript: VAADIN/vaadinBootstrap.js');"+
                "vaadin.initApplication('forjs', {"+
                "'browserDetailsUrl': 'two',"+
                "'serviceUrl': 'two',"+
                "'widgetset': 'com.vaadin.DefaultWidgetSet',"+
                "'theme': 'amavaadinapptheme',"+
                "'versionInfo': {'vaadinVersion': '7.1.7'},"+
                "'vaadinDir': 'VAADIN/',"+
                "'heartbeatInterval': 300,"+
                "'debug': true,"+
                "'standalone': false,"+
                "'authErrMsg': {"+
                "'message': 'Take note of any unsaved data, and <u>click here</u> to continue.',"+
                "'caption': 'Authentication problem'"+
                "},"+
                "'comErrMsg': {"+
                "'message': 'Take note of any unsaved data, and <u>click here</u> to continue.',"+
                "'caption': 'Communication problem'"+
                "},"+
                "'sessExpMsg': {"+
                "'message': 'Take note of any unsaved data, and <u>click here</u> to continue.',"+
                "'caption': 'Session Expired'"+
                "}"+
                "});";

Now, the JavaScript function ‘vaadin.initApplication’ is called. I know this because I handle sucessfully JavaScript function callback in way that is explained here: https://vaadin.com/book/vaadin7/-/page/advanced.javascript.html

However, new UI is not charged. Additionally, I’ve specified custom UI providers for both UIs (distinct provider classes), I’ve override all its methods and I’ve toggled off breakpoint for debug mode. I check first UI provider is used but when ‘vaadin.initApplication’ function is called for new UI charge, second UI provider is not used. If I drop my ‘div’ element previously, behaviour is the same. I also try changing value for ‘vaadinDir’ with all posibilities but I haven’t got any positive result.

Can someone help me? Does another function like ‘finishApplication’ exists? Is doing what I want possible?

Any answer, please…