JDeveloper 11g together with Oracle ADF provides fully functional LOV component, in 11g you can define LOV in Model, for specific attribute in View Object (ADF BC). However, at the moment there is problem with non-model LOV, main problem - Search region for non-model based LOV not available. For example, you can check my previous sample application, developed with JDeveloper 11g TP3 - List-Of-Values Component in Search and Edit Form. In this application, I was using non-model LOV, it was based on variable in Page Definition. However, same type LOV appears differently in JDeveloper 11g TP4 - without Search region, and its not clear if it will have Search region in next release.
So, what I want to say - usually its not recommended to reinvent the weel, but in practice every developer should know how to implement similar component functionality manually. With Oracle ADF you can implement your own LOV, but if you can wait for new release, or not facing problems with standard component, may be there is no need to implement own...
You can download my sample application - CustomLOV.zip. This application demonstrates how to implement own LOV functionality. Next step will be to implement custom ADF reusable component for LOV. Similar as Glasspane ADF reusable component - Glasspane in ADF Faces RC.
Now I will describe main steps, you can follow if there will be a need to have custom LOV type functionality.
First, we need somehow to open dialog window, it can be done relatively straightforward - to put af:clientListener operation on selected af:inputText field and specify dbClick type for this action. This will allow to raise popup with LOV when dbClick event will be catched.
Popup with our custom LOV is opened using Javascript function.
LOV is based on two sections - Search parameters and table with Results:
Main trick in this application is applied for row selection from LOV. Its not a problem to select row and return it by pressing OK button. But, its little bit more complex to return selected row just by double clicking on any row. Its a problem, because selection event is fired on single selection click, but not on on double click. However, you shouldn't forget - we are using ADF, almost all problems can be solved here ;) So, what i did - I have set af:clientListener with dbClick type for Results table and additionally have set af:serverListener for the same Results table.
Idea - when user performs double click event, Javascript client listener function is invoked and this Javascript function invokes Java method declared in af:serverListener. This Java method basically will retrieve current row from Results table iterator - thats all.
Here are two Javascript functions from developed sample application:
First function is responsible for popup with LOV invocation, second reacts to dbClick event in Results table.
Java code in Backing bean is concentrated into three main methods:
First method works as Dialog Listener, this means is invoked when LOV is closed using OK button. Second method is invoked from Javascript client listener function, when dbClick event is catched in LOV Results table. Third function just retrieving value selected in LOV and assigning it to parent field.
In sample application, LOV is defined for LocationId field, just double click on this field:
Our custom LOV is opened with Search region and Results table:
You see, LOV looks like standard Oracle one, however may be even better - possible to control Results table size :) And finally, when row in Results table is double clicked, selected data is returned to parent component:
very nice and useful article.
ReplyDeleteThanks Pradip !
ReplyDeleteHi Andrejus. I couldnt run your CustomLov project. You have a local DB connection in there (192.168.x.x)
ReplyDeleteHi,
ReplyDeleteThats for sure, you need to change database connection in sample application. Do you know how to do this?
Regards,
Andrej
Hi,
ReplyDeleteI try to use your example to open a new page when a record in a table is double-clicked however it is not working in 11g production. I can not add the serverListener to a table. I get the error: Server Listener is not a valid child of a Table. Any ideas?
Andre
Its a bug in JDev wizard. You need to add in Source, it will show error but will work on runtime.
ReplyDeleteRegards,
Andrej
Hi Andrejus,
ReplyDeleteI have two inputText,how to make the focus of the first pass to the second box?
I work with fragment pages (.jsff) where to put the javascript code?
Thanks!
Hi all,
ReplyDeleteI created a project with fod, created a database connection, the entities from the tables and the view objects. I'm trying to run the modue and it always give me the message :
(oracle.jbo.ConfigException) JBO-33003: Connection name fod not defined
i have done the following steps
1. Expand the Application Resources accordion, then the Connections folder and the Database node.
2. Does the Database node contain a node for your connection?
3. Right-click the node for your connection and select Properties in the context menu.
4. In the Edit Database Connection dialog, click Test Connection. Is the test successful?
5. In the navigator, double-click your business components project to edit it.
6. In the Project Properties dialog, go to the Business Components page.
7. Is there a connection selected, and is it the same connection that you tested in step 4?
8. Click the pencil icon to edit the connection, and click the Test Connection button. Is the test successful?
it is successfull but when iam trying to run the module it is giving the same errro.
what would be proble plz help me
thnx.
Hi: This looks good. Do you have an 11g example of using an LOV in an ADF table (e.g. displaying multiple email addresses per row in a table that displays persons).
ReplyDeleteThanx Andrejus.
ReplyDeleteHow would you pass a value from a field item on the popup page to the field on the calling page?
Hello,
ReplyDeleteI was working today exactly on the same thing. If let's say you have on the page field with #{bindings.JobTitle.inputValue} value, you need to set same value expression for the field in popup component. Both fields will work on the same iterator and value will be passed automatically. You need to set PPR refresh on Iterator in Page Definition in order to make it work.
Regards,
Andrejus
Hey Thanx Andrejus for your help with passing values from a popup field to the calling page. I had previously implemented this functionality with a set action listener method and was successful. However, your approach looks to be more efficient, so i will give it a try. Thanx again!
ReplyDeleteHi Andrejus,
ReplyDeleteI am using Oracle JDev 11.1.1.0.2, and run your application and got the screen showing the Deapartments, but with following error on my html page:
Error : 'AdfAgent.AGENT' is null or not an object
Thanks
Ali
How to create a dynamic LOV with some complex query containing more than one table
ReplyDelete