ADF Listener - Header

ADF Application Event listeners – Part I

Hi all and welcome to a new series on Red Mavericks!

This one is technical, focused on Oracle Application Development Framework, or ADF, so… sorry to our Business Analyst readers. There’s a new article coming out to new next week about Advanced Web Form creation… stay tuned.

Anyway, today’s article is written by a new Maverick: Pedro Gabriel. Welcome Pedro!

Pedro is a senior ADF developer at Link Consulting, and he’ll be sharing some of his experience with our fellow techie readers. He would be very interested in hearing back from you through twitter @PedrohnGabriel. Be sure to follow him  and check his Bio, right here🙂

So, without further ado, here is Pedro’s article.


ADF applications provide a wide range of Event Listeners triggered whenever a change in state occurs. With these event listeners you are able to interact with:

  • The state of the servlet context
  • The state of the servlet request
  • The HTTP session object
  • Servlet Filters
  • Phase Listeners

 

Servlet Context Events / Servlet Request Events

This type of events involves resources or state held at the level of the application servlet context/request object. You have four types of servlet context events:

 

Event Type Interface Methods Description
Servlet Context Listener javax.servlet.ServletContextListener contextInitialized() Servlet context is created.
contextDestroyed() Servlet context is about to be destroyed.
Servlet Context Attributes Listener javax.servlet.ServletContextAttribuestListener attributeAdded() An attribute is added to the Servlet Context Listener.
attributeRemoved() An attribute is removed from the Servlet Attribute Listener.
attributeReplaced() An attribute is replaced from the Servlet Context Listener.
Servlet Request Listener javax.servlet.ServletRequestListener requestInitialized() The request is about to come into scope of the web application.
requestDestroyed() The request is about to go out of scope of the web application.
Servlet Request Attributes listener javax.servlet.ServletRequestAttribuestListener attributeAdded() A new attribute was added to the servlet request. Called after the attribute is added.
attributeRemoved() A new attribute was removed from the servlet request. Called after the attribute is removed.
attributeReplaced() A new attribute was replaced from the servlet request. Called after the attribute is replaced.

 

From the moment the ADF application is invoked until it is totally rendered for usage by the end user the events are triggered in the following order:

ServletEventsOrder

In order to listen and interact to any of these event listeners you need to create a new servlet context or request listener class and implement the previous mentioned interfaces. The next image shows how to create it.

CustomServletContext

Then you need to register them in the “web.xml” file in order to listen and interact to the events for the servlet context or request listeners. Set the custom event listener class path. For now on when you run the ADF application the filter will be triggered.

CustomServletContext_Web_xml

HTTP Session Events

This type of events involves resources or state associated with series of requests from a single user session that is associated with the HTTP session object. You have two types of http session events:

 

Event Type Interface Methods Description
HTTP Session Listener javax.servlet.http.HttpSessionListener sessionCreated() An HTTP session is activated.
sessionDestroyed() An HTTP session is about to be passivated.
HTTP Session Attribute Listener vavax.servlet.http.HttpSessionAttributeListener attributeAdded() An attribute is added to the HTTP session listener.
attributeRemoved() An attribute is removed from the HTTP session listener.
attributeReplaced() An attribute is replaced from the HTTP session Listener.

 

The HTTP session events are executed in the following order:

HttpEventsOrder

To listen and interact to any of these event listeners you need to create a new HTTP listener class and implement the previous mentioned interfaces. The next image shows how to create it.

HttpSessionListener

Then you need to register them in the “web.xml” file in order to listen and interact to the events for the HTTP event listeners. Set the custom event listener class path. For now on when you run the ADF application the filter will be triggered.

HttpSessionListener_WebXml

Servlet Filters

Servlet filters are used for pre-processing Web application requests and post-processing responses. Sometimes modifying the response from a class of servlets during pre-processing might be useful. You can have as much filters as you want and are invoked based on the order they are configured in the web.xml file.

When you create a new filter class it must implement the “javax.servlet.Filter” interface. The next image shows how to create it.

CustomFilter

You will find your custom filter implementing 3 methods:

  • init – filter initialization and saves the filter configuration in a variable.
  • doFilter – filter implementation. You can check whether the filter is called during a request or a response.
  • destroy – filter finalization. You can override this method to perform extra actions.

After filter creation you must register it on the “web.xml” file in order to listen and interact to the events for the filter.

CustomFilter_Register

Phase Listeners

ADF lifecycle integrates with JSF request lifecycle. By using a phase listener, you can listen to the events fired before and after for any of the ADF lifecycle phases, and execute custom code. Take a look at the JSF and ADF lifecycles in the next image so you can understand the range of events you can listen:

adf_jsf_lifecycle

In order to listen and interact to ADF lifecycle phases you need to create a new phase listener class and implement the “javax.faces.event.PhaseListener” interface. The next image shows how to create it.

CustomPhaseListener

Then you need to register it in the “faces-config.xml” file in order to listen and interact to the events. Set the custom phase event listener class path.

CustomPhaseListener_FacesConfig

Conclusion

By creating your own event listeners classes you are able to listen and interact with a wide range and variety of data that is triggered whenever you perform any action in your ADF application.

On the next post we’ll provide some examples regarding the type of data that you can find and intercept in the event listeners.

Cheers,

Pedro Gabriel

 

@PedrohnGabriel

Video – How to create a Web form in Oracle BPM 12c

Hi,

 

Welcome to Red Maverick’s first video.

In this video, we’ll guide you on how to build a web form, using the web form designer in Oracle BPM12c Process Composer.


Enjoy!

Cheers

Maverick

Data Objects and Form Header

Process Data Definition – Part II… and Web form introduction

Hi there,

So here’s our new article, completing the data definition series. We’ll build the remaining Business and Data Objects as well as build our first web form based on those objects.

Using your data inside the Request a Parking Space process

Last time, we saw how we defined the data that will be governed by our Business Process.

Now it’s time to make use of it during the process execution. It’s this data that will be input, manipulated and condition the actual process flow for every process instance.

If you remember from the last article, you had some homework 🙂

You had to build the Parking Space Business Object. Check what you did against our proposal. It should feature the same attributes, give or take a few…

Parking Space

  • Space Nr.
  • Reservation Start Date&Time
  • Reservation End Date&Time
  • Reserved for
  • AllSpacesOccupied?
  • Meeting with
  • Employee Nr

Important Note: Remember that processes govern data, they don’t keep it. Data is kept in the database. That’s how you have to think.

Again, the purpose of this series is to help business analysts and process owners model and automate processes without writing any code, so we’ll assume that the IT department did their work and expose some services that check if there’s a parking space available for the time slot that the requester wishes to reserve and, if so, returns the information defined in the Parking Space Business Object, and if not, returns an response that indicates all parking spaces are occupied.

Remaining Data Objects

Let’s create our remaining data objects: one for the parking space and one of our special data objects that help us govern the process flow, an instance of the ProcessStatusBO.

Inside the process BPMN diagram, click on the Data Objects option

Access the Data Object definition window

Access the Data Object definition window

and create a new process data object called v_parkingSpace, of the type object -> parkingSpaceBO, and another one called v_processStatus of the type object->ProcessStatusBO.

Add a new process Data Object

Add a new process Data Object

Adding the 2 new Data Objects

Adding the 2 new Data Objects

I use the prefix “v_” to indicate that it’s a variable, something that holds data, of my process.

From this moment on, your process has all the data placeholders that it needs.

All 3 Data Objects created

All 3 Data Objects created

Now there’s one more step…

Collecting the information

We’ll need to collect the data first, to get the process rolling. There are, in fact, several ways to start processes, but the vast majority will necessarily collect information at the start, either from a user (through a form, …) or from other systems, and places it in the process data objects. In our case, we’ll build a form to collect that information from the requester.

Designing web forms is a breeze since Oracle BPM 11.1.1.7. The frevvo platform was introduced to help business users design the interaction forms themselves, reducing the need for IT to build applications for that specific purpose that typically take a lot of time to be ready, increasing the overall agility and decreasing the time-to-market of a process.

So, to build our own forms, we’ll go into the web forms option in Oracle’s BPM Process Composer, click over the “+” sign and give it a name, for instance RequestInfoFRM.

Creating your first form

Creating your first form

We’re adopting what we call the “Form first method”, so we’ll design the form first, and let Oracle BPM generate the data structures for itself. Then, we’ll just need to connect these self-generated structures to our own data objects.

There’s also the “Data First method”, that allows you to specify the specific data objects for forms and allows widget auto generation, effectively generating the web form in a single click. You only have to adjust the looks, if you don’t like the way the widgets are placed.

For our form, we’ll collect the information that we defined in our RequestBO.

 As you can see, the web form designer has a drag-and-drop interface, which allows even complex forms to be designed in a very short timeframe.

And so, we completed our data object definition and built our first web form for it. On the next post, we’ll look into more detail about web form creation, namely focusing on both form creation methods and looking into the various form widgets. Until then…

Cheers,

Maverick

Post Header image by Garry Ing