Skip to main content

Initializing your Fusion Web Application Parameters at startup

If you need to initialize specific business data during application start up,this post is for you.


You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS3 + HR Schema]

A glance at the implementation

This example make use of a custom javax.servlet.ServletContextListener for performing the application initialization during deployment. Please see 'view.ContextInitializer' class in the attached sample workspace, which act as the ServletContextListener in this example. btw, check out this post How to work with ServletContextListener if you not familiar with this approach.

This example invokes ApplicationModule and populates the ServletContext attributes from the custom ServletContextListener's ContextInitializer::contextInitialized(...) method. Please note that ADFContext.getCurrent().getApplicationScope() in a web app refers the ServletContext. It means that whatever you set to ServletContext, can be retrieved later by calling ADFContext::getApplicationScope() from the Model layer. You can use EL #{applicationScope.someVariable} if you need to refer ServletContext attributes from the UI.

The above example initializes a default DepartmentId during application start up and the same is used in the the Employees View Object query using groovy expression to get the employees (default DepartmentId is configured as context-param in the web.xml)


Anonymous said…

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!