Wednesday Feb 20, 2013

Implementing “Contains” autosuggest behavior for an Input Combo Box LOV

The framework provided autosuggest behavior performs a “Starts with” search for displaying the values in the autoSuggest of an Input Combo Box List of Values. In this post, we will see how to implement a custom autosuggest behavior which returns values by performing a “contains” search.

The following image shows an input combo box list of values dropped on a .jsff:

We can add an autosuggest behavior from the Structure window by clicking af:inputComboBoxListOfValues -> Insert inside af:inputComboBoxListOfValues -> ADF Faces -> Auto Suggest Behavior

This is the autosuggest behavior provided by the framework which returns all values which START WITH the partial string typed by the user in the input combo box list of values. We will write a custom method in the backing bean which returns the values we want to show as follows:

As seen above, this method takes a String parameter which is the partial string entered by the user and it returns a List of SelectItems which have that string as a substring. The list is retrieved in the AMImpl as follows:

In this method, we get the VO which is used to populate the input combo box list of values and apply the following view criteria on it:

The bind variable ‘Bind_ResourceName’ is set to the partial string entered by the user. By applying the view criteria we get an iterator to all the rows matching this condition, i.e. all rows where the value of “DisplayName” contains the string entered by the user.

Finally, we use the custom method from the bean instead of the framework generated suggestedItems:

Now, when the user types in the input combo box list of values, all the values containing that partial string are displayed in the autosuggest as shown:

Friday Aug 24, 2012

In-Memory Filtering and RowMatch


We have a view object named ExampleVO which is based on entity object ExampleEO, and this VO has an attribute called ExampleFlag. ExampleVO has a clause in the base query that only allows rows that match the criteria ExampleEO.ExampleFlag = ‘Y’. We have another view object named CreateExampleVO that is used to add new rows to the ExampleEO. Both these view objects have view link consistency enabled.


Now if we insert a row into CreateExampleVO with the value of ExampleFlag as ‘N’ one would expect that this row will not be included in the ExampleVO. This is not the behavior that is observed. We now have a row in the ExampleVO that does not match the clause. If view link consistency is enabled, any new row created by any view object based on the same entity is added (regardless of the query) to the row set of all VO’s based on that EO.


If the view object has a design-time WHERE clause like ExampleEO.ExampleFlag = ‘Y’, you can apply a RowMatch object to your view object to perform the same filtering in-memory.

The filtering expression of the RowMatch object you specify prevents new rows that don’t match the condition from being added.

You can add a RowMatch to the view object by creating the same clause in a view criteria and applying it. The mode for said view criteria should be set to ‘In-memory’.
Note: You don’t have to remove the where clause from the query

Relevant Links.

Thursday Jul 05, 2012

Bind Variable and SQL error during statement preparation

 I was getting the following exception at run-time.

JBO-27122: SQL error during statement preparation. Statement: SELECT AxEO.A_ID, AxEO.B_ID, AxEO.C_ID, ByEO.A_ID, ByEO.B_ID, ByEO.C_ID, Cz.A_ID, Cz.B_ID, Cz.C_ID FROM ABC_x AxEO, ABC_y ByEO, ABC_z CzEO WHERE AxEO.A_ID = ByEO.A_ID AND  CzEO.A_ID = :Bind_PId

I copied and pasted the query on SQL worksheet, replaced :Bind_PId with a valid id, and executed the query. The query worked alright, implying the query was alright. I tried to connect to different DBs but the issue persisted, meaning it was not a DB issue either.

Finally, the root cause was found to be in the concerned VO; one of the bind variables (say Bind_TId) was marked "Required". De-selecting the Required check-box resolved the issue.

In retrospect, the issue looks to be rather straight-forward. However, the error message is not very helpful, if not misleading. Besides, it's counter-intuitive to think that a bind variable which is not being used in a query can cause error while statement preparation. The other bind variable - Bind_TId - was being used in other view criteria, not the view criteria involved in the given query. Still, it was required.

Wednesday Jun 27, 2012

Using Exception Handler in an ADF Task Flow

Problem Statement:

Exception thrown in a task flow gets wrapped in an exception that gives an unintelligible error message to the user.

Figure 1

Solution 1. Over-writing the error message with a user-friendly error message.

Figure 2

Steps to code

1. Generating an exception: Write a method that throws an exception and drop it in the task flow.
2. Adding an Exception Handler: Write a method (example below) to overwrite the Error in the bean or data control and drop the method in the task flow.

Figure 3

This method is marked as the Exception Handler by Right-Click on method > Mark Activity> Exception Handler or by the button that is displayed in this screenshot

Figure 4

The Final task flow should look like this. This will overwrite the exception with the error message in figure 2.
Note: There is no need for a control flow between the two method calls (as shown below).

Figure 5

Solution 2: Re-Routing the task flow to display an error page

Figure 6

Steps to code

1. This is the same as step 1 of solution 1.
2. Adding an Exception Handler: The Exception handler is not always a method; in this case it is implemented on a task flow return.  The task flow looks like this.

Figure 7

In the figure below you will notice that the task flow return points to a control flow ‘error’ in the calling task flow.

Figure 8

This control flow in turn goes to a view ‘error.jsff’ which contains the error message that one wishes to display.  This can be seen in the figure below. (‘withErrorHandling’ is a  call to the task flow in figure 7)

Figure 9


ADF Tips and Tricks


« July 2016