Use DVT in an ADF Table

The use case here is based on the priority from a task. The requirement was not to show the priority as number, but with a color. It was surprisingly easy to accomplish this in ADF with DVT.

To illustrate I use a read only VO to show the priority:

Drag & Drop as a read-only table with sorting enabled:

We won’t use the outputText, but we’ll reuse the binding that is created.
Select the gauge component from the Component Palette & drag and drop it in the column.

 In the wizard choose for the LED:

This generates an dvt:gauge component that is empty, now we need to set a few properties.
As value we set the #{row.prio} binding that the outputText created for us.
Change the inlineStyle to get the correct width & height.
Choose the colors that you wish to show for the different priorities. I choose red for 1, yellow for 2 and green for 3 as 1 being the highest priority and 3 being the lowest.
This results in the following code: 


If you run this, it will result in the following column in a table:

Very easy to read for the user and if you ticked the sorting you will see that the column is still sortable as you would have expected with a number as priority:

You can see the (not so impressive) results live here at the Oracle Public Cloud.

Create the IdcContext based on an application resource connection

In the previous post I showed how to use get_file with the RIDC protocol. You create an IdcClient & IdcContext and use this to set up the connection. However, it is also possible to use the application resource connection for this.

First set up the connection in JDeveloper:

This will result in an entry in the connections.xml in your META-INF:

Now you can create an AdfConnectionFacade based on the name of this connection.
Then you create the IdcClient & IdcContext based on the AdfConnectionFacade:
      //Use the defined WebCenterContent connection
      AdfConnectionFacade acf = new AdfConnectionFacade("WebCenterContent");
      IdcClient idcClient = acf.getIdcClient();
      //Create an idcContext based on the Credentials.
      IdcContext idcContext = new IdcContext(acf.getUserCredentials("user"));
The parameter “user” in getUserCredentials refers to the user you see in the connections.xml. 

Get a Document out of WebCenter Content by ID

The use case was to show PDFs in the browser that come out of WebCenter Content.
I achieved this by using the RIDC library.

The information you need, you can find in the WebCenter Content Admin Server.
Login and go to the General Configuration. Look up the IntradocServerPort number that is configured there, so you know the portnumber for the call.

It only takes a few lines of code to get the InputStream from the document:
      IdcClientManager manager = new IdcClientManager();
      IdcClient idcClient = manager.createClient("idc://servername:portnumber");
      IdcContext idcContext = new IdcContext("username", "password");

      DataBinder requestBinder = idcClient.createBinder();
      requestBinder.putLocal("IdcService", "GET_FILE");
      requestBinder.putLocal("dID", "id");

If you want you can get some extra info from the response:

And that’s probably all you need. 

Fire an methodAction from a component without an actionEvent

I had an use case in which I needed to execute a methodAction from a selectOneChoice.
Looking around on the net I found this blog from Frank Nimphius which was usefull:

But there are more ways to achieve what we needed.
The selectOneChoice component doesn’t support action or actionListener. So I misused the valueChangeListener to do this. We cannot call a taskflow action, nor can we programmatic call the actionListener because of the JSF Lifecycle phase we are currently in (JSFProcess Validations), the methodAction will use the oldValue from the selectOneChoice and not the newValue.

I will describe two more options to achieve the correct result:
1.       Programmatic queue the task after the InvokeApplicationPhase.
2.       Use the bindings to invoke the Action.

Programmatic queue the task After the Invoke Application phase
On the page, set the valueChangeListener to a method in your backingBean.
In this method you have to perform the following steps:
  • Get the OperationBinding.
  • Get the AdfFacesContext.
  • Put the OperationBinding on the queue for after the invokeApplicationPhase.
    //get the OperationBinding.
    final BindingContext bctx = BindingContext.getCurrent();
    final BindingContainer bc = bctx.getCurrentBindingsEntry();
    final DCBindingContainer dcbc = (DCBindingContainer) bc;
    final OperationBinding action = dcbc.getOperationBinding("bindingName");

    //Queue action.execute after InvokeApplicationPhase.
    final AdfFacesContext afc = AdfFacesContext.getCurrentInstance();
    afc.queueTaskForAfterPhase(FacesContext.getCurrentInstance(), PhaseId.INVOKE_APPLICATION, new Runnable()
      public void run()

Use the bindings to invoke the Action
Create a new executable:
Choose an id and choose the (method)Action that you want to bind.
In the properties choose refresh: renderModelIfNeeded.
Point the refreshCondition to a Boolean in the BackingBean.
On the page point the valueChangeListener from the component to a method that sets the boolean to true.

A new Fusion Middleware Blog

I decided that it is time for me to start a blog about my experiences with Oracle Fusion Middleware & ADF. For those people that do not know me, my name is Richard Olrichs, I am an Oracle Ace & Certified Specialist from the Netherlands. I have been working with Oracle ADF since 2007.

I hope I can contribute something to the community.