Browse Category by ADF
View Post

ADF: Update model in value change listener

There are some cases when we need to get a value associated to the new value that we have selected in a selectOneChoice, or that we have typed in an inputText.
In this cases we will not be able to get that value, as the only thing we can do is to get the new value from the ValueChangeListener object.

Continue Reading

View Post

ADF: using popupFetchListener to execute a method before the popup opens

When developing ADF applications, a common way to create or update a record is doing it in a popup. There are many ways to do it that I have seen in some of my last ADF projects, for example:

  • Executing createInsert operation in the button’s action listener and then opening the popup programmatically 
  • Using an action listener to create the record and using showPopupBehavior with triggerType set to click (In this case, if the button is disabled on some condition, the actionListener will be executed anyway)

In this post I am going to show you another way, using popupFetchListener.

In this example we are going to drag and drop Departments view object as a table (we don’t really need it but we can see the new created record), and 2 buttons, one for creating records and other for editing them.

In each button we are going to add a showPopupBehavior component  with triggerType property set to action and popupId proerty set to the id of our popup.

Once we have the buttons, we create a popup and drag and drop departments view object as a form.
After that we have to create a popupFetchListener in the properties panel.

 This will create a method in our bean where we have to check the button we have clicked in order the call CreateInsert opeartion only when we click on Create button.

This is how the page definition file looks like. The tree binding, 4 fields of the form and the create insert operation that we call in the popupFetchListener.

The result of this implementation.

You can find the code of this post in Github.

View Post

ADF has been released: Bug fixes and lots of new features

Oracle has released a new version, not just and ADF version, it is a new release for all Oracle Fusion Middleware products.

Although this could be seen as a minor release, it comes with lots of new features in ADF Business Components, mainly in REST support, and Data Visualization Tools among others, as well as a lot of bug fixes.

There are many new enhancements to Gauge components, we can now set a title, border and also set the indicator wider that the plot area.

There are some new components, the picto chart.

And the tag cloud. This is a component I have been expecting long time ago as we were able to use it as you can check in this link (Marrying the Worlds of ADF and HTML 5) but it was not available out of the box.

In ADF Faces there are two more cool enhancements as we can set an af:table to cache fetched rows so there is no need to re-fetch when the user scrolls back, and af:inputDate opens directly on the client instead of going back to the server.
There are more changes and improvements in ADF BC as REST Services, Groovy support and desktop integration.
You can check the complete list of new features and bug fixed in this link: Oracle JDeveloper and Oracle ADF 12c ( New Features
View Post

ADF: af:table filter modifications using a custom Query Listener

In one of our last projects we had the requirement to allow the user to filter tables using the table filter feature. By default you can filter String fields starting with the word that the user provides, but our customer needed to find the rows that contained the criteria.

This is an easy task that can be accomplished by creating a custom Query Listener method.

As by default the filter works with “Starts with” condition you will see that filtering by “tra” will give no result although departments like Administration exists.
In this example we will use Departments table in HR schema.

When we drag and drop to create a table and we set it to be filterable, we can see that a query listener has been created by default.

As we need to modify the filter values we need to create ouor own query listener.
The idea of this method is to get every value, and if it is String we have to change the original value and concatenate ‘%’ before and after the value.
After that we need to call the default query listener that we can get from queryListener property in the table component.
If we end here, the  user would see the new filter with % symbol, so we are going to remove it and leave it as the user type it.

This is the helper method we use to call the default  query listener.

The last step is to set our new method as the table’s query listener.

If we run the application we can see that if we filter by “tra”, we can now see some records.

View Post

ADF: DVT Charts based on a dynamic vo

In one of our latest projects we had the requirement to create a reporting feature that based on some filters we had to built a custom query and display those results in a chart.
In this post I will show you the approach we followed.

The first step is to create a dummy view object. We are going to use SELECT * FROM DUAL as its  query.

After this we need to add this view object to our Application Module data model and also create AM implementation class.

The main thing we are going to make is to create a List in our bean, based on a POJO that we will populate with our viewobject data.
We are going to add 3 attributes to our java class with their getter and setter methods.

After that, in our page’s bean we need to create a couple of properties. The first one is the List that will hold the values, and that will be the value property of the graph, and the second one is a String that will be the value property of the input where we will introduce the query.

The next method of the bean is the one to create the graph.
The first three lines let us create the viewobject a runtime passing the query and the view object instance.

In the rest lines of our method we are just iterating the view iterator and populating the graph List object.

The last step is to create the page that will looks like this

In the page definition file associated to the page we have to create the iterator binding that we are using in the bean.

While testing if we use this query, we will see a graph with the data.

And if we change it, the graph will change with the new query’s data.