Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Objectives
After completing this lesson, you should be able to do the following: Build cascading lists of values (LOV) Enhance the application with calculations Validate foreign keys Employ Groovy expressions in validation
3-2
Agenda
Cascading List of Values Transient Attributes and Calculations Entity Object Validation Failure Messages
3-3
Cascading Lists
Use one list to determine the values of a second list: select a Manager, who works in the same department or has a job of MANAGER or PRESIDENT.
Employees in the Sales department Change department to Employees in the
Research
department
Research
3-4
3-5
3-6
3-7
3-8
3-9
3 - 10
3 - 11
Agenda
Cascading List of Values Transient Attributes and Calculations Entity Object Validation Failure Messages
3 - 12
Transient Attributes
They do not map to the database column. They are value holders to display the calculated data. After you add a transient attribute to the entity object, to make it a calculated attribute, you can define the calculation by one of the following methods:
Defining a Groovy or regular expression Writing Java code and using a SQL expression:
Enable a custom entity object class on the Java page of the Entity Object Editor, choosing to generate accessor methods. Write Java code inside the accessor method for the transient attribute to return the calculated value.
3 - 13
3 - 14
Entering a Calculation
In the Attribute Editor, to use a Groovy expression, select the Expression option and enter the calculation in the Value property. Set the dependencies to include all attributes in the expression.
3 - 15
3 - 16
Agenda
Cascading List of Values Transient Attributes and Calculations Entity Object Validation Failure Messages
3 - 17
Compare
List Range
Length
Validates the values character or byte size against a size and operand (such as greater than or equal to)
Validates the data using Java regular expression syntax
Regular Expression
3 - 18
With Groovy, you can define validation rules, conditional validation, default values, and failure handling.
Equivalent Groovy Script
Sal * 0.10 Sal * 0.10
Java Code
((Number)getAttribute("Sal").multiply(ne w Number(0.10)) ((Date)getAttribute("PromotionDate")).co mpareTo((Date) getAttribute("HireDate")) > 0
3 - 20
3 - 21
Agenda
Cascading List of Values Transient Attributes and Calculations Entity Object Validation Failure Messages
3 - 22
3 - 23
3 - 24
3 - 25
3 - 26
Managing Failures
On the Failure Handling tabbed page, enter the error message to be displayed when the validation fails.
3 - 27
3 - 28
3 - 29
3 - 30
Failure Handling
Groovy validation rules can conditionally raise one of several exceptions.
3 - 31
Summary
In this lesson, you should have learned how to: Use two view objects to create dependent lists Add transient attributes to hold calculations Catch foreign key validations at the entity object level Create expression validations using Groovy
3 - 32
3 - 33