One of the interesting feature in ADF is using 'Groovy Expressions' , Using these expressions we can invoke various methods defined in ViewObjectImpl or Application Module Impl or access Application Module UserData session object
1. How to invoke a method defined in ViewObjectImpl class for a given specific attribute which is part of the same view object
You can define any method in ViewObject Impl something like as below
public String getEmployeeName(){
return "EMP123"
}
Define an attribute in a view object and modify its value (Groovy expression) as below
adf.object.viewObject.getEmployeeName() - This will invoke the method defined in ViewObjectImpl class and hold the returned value.
2. How to access userData session object using Groovy expressions
Get the userData hash table in AM Impl class, and store whatever values you need as shown below
Hashtable userData = getDBTransaction().getSession().getUserData();
userData.put("employeeID","1234");
Use below groovy expression in any of the View objects which are part of respective application module , and access the data stored in userData session object.
adf.userSession.userData.employeeID
Below is sample code how to get the user Session Data in App Module
Hashtable userdata = getDBTransaction().getSession().getUserData();
3. How to access a method defined in Application Module in any view object
use below groovy expression in any of the view object which is part of respective application module
adf.object.applicationModule.getEmployeeIDByName()
1. How to invoke a method defined in ViewObjectImpl class for a given specific attribute which is part of the same view object
You can define any method in ViewObject Impl something like as below
public String getEmployeeName(){
return "EMP123"
}
Define an attribute in a view object and modify its value (Groovy expression) as below
adf.object.viewObject.getEmployeeName() - This will invoke the method defined in ViewObjectImpl class and hold the returned value.
2. How to access userData session object using Groovy expressions
Get the userData hash table in AM Impl class, and store whatever values you need as shown below
Hashtable userData = getDBTransaction().getSession().getUserData();
userData.put("employeeID","1234");
Use below groovy expression in any of the View objects which are part of respective application module , and access the data stored in userData session object.
adf.userSession.userData.employeeID
Below is sample code how to get the user Session Data in App Module
Hashtable userdata = getDBTransaction().getSession().getUserData();
3. How to access a method defined in Application Module in any view object
use below groovy expression in any of the view object which is part of respective application module
adf.object.applicationModule.getEmployeeIDByName()
No comments:
Post a Comment