Browse Year by 2015

PCS: Starting a process instance remotely

While implementing an Oracle Process Cloud Service PoC we had the requirement to allow users to start an instance using a form in their custom mobile application and also using the workspace.
We have a ‘Form Start Event’ so users can start the instance thought the workspace. We also added a ‘Message Start Event’ in order to publish it as a web service.
Having that process deployed, if we head to ‘Deployed Applications’ in workspace main page.

And click on the button in ‘Actions’ column.

We can see the web services exposed.

If we use that wsdl url in soapui we see that we have 2 operations, one for each of the start events.

Executing both, we can see that even using ‘Form Start Event’ we can start a process instance remotely as an operation is automatically created in the web service, so we can remove the ‘Message Start Event’ as we can meet both requirements just using the ‘Form Start Event’.

If we open aproval form in the workspace we can see that the data sent from soapui has been successfuly sent.

ADF: Display Map values in af:table

When we want to populate an af:table programatically we usually use a collection based on a java bean (e.g. List<MyObject>) but in this post of JDeveloper & ADF the developer required to populate the table with Map values.
First we need to create a Map in our bean and add the values that we are going to show in the table.

If we try to populate the table we can see tat we need to know the keys of the Map to get the values.

As you can see Value Columns displays the value in the Map for ‘Key 1’ key, but using this method we can not dynamically display all values.

To solve this issue we need to create an array in our bean where we will have all keys of the Map.

Now that we have created in our bean all that we need, we can start building the table structure.

On the table of the second image we need to make some changes. First, instead of using Map property, we have to use the key array we have just created as value property of the table.

And, as we have to access Map values, we have to add an af:iterator inside the table and add the columns we need inside this iterator. The value property of this iterator is the Map property in the bean.

This way, to retrieve keys we are going to use #{row} and to retrieve values asociated to a key we are going to use #{var[row]}.

Oce we have finished with the changes, if we run the application we can see that all the values of the Map are displayed in the table without the need of knowing the keys of the Map.

ADF: Switching between skins on runtime based on the url

Andrejus posted a couple of months ago how to switch between alta and skyros in ADF 12c. This is a cool way to start the migration from 11g to 12c and Alta UI. I am going to show you another way to use one skin or other based on the page you are.

Firstly we have to create a bean and a property inside it where we are going to store the current skin. We have to set this bean as sessionBean.

After that we have to set a bean property in skin-family in our trinidad-config so we can set the skin dynamicaly.

The next step is to create a filter. In doFilter we are going to evaluate the URL and set the skin based on that value. We also have to instantiate the bean and add it to sessionScope becasuse the first time it will be null.

Once we have the filter created we have to add it to web.xml

Now that we have all setup, having multiple pages, if we test it we can see that the the page “alta” will display AltaUI skin and “skyros” page wil dispklay Skyros skin,

MCS: Custom API that calls a SOAP Web Service

In one of the other posts about MCS i showed how easy we can create an API that makes a call to an external REST web service. MCS Connectors also allows to connect to a SOAP web service. Although there is a couple of different things I am going to start the process from the beginning.

  • Creating the connector

We have to head to Connectors page, click on New Connector button and pick SOAP sub menu.
In the popup we need to fill some information including the SOAP web service URL.
We are going to use a public weather service: 

Our connector has been created. Now we can configure settings like connection timeout or add security policies.

In this example we are not going to add any extra setting so we can continue to the last step, Test.
As you can see although this is a SOAP web service, the tester let us introduce a JSON payload.
This is one of the great things of MCS, the SOAP Connector uses a JSON translator and transforms automatically the JSON that we are going to use to the xml that the SOAP web service needs.

Now if we set a zip code into the JSON and click on Test Endpoint we can see that the web service returns us the weather of that zip code.

  • Create and Implement a Coustom API.

Now that the connector is up and running we need to create a Custom API that will make the call to the connector.
We have to navigate to APIs page and click on New API.

In the popup we have to fill the name of the API and a short description or upload a RAML file.

Now there is a setting we have to change in order to avoid authentication and having to create users. Head to Security option and be sure to select On  in Allow Anonymous User Access.

We need to create an Endpoint we click on New Resource and add {zipcode}. This is the parameter that our API will need to send it to the connector call.

After that, clicking on methods (in the right hand side) we will add a GET method.

Now that we have designed the API, we need to implement it by downloading the JavaScript Scaffold.

In the zip file there are 4 files.

package.json is the file where we can set the dependencies of our API, in this case we have to add our connector’s URI.

In myweatherapi.js file we have to make the implementation.
There is a couple of things that differs from the REST connector call.
  1. In the URI of the connector we also have to add the name of the method that we are going to call, in this case GetCityForecastByZIP.
  2. We need to build the JSON that we will send to the connector.
To achieve the second point we can use the example payload from the connector tester and put zipcode parameter.
After building the JSON we have to make a post call to the connector.

Once we have finished the implementation we have to pack the files in the same zip filethat we have downloaded and upload it to MCS.
The last step is to test out API. Just type a zip code, select the MBE and version and click on Test Endpoint. You will see that the API works and returns us the weather forecast.

ADF: Display current selected node in af:tree

Some times when we want to display some master detail data we use an af:tree because it is a easy and elegant way to display data. I am going to show you how to display data of the selected node in an af:tree based on a single view object.
We are going to use this data model based on Oracle hr schema.
The first thing we have to do is drag and drop the EmployeesView1 view object from the data control palette to the page.

After that we also have to add a form based on EmployeesView. Here is the problem. What view object instance are we going to use to create the form? If we use Parent instance, although we select a child node, in the form we are going to see just the parent node data.

In order to solve this issue we are going to create a new instance of the Employees view object, in this case EmployeesDisplayVO.

The next step is to create a Action Binding with setCurrentRowWithKey operation of the new view object instance in the pagedef of our page.

The last step is to create a custom Selection Listener in our bean and associate it to the af:tree

In this method, a part from ejecute makeCurrent method of the treeModel, we are going to get selected keys and execute setCurrentRowWithKey method with the selected key as parameter.

When we select the first node only one key is in the list, but if we select the second or third level we will have one key per level and we will have to use keyList.get(keyList.size() – 1) in order to get the last selected key.

If we run again the application we can se that if we select any node we can see its information in the form.