My Jdev version is 12.1.2 and below is my case,
All data tables have a region column, user will choose a region during login, and user should only be able to see the data of the chosen region.
My first solution:
Create the VO and add a bind variable in the where clause of the query:
- region = :pRegion
- pRegion default value = adf.context.sessionScope.Region
In the login process, I will set the value for sessionScope.Region based on user input.
This works as what i want. But recently I've read quite many articles about accessing the session scope from the model project, and almost all of them concluded that this is not a good practice, like breaking the MVC pattern...etc. And then I found another solution as follow:
Second solution:
Create the VO and add a bind variable in the where clause of the query:
- region = :pRegion
- pRegion default value = adf.userSession.userData.Region
Create a method (say "setCustomSessionData") in the AM to set the userSession data
this.getSession().getUserData().put("Region", regionValue);
Login process store the region information to HttpSession
Perform method call on "setCustomSessionData" and pass in the value from HttpSession, so that the VO will be filtered when it is being accessed.
My question is,
1. Is the second solution a proper solution for my use case? Any other option to achieve my requirement?
2. I've several AMs and they are nested under a Root AM, is it I have to invoke my "setCustomSessionData" for all my AMs individually so to initalize the region for every AM?
3. Since AM's userSession data doesn't preserved across passivation/ activation, if using the second solution, does it means that I have to do some program on every AMs to set the region information during activation (like Invoke the "setCustomSessionData" again using the HttpSession content)?
4. Does the second solution still break the MVC pattern? Although it doesn't access the session scope directly, but i still cannot run the VO with region filtered in the AM due to the AM's userSession is not set.
Appreciate if someone can give me some hints about my question.
Thanks
Kelvin