Extension Code Generators for JavaScript

Over on my other home (https://siebelhub.com) we use and promote the use of Code Generators : because most of the JavaScript people need to create is in fact very structured, because of the underlying extension architecture. You don’t write just any code, you write code the way you have to write it. So how to write Extension Code?

It struck me the other day that this is equally true now for Oracle Policy Modeling – JavaScript extensions have a very well defined structure, and as I said above : you don’t write just any code – you write it the way you have to write it, in order to fit into the underlying architecture of our beloved interview.js.

Since I find myself often repeating the same JavaScript task over and over again – for example I need to create 2 custom Labels for 2 different projects or customers – I do a lot of cutting and pasting. But that often goes wrong as I forget I’ve renamed something or changed a variable somewhere.

So I decided to create a Code Generator – a sort of tool to create templates of code that I can use to create new files. And I decided to use Oracle Policy Automation for the job. Here is the sort of thing I am talking about:

Extension Code

By answering a few questions about the code you want to write, the Project generates a template for you to copy and paste into a new Text File and there you have your code to start writing something interesting. There is a Copy to Clipboard button at the bottom of the code.

In the end, I decided to add a few things to the examples to act as learning tools:

  1. The Input Control has Validate and Update options that help understand the way these Keys actually are supposed to work. Validate throws an error message to the user if the text entered does not match a specific validation rule.
  2. The Update Key shows how update is fired whenever anything on the Screen is updated. Useful for updating your Control in response to other activity on the Screen. As an example, the color of the Input changes each time Update is fired.

The Extension Code Generator also includes the custom Search as templates with the following options:

  1. Search lets you choose from a series of standard searches (Airlines, Railways Stations, etc) as well as allowing you to configure your own REST call and lets you add any Headers you need to make your call.

Here is a video that will hopefully shed some more light on what this Project does (or tries to do)!

This seemed like a fun thing to do in Oracle Policy Automation – if you would like a copy of the (18C) project then please leave a comment and I will tell you all about it’s foibles :).