Flipkart Search

Sunday 15 April 2012

Showing User Specific Table data in Adf - Part 1

This is a very normal use case where a user has to see his own data. We usually do it by saving userdata in DB according to some UserId{Like emailId } or some specific number or anything...For this tutorial you should have a table with user specific data....For this example I took Employee table of HR schema .....
There are two methods to do this.....
1. Execute with Params{With Bind Variables}
2. ViewObject Implementation Class
In Part 1. I will how to achieve this goal by Execute with Params{With Bind Variables}...
1. First create a desired VO and Bind a variable to it.{This should be the your userId which can be anything}
2. Now give a where clause to your VO which binds your bind Variable

3. Now create a task-flow{or a jspx page}......I prefer taskflow to ensure re usability...

4. Now add a view to it ..and make sure you select document tpye: JSP XML

5. Now go to datacontrol and expand your employee collection and go to operation section and drag and drop ExecuteWithParams to your page as an ADF parameter Form 
6. Now drag and drop your table on the same jsff page see above..
7. Now go to jsff page Bindings and then go to structure window{left below corner}and you can see Executables . Now right click on Executables->Insert Inside executables->invoke Action. Give any string as id and Binds as ExecuteWithParams . Go to its property and make refresh:always {Note: click on the image below for better visibility}

8. Now again go to binding tab of the jsff page{you must be there already }. See the cursor{Means edit the bindings->ExecuteWithParams

9. Now you will see the dialog as below...go to value -> show El  Expression Builder

10. Now delete the existing text and map it to security context user name...
11. Now you can delete the adf parameter form in the jsff page{So that user can't view it}.. or you can make the adf panel form layout render false which contains the ExecuteWithParams form field and Button

12. Now you have to give a login page to the user so that he can give his user name and password to login and see his data...In adf this is very simple...Go to Application->Secure->Configure ADF security...

Follow the next screens as it is--

13. Now click next-next or finish and open Application Resources->Descriptors->META-INF->jazn-data.xml and add your user and give userId as Name
14. Add an application role and add the existing user to this role...

15. Now go to resource Grants tab then Resource Type->Task Flow and give your task grant to application rule..

16. Now create a blank jspx page and drop adf page flow into it as region
17. Now grant this jspx to the same application role....
18. Now run your application and Enjoy
see the sample..earlier
 And now with ExecuteWithParams

No comments:

Post a Comment