Adding a validation to the page
We are now going to add some validation to the create society page. We can add validation by adding code to the setter methods in the entity object class. In the following example, we are going to validate that a date entered in the dateStart
field is greater than the current date.
How to do it...
To add a validation to the page, perform the following steps:
Right-click on EmpSocietyEO in Applications Navigator.
Select Go to Entity Object Class from the pop-up menu and scroll down to the
setDateStart
method, as shown in the following screenshot:Add the following code before the
setAttributeInternal
line.In the following screenshot we check to see if the value in the Start Date field has been entered.
If there is a value, that is, the field is not null, we store the date in a variable called
startDate
.We store the current date in a variable called
todaysDate
.Finally, we check if the start date is less than today's date. If the condition is
true
, we will raise an...