Note : A lot of things have changed in the world of Intelligent Advisor Custom Entity Containers since this investigative article was written. If you are looking to learn about Custom Entity Containers you should focus on part three, or watch a video of the final example on our YouTube Channel.
For the most up to date content, you should read Custom Entity Container posts or read the detailed example in JavaScript Extensions for Oracle Policy Modeling.
Once again, we look into an educational JavaScript Extension example for Oracle Intelligent Advisor. As usual the example provided is purely intended for learning purposes. It involves a situation that you probably have come across many times. We wish to display a set of inferred entity instances in our Interview. But we are afraid that our set of instances is going to produce a layout that is rather unfriendly. Here is a visual example, taken from a sample project with a simple inferred entity that has only two attributes :
There are fifty three items in my list. So the Entity Container provides a very long list. Yes, I’m sure I could play around with labels and containers and goodness knows what, in order to make it shorter. But basically, the Entity Container just spawns an elastic list. Which is the opposite of what I want. Instead I would like to see this:
The above example is a fixed height, and has a scroll bar in order to visualise the content at my leisure. The page is not affected by a very long list. And that is rather nice, especially if you have a dynamic list of terms and conditions, or something similar. Here is the data model, including the inferred entity, relationship and attributes.
The Excel spreadsheet is very basic for our example:
Custom Entity Container JavaScript Extension Example
So now on to the mechanism for displaying the content. This Custom Entity Container JavaScript Extension Example will use a standard JavaScript template based on the Oracle Policy Automation documentation. The code of the mount section is as follows:
Let’s look at it in detail. There is some interesting stuff in there. Firstly, the basic principle is as usual. On line 8, as before, we reference a custom Property in our Screen that allows us to identify the Entity Container Control on the Screen. Then, in lines 11 to 15 we create a simple DIV and add a scrollbar that will appear if the content is too large to display in the 100 pixel height.
Then we begin a loop in line 17, based on a global variable called data.data[1].instances. Of course we should create a reference to it, but for the purposes of learning we can leave it as is. This object, whose exact index will change depending on the structure of your Oracle Policy Automation data model, will prove very useful indeed. It is clearly visible in the Debugging Console of the Browser, if you insert a handy break-point:
In the case of my inferred entity instances, this array contains all 53 instances in my Browser. The same array is also visible as a Local variable as well:
Note in the screenshots above, the location of the break-point is not really relevant here : it is just used to stop the JavaScript engine in the middle of mount.
So the ability to access the instances is most useful. The code loops based on the number of instances. We add a child DIV element for each instance, and then access the values of the two attributes to concatenate them into a longer string. Word-wrap is switched on in my screenshot so you can see the whole Custom Entity Container JavaScript Extension Example code.
Finally we add a horizontal rule just to break the list up a bit. Of course there are lots of things we could do here : but we are just building a simple list and don’t really worry about styling the elements in line, which is not good practice of course.
The rest of the code simply gets rid of the element when the unmount section is called.
This example is interesting since it reveals a little about the inevitable content of our JavaScript extension. There are probably other ways to get hold of the content of the inferred entity but this is useful for educational purposes.
Summary
But as you have no doubt seen, the code example here will only work with the Debugger. It has it’s usefulness of course, to be able to understand that the content is structured in a certain way. But what about after Debug? That’s what’s coming next.
For a limited time the code is available for free download from the Online Store. Look for Custom Entity Container JavaScript Extension Example in the product list.