Problem with View Manager pattern and components

I’m starting a new project (Vaadin 6.8.8) and I’m using a view (screen) manager pattern but I have a problem when my web flow is to go back (pop).

My first screen is a search form (a class that extends VerticalLayout), in this screen only one form is shown and my second screen is the result view (another class that extends VerticalLayout). When the user is in the result screen and click in the back button, the search form screen is shown but there are two forms, the old form (with the previous options selected) and a new one (empty) form. What my back button code does is simply a viewManager.popScreen().

Here is my ViewManager.java code:

public class ViewManager {
	
	private MainApplication app;
	private Window window;
	
	private Stack<ComponentContainer> viewStack;
	
	public ViewManager(MainApplication app) {
		this.app = app;
		this.window = app.getMainWindow();
		
		this.viewStack = new Stack<ComponentContainer>();
	}
	
	public void pushScreen(Views view, Object filter) {
		viewStack.push(window.getContent());
		
		switch(view) {
			case AVAILABILITY_REQUEST:
				viewStack.clear();
				AvailabilityRequestView screenRequest = new AvailabilityRequestView(app);
				window.setContent(screenRequest);
				break;
			case AVAILABILITY_RESPONSE:
				AvailabilityResponseView screenResponse = new AvailabilityResponseView(app, (AvailabilityResponseFilter)filter);
				window.setContent(screenResponse);
				break;
		}
	}
	
	public void popScreen() {
		window.removeAllComponents();
		window.setContent(viewStack.pop());
	}

}

Is it a bug? or am I missing something?

I solved my problem.

The problem was that I was creating the form components (textfields, buttons, etc.) in the attach() method of the request view. To solve it, I simply create the form components in the constructor method.