if you use ADF Security for authentication then the user name is accessible from the ADF Context in ADF BC. You can then
1. Create a View Criteria in ADF BC for a specific view
2. Define the View Criteria to use a bind variable
3. Use groovy to add the bind variable value
- set value type to "Expression"
- add adf.context.securityContext.userName
4. Go to the Application Module --> Data Model
5. Select the View Object instance
6. Press "Edit"
7. Select the View Criteria
If you download the sample to this article: Oracle ADF: Security for Everyone then you see that users have a profile page containing data queried for the authenticated user. Its using the above approach
If you don't use ADF Security still you can use that approach. Instead of providing the bind variable value using Groovy you could execute the view object useing executeWithParams operation in which case you can read the value of the authenticated user from the ADF view side. The bind variable would not be set to Expression in this case though.
First thing is that you need to implement security in your application, if you configured security then, Take a session scope bean in your un bounded task flow
inside that session bean , you can get the information from security context, then write a static block inside your session bean and modify the fallowing code according to your requirement
ADFContext adfc=ADFContext.getCurrent();// get the context instance SecurityContext securityContext=adfc.getSecurityContext();// instantiate the SecurityContext String username=securityContext.getUserName(); // returns the username from the security Context who are currently logged in
Once you written this code just assign this username to session scope variable
Map sessionScope = (Map)ADFContext.getCurrent().getSessionScope().put("UserName", username);
So that the username with the key UserName will be available throughout your session
and Apply in where clause according to the user logged in, or else you may directly use
adf.context.securityContext.userName at the bind variable what ever you used inside your view criteria.