Friday 4 January 2013

Generic way of Data Passing between UI Layer and Model Layer


Requirement is used to access the User Login HTTP Session Data from UI Layer to Model Layer for doing some Business Validation like checking the user is Already logged in or not, Passing the Login Date as default for all ViewObjects and etc.,.

In general, if want to pass the data from UI Layer to Model Layer then need to use the 'Action' bindings. From 'Action' bindings we need to pass the data and store it in AM, from that can access across the View Objects for the business requirements. If we are doing in this way then need to add the action bindings entry in each pageDef files. In case it is Task-flow with Begin New transactions then each task-flow will has its own transaction and it has many pageDef then need to take care all places.

For avoiding all, If we are using the DataControlFactoryImpl then no need of any pageDef entry. Only one included entry on the BC4JDataControl tag of DataBindings.cpx itself enough.

Need to follow the below steps for achieve the Generic way of Data Passing,

  • Need to create custom class by extends DataControlFactoryImpl and override the method of getDataControlClassName() and need to return the class name of custom class by extends JUApplication.


  • Need to create custom class by extends JUApplication and override the method of beginRequest() and write a logic of passes all the session scoped attributes to the underlying Application Module.


  • Open the DataBindings.cpx file and added the entry against the property of ‘FactoryClass’ underlying the tag BC4JDataControl


For more details check with sample.

[Runs with Oracle JDeveloper 11g R2 Update 3 + HR Schema]

How to run this sample?
Run using the Run.jsf and check the Generic Data Passing by followed a below steps,
  1. In Main Page click the Store on session button and see the console (it shows the actual value stored in the session with Key/Value pair).
  2. Press the ‘Employee’ Button then it will load an Employee Page. At the time of loading it will pass the UI Layer data into Model Layer via CustomDataControlFactoryImpl
  3. Now click the ‘Print UI Session Data’ Button and see the console, it will print the actual UI Layer Data into Model Layer

No comments:

Post a Comment