How to enable search button only after entering required fields and a optio

I have a requirement where i need to enable a search button only after all the required input fields and a option field are filled how can i achieve this using vaadin 7.

The following are the input fields


fromdate and todate are required and remaining all are optional

What i tried.

All the fields are already added to form layout and each field has some validations.

i created a fieldGroup

and for all input fields i did this

fieldgroup.bind(productId, “productId”);

productId.addTextChangeListener(new TextChangeListener() {
public void textChange(TextChangeEvent event) {
if (fieldGroup.isValid()) {

I have added the above code for each field.

Can anyone please suggest me how to achieve this fuctionality in vaadin 7