Showing posts from November, 2018

Custom 401 unauthorized error page

Sources: 1) ErrorCodeDemo1-GitHub , 2) ErrorCodeDemo2-GitHub

Quite often I see developers ignoring proper error redirection for 401 unauthorized access scenarios. The usual behaviour is to put an enterprise/application role constraint for the homepage and relying on the J2EE container to deliver the default error page. Not only does it look ugly, but it also breaks the application flow, as the end user has no other option provided to rectify the error.
This article talks about two simple approaches to display our own error page when an unauthorized user accesses your application. The end-result would be displaying something like this:

Approach 1: Declarative This is a simple, one-step approach. You just define a reference to your own error page inside web.xml file, which gets called for a 401 error code.

Approach 2: Programmatic The second approach is slightly elaborate. But effectively, there is no difference in the end-result. In this approach, I create a task-flow…

RichInputListOfValues - accept unlisted values and update model

Source: GitHub

Business requirements can be strange and demanding at times. They would make you look deeper into the framework and try to find out mechanisms to bypass usual behaviour.
I recently worked on a requirement where the customer was in love with Input-List-Of-Values component and wanted to know if I could stretch it further. Here's what he wanted:
1. Allow the Input-List-Of-Values to accept values which were not in the list. 2. On entering such a value, fire a validation which would show a warning message that the value is not in the list. 3. From the developer's stand-point, we also wanted to update the model then and there, as we were using the current row's attributes for some other logic processing. Of course, this third point was our concern, not the customer's.
So let's see how to go ahead with this. I have an application which displays one row of a transient view object. The "FirstNameAttr" attribute of this view has one…

SQL Authentication Provider for Oracle ADF


Using SQL authentication provider turns out to be a much needed feature for applications which have been transformed into ADF web applications from legacy forms. For applications with really large user bases, it becomes quite tedious to transfer users from database tables to other providers like LDAP.

We do have quite a lot of discussions on this topic. This article will be an extension of two great blogs by Edwin Biemond and Chris Muir, and intends to provide a complete solution with this approach.

The detailed initial steps of this approach are mentioned in the above two blogs. So I will quickly run through them.

I set up a new auth provider from WebLogic console - I will call it CustomSQLAuthenticator.

I would want this authentication system to take precedence over the DefaultAuthenticator. In order to do that, I would do the following:

1) Re-order the providers, to bring up CustomSQLAuthenticator above DefaultAuthenticator.

2) Set the control flag for both Custom…

Programmatic DVT charts in Oracle ADF

Source: GitHub

This article talks about programmatic approach of creating dvt components or charts, using Java objects, and more importantly, without ADF bindings. This is quite helpful when you deal with data which does not change often and can be pre-loaded into Java objects. The biggest advantage of this is of course, performance, since you do away with any database interaction.

The sample code has a table based on Department pojo. Each department object has a List of Employee pojo. On table row selection, I retrieve the list of employees, and I use this list to create the Object array required for each chart type.

There are a couple of key points to this approach:
1) Your Java data model should be prepared to provide all the required information to the chart.
2) You need to know the "Tabular Data" format for each graph.

My data-model consists of a Department object, having a list of Employee objects.

Each graph's tabular data format is an array of O…

Send mail using gmail from Oracle ADF

Source: GitHub

This article talks about using Google services (Gmail) to send email from an ADF application. I doubt that there would be a real-world use-case for this, but nonetheless, the email integration would be the major takeaway from this blog.

This does not use any ADF related package. Any Java application is good enough for this.

To start with, I have an ADF application, with just the ViewController project. I don't need any Model support for my sample project. The UI captures the required details.

However, before you start sending emails from your Google account, you need to allow "less secure apps" to access your Google account. Now this is not recommended, but try it out for once. Visit, scroll down till the end and set "Allow less secure apps: ON".

The emailing will be taken care of by javax.mail package. Let us break up the activities into the following sections:

Note: multiple recipients (to…

Custom (user-defined) GUI components in ADF

Source: 1) CustomComponent , 2) CustomComponentApp
A very less-used, yet powerful, feature of Oracle ADF is its ability to allow users to create custom (declarative) UI components. The steps to create such a re-usable component is a bit elaborate and clumsy, but the fruit of the hard-work is quite sweet!

This is going to be quite a large blog. So I will break this into 2 sections. However, just to get your attention, this is what we intend to achieve in the end:

Section 1 - Define the component Create an ADF application, with the default ViewController and Model projects. I have renamed ViewController to DeclarativeComponent in my case, and have removed the Model project. An alternate starting point would be to create an empty Java application and add a project, but I chose this path so as to ensure that all the required libraries get included automatically and save me the hard work!
Once the application structure is created, right click on the project and create a ne…