UI.getCurrent().setContent(pageLayout) not displaying UI

Currently, I am trying to integrate vaadin with Activiti Framework for which my logic depends upon the execution of UI.getCurrent().setContent(pageLayout) and then my application should not proceed untill the user has entered the input in the text fields. But, it seems that the line UI.getCurrent().setContent(pageLayout) is executed only when it is last line in my code. Otherwise the ui simply does not show up as demonstrated in the code below:

Scenario 1: UI does showup
{
final VerticalLayout layout = new VerticalLayout();
System.out.println(“INIT”);

    //navigator=new Navigator(this,layout);
    getPage().setTitle("Navigation Example");
    new StartView();

}

public StartView()
{
final VerticalLayout layout = new VerticalLayout();
System.out.println(“HAAN HUN MAIN YAHAN”);
Button btn = new Button(“First Page”);
layout.addComponent(btn);
UI.getCurrent().setContent(layout);

        btn.addClickListener(e -> 
        {
           ((MyUI)UI.getCurrent()).getNavigator().addView("main", new MainView()); 
           
        });
     
}
  1. Scenario: UI doesnot showup
    {
    final VerticalLayout layout = new VerticalLayout();
    System.out.println(“INIT”);

     //navigator=new Navigator(this,layout);
     getPage().setTitle("Navigation Example");
     new StartView();
    

while(true)
{
//UI DOESNOT SHOW UP. THE purpose of this while loop is to wait untill the user doesnot enter any value in
//the textfield. but if this gets executed, then UI doesnot showup. I have tried using threads but problem persists!
}

}

I think you will need some other way than having a while loop - if the while loop is not terminated, the servlet will not respond to the browser, so the UI can not be displayed.

Actually what i want to do is that, i have a bpmn model which consist of a user task (takes user’s input) and then a script task (displays user’s input). I want to pause my activiti workflow after user task, generate a user form gui and resume the execution of the next task when the button is clicked using vaadin. Can you please suggest me a way to do so?

I don’t have specific experience with Activiti, but typically BPM systems have some type of user interaction task (for example Human Tasks in old IBM Websphere Process Server lingo) that work as you describe - the process waits for a human to do something before continuing.

So from a Vaadin UI point of view, you could search for a list of available Human Tasks found from the server and display them somehow, maybe in a Grid. When you open one up, it could create a new Window containing a TextField and a Button. When you fill in the TextField and click the Button, the Button’s ValueChangeListener triggers on the backend and fills in the Human Task and tells the BPM to continue the process.

That’s exactly what i am trying to do. But i am not able to suspend the process and resume it on button click.

I have no idea how your process works, but just from looking at the docs, have you tried creating a User Task? See here: https://www.activiti.org/userguide/#bpmnUserTask

-Olli