Performing Validation
Another element you'll likely want to add to your enterprise object classes is validation. For example, suppose that when a studio buys a new movie, you want to check to make sure that acquiring the movie won't cause the studio to exceed its budget. You could implement a method in the Studio class like the following:Studio.java (server and client)
public void validateBudget(Number budget) throwsEOValidation.Exception {
if (budget.intValue() < 100) {
throw new EOValidation.Exception
("A budget cannot be less than $100");
}
}
Now when a studio buys more movies than it can afford, a panel displaying the message "A budget cannot be less than $100" appears when the user attempts to save the changes to the database.
© 1999 Apple Computer, Inc. (Last Updated 13 Sep 99)