Time for action – setting a default salary for employees
For example, consider a case wherein we want to set a default value for the salary attribute
in the EmpEO.xml
file based on the Deptno
attribute. In this case, we have to provide an expression that will be evaluated at runtime to provide the default value. The following steps show us how to do this:
Click on the
Sal
attribute from the list of attributes displayed in the Attributes section ofEmpEO.xml
.In the Default Value section, select the Expression option. Now the pencil icon will be enabled for the textbox below the Expression option.
Click on the pencil icon to open an Edit Expression Editor window, and add the following code in the Expression editor box:
if(Job == 'MANAGER'){ Sal = 1000; } else{ Sal = 2000; }
Select the
Job
attribute as the calculation is dependent on it.Now click on the OK button to add the expression for setting a default value for the
Sal
attribute.
What just happened?
We have created the default value...