Hello everyone,
Please forgive me if this is a silly question, but I’m new to web application development with vaadin.
Here is my problem:
I have a start view which asks the user for some input and there is a proceed button to go to the next step of my application, which is another view. Depending on the user input, my application should display one or the other view and after that, run a method that executes some computations.
I use a navigator to navigate between the views and I have included the above methods (the ones that execute the computations) in a ViewChangeListener to execute after the view change.
The problem is that, when I click the proceed button of the first view, the view doesn’t change until after the exit of the computation method.
I quore a part of my code, if that helps anyone:
navigator.addViewChangeListener(new InputToDiagChange());
if ([i]
condition
[/i]) {
navigator.addView("inference", diag.getInferenceView());
navigator.navigateTo("inference");
}
else {
navigator.addView("diagnosis", diag.getDiagnosisView());
navigator.navigateTo("diagnosis");
}
public class InputToDiagChange implements ViewChangeListener{
@Override
public boolean beforeViewChange(ViewChangeEvent event) {
return true;
}
@Override
public void afterViewChange(ViewChangeEvent event) {
if(event.getOldView().getClass().equals(InputView.class) &&
event.getNewView().getClass().equals(InferenceView.class)){
diag.computeInferrence(); //This is a method that executes computations
}
if(event.getOldView().getClass().equals(InputView.class)
&& event.getNewView().getClass().equals(DiagnosisView.class){
diag.runDiagnosis(); //This is a method that executes computations
}
}
}
Does anyone have a clue? Am I doing something wrong here?