How to Clear form data and page results on button click ?

Hi,
I am new to Vaadin and stuck at one place.
I have a form (with 3 three user fields) and on click of a button I am calling a web service and showing the results in a table.
But on click of another button , I want to clear all user input and remove displayed table so that user can do another search.
I tried using window.removeAllComponents(); and then adding the components again, but the components get removed but do not get added again.
Can somebody help on this ?
Below is my code.

package VaadinProject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.jensjansson.pagedtable.PagedTable;
import com.magellanhealth.enterprise.druglookup.webapp.spring.webflow.controller.DrugLookClient;
import com.magellanhealth.enterprise.druglookup.webapp.spring.webflow.model.DrugSearchCriteria;
import com.vaadin.Application;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ConversionException;
import com.vaadin.data.Property.ReadOnlyException;
import com.vaadin.data.Validator.EmptyValueException;
import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.Component.Event;
import com.vaadin.ui.Component.Listener;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.ListSelect;
import com.vaadin.ui.Select;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
import com.magellanhealth.enterprise.druglookup.webapp.spring.webflow.model.DrugData; ;

public class VaadinProjectApplication extends Application {

public void init() {
	
	addComponenttoWindow();
}
private void addComponenttoWindow(){
	final Window window = new Window();
	setMainWindow(window);
	window.setImmediate(true);
	Label label = new Label("Drug Coverage Lookup");
	
	DrugSearchCriteria drugSearchCriteria = new DrugSearchCriteria() ;
	
	final BeanItem<DrugSearchCriteria> beanItem = new BeanItem<DrugSearchCriteria>(drugSearchCriteria) ;
	
	final Form lookupForm = new Form();
	lookupForm.setImmediate(true);
	lookupForm.setFormFieldFactory(new MyFieldFactory());
	lookupForm.setItemDataSource(beanItem);
	lookupForm.setVisibleItemProperties(new Object[] {"formularyId","searchType","searchName","searchNDC"});
	Button thebutton = new Button("SEARCH",lookupForm,"commit");
	
	thebutton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -4459717321759951123L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
            	lookupForm.commit();
            	
            	DrugSearchCriteria drc = beanItem.getBean();
            	if(drc != null){
            		
            		this.createClearbutton() ;
            		
            		String formularyId = drc.getFormularyId();
            		String searchType = drc.getSearchType();
            		String drugName = drc.getSearchName();
            		String drugNdc = drc.getSearchNDC();
            		System.out.println("form id -- >" + formularyId);
            		System.out.println("search type -- >" + searchType);
            		System.out.println("drugName -- >" + drugName);
            		System.out.println("drugNdc -- >" + drugNdc);
            		DrugLookClient drugLookClient = new DrugLookClient();
            		List<DrugData> drugList = new ArrayList<DrugData>();
            		try {
            			drugList = drugLookClient.callService(drc);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
            		PagedTable pagedTable = configureTable(drugList);
            		//Table table = configureTable(drugList);
            		window.addComponent(pagedTable);
            		window.addComponent(pagedTable.createControls());
            	}
            } catch (EmptyValueException e) {
                // A required value was missing.
                // Enable tooltips to show this.
                for (Iterator<Component> i = lookupForm.getLayout().getComponentIterator();
                     i.hasNext();)
                    ((AbstractField) i.next()).setValidationVisible(true);
            }
        }
        
        private void createClearbutton(){
        	Button clearButton = new Button("Clear Search",lookupForm,"discard");
    		clearButton.setImmediate(true);
    		window.addComponent(clearButton);
    		clearButton.setImmediate(true);
    		clearButton.addListener(new Button.ClickListener(){
    			 /**
    			 * 
    			 */
    			private static final long serialVersionUID = 1L;

    			@Override
    	            public void buttonClick(ClickEvent event){
    	                try {
    	                	System.out.println("inside clear method");
    	                	//window.re
    	                	window.removeAllComponents();
    	                	addComponenttoWindow();
    	                }catch (EmptyValueException e) {
    	                    // A required value was missing.
    	                    // Enable tooltips to show this.
    	                    for (Iterator<Component> i = lookupForm.getLayout().getComponentIterator();
    	                         i.hasNext();)
    	                        ((AbstractField) i.next()).setValidationVisible(true);
    	                }
    			 }
    	                
    		});
    	}
    });
	window.addComponent(label);

// lookupForm.addField(“formularyId”, ProgramPlanName);
// lookupForm.addField(“searchType”, searchBy);
// lookupForm.addField(“searchName”, drugName);
// lookupForm.addField(“searchNDC”, drugNDC);
//lookupForm.addField(“formularyId”, ProgramPlanName);
// window.addComponent(ProgramPlanName);
// window.addComponent(searchBy);
// window.addComponent(drugName);
window.addComponent(lookupForm);
window.addComponent(thebutton);
}
private PagedTable configureTable(List drugList){
PagedTable table = new PagedTable();
table.addContainerProperty(“Drug Name”, String.class, null);
table.addContainerProperty(“NDC”, String.class, null);
table.addContainerProperty(“Covered”, String.class, null);
table.addContainerProperty(“Medical Exception Required”, String.class, null);
// table.addItem(new Object {
// “SCHIRMER TEAR TEST STRIP”,“00065089804”,“NO”,“NO”}, new Integer(1));
// table.addItem(new Object {
// “SCHIRMER TEARING”,“00065088745”,“NO”,“NO”}, new Integer(2));

	for(int i=0;i<drugList.size();i++){
		DrugData data = drugList.get(i);
		table.addItem(new Object[] {
				data.getDrugName(),data.getNDC(),data.getCovered(),data.getMedicalExceptionRequired()}, new Integer(i+1));
	}
	table.setPageLength(15);

	
	return table ;
}

}

Thanks,
Avinash.

Hi,
Just a quick update. When I reload the page its working.
I added the last line to my code and its working.
But we are using Liferay and I have deployed my Vaadin app as a portlet hence I dont want to reload the complete page.
Anything which can reset the page without reloading would help greatly.

window.removeAllComponents();
addComponenttoWindow();
window.executeJavaScript(“window.location.reload(true)”);