« Back to Apex Home
Follow

Client-side Validation

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.

ACV2T1-3-1.png

Set the Required Fields

Select each of the following fields and set their visibility to "Required" - Product Class, Make and Model. 

ACV2T1-3-2.png

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.

ACV2T1-3-3.png

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.

ACV2T1-3-4.png

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. 

ACV2T1-3-5.png

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.

ACV2T1-3-6.png

Make Button Depend on Validity

Select the Save button and go to the configuration tab, and bind the "Enabled" option to the isValid variable. 

ACV2T1-3-7.png

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). 

ACV2T1-3-8.png
 

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments