We can run a TestSet
instance only if the user selects one. Follow these steps to add a proper validation:
Implement your
initButton
method to match this code:private void initButton() { button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if(isValid()) { runSelectedTest(); } } }); }
Now implement your
validate
method. Here is how we validate:public boolean isValid() { combo.setComponentError(null); textField.setComponentError(null); boolean isValid = true; if(combo.getValue() == null) { combo.setComponentError( new UserError("Select a test from the list.")); isValid = false; } if(textField.getValue().toString().isEmpty()) { textField.setComponentError(new UserError( "You must introduce the number of iterations to execute")); isValid = false; } return isValid; }