This lesson shows how to add required fields and validation to a coach.
Wire the Save Button
To see the validation in action, wire up the Save button to the end point of the service. Draw a line from the coach to the end point of the service. This line may not pick up the correct boundary event on the coach, so select the line, and hit the Select button next to End State Binding, and pick the Save button in the window that appears.
Set the Required Fields
Select each of the following fields and set their visibility to "Required" - Product Class, Make and Model.
Run the Service
Run the service and you will see red asterisks denoting these as required fields. You will notice you can still click the Save button to exit the coach, and no message is displayed.
Set the Required Message
Select the Product Class field and go to the configuration tab and enter "Product Class is required" for the Required Message. Do the same for the Make and Model.
Run the Service
When you run the service, the coach looks the same until you enter text into one of the required fields and remove it again, at which point the validation message will show. This is still not connected to the button, so you can still click Save to exit the coach.
Add Validate Scope
Drag a Validate Scope coach view into the row containing the fields. Create a new private variable "isValid" of type Boolean and bind it to this view.
Make Button Depend on Validity
Select the Save button and go to the configuration tab, and bind the "Enabled" option to the isValid variable.
Run the Service Again
Now when you run the service again the OK button will be disabled until the section becomes valid (ie until all the required fields are populated).