Skip to main content

ADF 12.x: Changing the List Of Values "No rows to display" text

In this post I describe how I implemented an interesting Use Case where the customer wanted to have an alternate message in the LOV when there is no data found. We all know how this can be changed in an af:table component by simply changing the emptyText property. In a List of Values, this works 'slightly' different.

Lets start with the basics

By default you will see the following List Of Values, telling you that no data was found:

However in the case of my customer, they were not happy with the text. So I had to come up with something else. That is interesting, because the ListOfValues is an ADF component in itself and the individual components inside the LOV cannot be manipulated by means of properties. I had to find a way to get access to the table component inside the List Of Values.
The way to do this has been described by Frank Nimphius, a long while ago, in his Forum Harvest posts. To be more specific, it is the harvest of November 2010, section "How-to define access keys to buttons displayed in an LOV dialog"

This really helped me to solve the issue and exactly describes what should happen at runtime.

  1. A user clicks the LOV button next to an Input List of Values component. In response to this, the LOV component launch event is fired, which we listen to in a managed bean.
  2. The launch event however is handled during the JSF Invoke Application phase, whereas the LOV displays during Render Response. Because of this, it is not possible to use a dialog launch listener to set the access keys for the buttons. Instead, the launch listener is used to invoke client side JavaScript.
  3. The client side JavaScript addresses an af:serverListener component to queue a custom event in ADF Faces. The custom event invokes a managed bean method that accesses the list of value component to eventually find the table component.

I started with the code sample as was provided in Franks post and was able to extend it for my needs. The trick is in lines 32-39:

1:    //method called from the server listener  
2:    public void changeLovInternals(ClientEvent ce) {  
3:      //get the LOV component binding reference  
4:      RichInputListOfValues lov = getListOfValues();  
5:      String id = lov.getClientId(fctx);  
6:      RichPopup popup = null;  
7:      String facetName = null;  
8:      UIComponent componentFacet = null;  
9:      Iterator facetNames = lov.getFacetNames();  
10:      while (facetNames.hasNext()) {  
11:        facetName = (String);  
12:        if (facetName != null) {  
13:          componentFacet = lov.getFacet(facetName);  
14:          if (componentFacet != null && componentFacet instanceof RichPopup) {  
15:            popup = (RichPopup) componentFacet;  
16:            break;  
17:          }  
18:        }  
19:      }  
20:      RichDialog lovDialog = (RichDialog) popup.getChildren().get(0);  
21:      lovDialog.setCancelTextAndAccessKey("&Take me back");  
22:      lovDialog.setAffirmativeTextAndAccessKey("&Make my choice");  
23:      //refresh the LOV to show the buttons  
24:      AdfFacesContext.getCurrentInstance().addPartialTarget(lovDialog);  
25:      // I found that the dialog consists of a panelGridLayout with 2 gridrows  
26:      if (lovDialog.getChildCount() == 1 && lovDialog.getChildren().get(0) != null &&  
27:        lovDialog.getChildren().get(0) instanceof RichPanelGridLayout) {  
28:        RichPanelGridLayout panelGridLayout =  
29:          (RichPanelGridLayout) lovDialog.getChildren().get(0);  
30:        List uiCompList = panelGridLayout.getChildren();  
31:        // always gridrows and always two.  
32:        if (uiCompList.size() > 0) {  
33:          // the first one is the search panel  
34:          // the second contains the table  
35:          RichGridRow richGridRow = (RichGridRow) uiCompList.get(1);  
36:          RichGridCell richCell = (RichGridCell) richGridRow.getChildren().get(0);  
37:          RichTable theTable = (RichTable) richCell.getChildren().get(0);  
38:          theTable.setEmptyText("Really, this is something, but it works");  
39:          AdfFacesContext.getCurrentInstance().addPartialTarget(theTable);  
40:        }  
41:      }  
42:    }  

When you run the application now, the LOV will display the alternate text

If you know how to get into the internal structure of an inputListOfValues, or any other component, you will be able to manipulate these components. Note that there is no guarantee that these manipulation will work after a upgrade. Oracle can change the implementation. This is for instance what happened with the inputListOfValues when the panelGridComponent became available. The internal structure of the ListOfValues component switched from using PanelGroupLayout and PanelHeader to using the PanelGridLayout component.
The solution in this post is implemented in 12.1.3. I did not check if Oracle changed the inputListOfValues in 12.2.

The code for this post can be found here on GitHub.

Most credits go to Frank Nimphius for his Forum Harvest post


Popular posts from this blog

How to use node-red to interact with twitter

Recently I had to setup an application that was able to read twitter and, based on some predefined keywords,  had to reply to specific tweets. I decided to have a look at node-red to set this stuff up. It proofed to be rather straightforward and easy to implement. The hardest part was to get approval for a twitter developer account. In this post I describe how I used node-red and how I implemented the interaction with twitter. What is node-red, and how to use it? Node-RED  ( ) is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.  You can use node-RED in many ways, but for the purpose of this demo I decided to run it in a docker image. I used the way described here ( ), as this i

How to: Adding Speech to Oracle Digital Assistant; Talk to me Goose

At Oracle Code One in October, and also on DOAG in Nurnberg Germany in November I presented on how to go beyond your regular chatbot. This presentation contained a part on exposing your Oracle Digital Assistant over Alexa and also a part on face recognition. I finally found the time to blog about it. In this blogpost I will share details of the Alexa implementation in this solution. Typically there are 3 area's of interest which I will explain. Webhook Code to enable communication between Alexa and Oracle Digital Assistant Alexa Digital Assistant (DA) Explaining the Webhook Code The overall setup contains of Alexa, a NodeJS webhook and an Oracle Digital Assistant. The webhook code will be responsible for receiving and transforming the JSON payload from the Alexa request. The transformed will be sent to a webhook configured on Oracle DA. The DA will send its response back to the webhook, which will transform into a format that can be used by an Alexa device. To code

ADF 12.1.3 : Implementing Default Table Filter Values

In one of my projects I ran into a requirement where the end user needs to be presented with default values in the table filters. This sounds like it is a common requirement, which is easy to implement. However it proved to be not so common, as it is not in the documentation nor are there any Blogpost to be found that talk about this feature. In this blogpost I describe how to implement this. The Use Case Explained Users of the application would typically enter today's date in a table filter in order to get all data that is valid for today. They do this each and every time. In order to facilitate them I want to have the table filter pre-filled with today's date (at the moment of writing July 31st 2015). So whenever the page is displayed, it should display 'today' in the table filter and execute the query accordingly. The problem is to get the value in the filter without the user typing it. Lets first take a look at how the ADF Search and Filters are implemented by