Setting default values for view row attributes
In this recipe, we will see how to set default values for view object attributes. There are a number of places where you can do this, namely:
In the overridden
create()
method of the view object row implementation classDeclaratively using a Groovy expression
In the attribute getter method
For example, for a newly created employee, we will set the employee's hire date to the current date.
Getting ready
This recipe was developed using the HRComponents
workspace, which was created in the Overriding remove() to delete associated children entities recipe in Chapter 2, Dealing with Basics: Entity Objects. The HRComponents
workspace requires a database connection to the HR
schema.
How to do it...
1. Create a view row Java implementation class for the
Employees
view object.2. Open the
EmployeesRowImpl.java
custom view row Java implementation class and override thecreate()
method using the Override Methods… button (the green left arrow on the editor toolbar...