Wednesday, February 6, 2008

List-Of-Values Component in Search and Edit Form

Sample application described in this post contains high practical value, it implements real use case. Defined use case - based on value selected in List-Of-Values (LOV) component, perform query in database and display results in form. Form with results is updated, when value in LOV is changed.

You can download developed application - LOVSearchEdit.zip and run it in JDeveloper 11g TP3, additionally you need to have Oracle XE database with HR schema.

Model part of sample application contains Locations Entity object and two View objects - LocationsView and CountriesLovView. First View object is based on Entity object and second View object is read-only, is used in LOV component.


View object - LocationsView is used to query database and return results displayed in form. In other words, this View object perform Search action. LocationsView contains WHERE clause with bind variable, it retrieves Locations by specified Country Id:


In View layer of our application, Search action is initialized by LOV component for Countries. I have created this LOV component as unbounded and not related to Model. I achieved this, by declaring countryIdVar variable in Page Definition, and using this variable as Base Data Source for LOV component.


You can create unbounded LOV component in JSPX page, by dropping empty af:inputListOfValues from ADF Faces Common Components palette. As next step, right-click on newly created component and select from menu - Bind to ADF Control. In Edit List Binding dialog you should choose variables as Base Data Source and in List Data Source choose View object that you want to use as list data provider. For example, in my application this dialog looks like this:


To execute Search action, I'm using ExecuteWithParams action defined in Page Definition and associated with LocationView. Input parameter for bind variable is retrieved directly from attribute wired with LOV component Base Data Source variable.


Defined ExecuteWithParams action is invoked from countryIdReturnPopupListener created for Countries LOV:


And finally last step, in order to refresh form with displayed Search results, you need to put AutoSubmit=true for Countries LOV component. And change PartialTriggers property of form with results to point to Countries LOV Id.

And yes, all this stuff really works. When page is opened and there still no value in LOV is selected, empty form is not displayed:


Let's select any value in LOV component:


Search results are retrieved and form with data is opened. User can navigate through results and update locations from selected country:

75 comments:

Karthika said...

Could you please give the steps to create this

Andrejus Baranovskis said...

Hi Karthika,

I dont have screenshots for this application. But you can research sample application, or ask what particular step is not clear.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,

Have you had a chance to work with re-usable components? Can I re-use a page in 2 different pages - one is as read only view and other is in edit mode?
So basically, I want to control the parameter passed to this page and determine if the fields can be updated or not?



Thanks,

Andrejus Baranovskis said...

Hi,

Yes I was working with reusable components in 11g. You can take a look into regions. Its Chapter 17 in Fusion Developer’s Guide for Oracle Application Development Framework 11g.

Regards,
Andrejus

Anonymous said...

Could you please give me the code snippet for the method getBindings() that you have used in countryIdReturnPopupListener()method?

Also I would like to know moew about the NDValue you had provided "${bindings.countryIdVar_Attr.inputValue".What is the countryIdVar_Attr? Isn't the variable name you had created in just countryIdVar?

Andrejus Baranovskis said...

Hi,

Actually, you can just download sample application this post is based on. I provide link to developed sample in the beginning of the post.

Regards,
Andrejus

Raj said...

Hi Andrejus,
When i run the page, the LOV 'Search and select' popup does not have the search region.

Could you please tell me how to get the search region ?

i got only the results table and two buttons.

Thanks

Andrejus Baranovskis said...

Hi Raj,

In View Criteria Editor there is Control Hints tab. You can select Basic or Advanced modes in this tab, Advanced means with Search functionality.

Regards,
Andrejus

João Augusto said...

Hi Andrejus.
Great example. Do you have any examples of using inputListOfValues with query options, without ADF ? Just using ADF Faces RC and implementing the corresponding models ?

Thanks a lot.

John

Andrejus Baranovskis said...

Hi,

You mean with TopLink for example?

At the moment I have only with ADF BC actually. But its good idea to try with TopLink, will do it in near future :)

Thanks,
Andrejus

João Augusto said...

Yes I do mean with Toplink (essentials), and not use ADF BC (view objects, data binding, and so on).

Is there a way to see how Oracle's BC implements the models needed for the query ?
(oracle.adf.view.rich.model.QueryModel). I'm getting confused in how to use these models, and Oracle's ADF Faces Rich Client Demo, is using an older API, which has some methods (like createModel), that the latest version does not have.

Thanks again.

John

Andrejus Baranovskis said...

John,

Actually, there should not be difference what to use in Model layer - ADF BC or TopLink. I will do similar sample with TopLink in my next posts.

Thanks,
Andrejus

Anonymous said...

Hi andrejus,
I´m trying to follow the steps in jedev 11gTP4. But i don´t obtain the same results.
the popup of LOV appears without the search option and i don´t find the view criteria editor.
And when i select a code from the LOV pupup it doesn´t make nothing, I mean i have made a LOV with the code of the customers and i have a form with the orders of those customers thas what a want to see the orders of a specific customers and what i see is the form without data.
i have donwloaded your sample application and have checked with the mine, but don´t find any diference.
I suppose that my problem is with data bindings.
Thanks
Rowan

Andrejus Baranovskis said...

Hi Rowan,

When you define LOV on View attribute, there is option in wizard to include Search functionality.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,
it would be posible to make an screenshot of when you define a LOV attribute. I don´t find the wizard to include Search functionality.
I have achieved every thing else.
Thanks

Andrejus Baranovskis said...

Hi,

You can find this option in UI Hints tab, available in List Of Values dialog. Just look for List Search section.

Regards,
Andrejus

Anonymous said...

Hi andrejus,
Another question. And what if i want to bind the LOV with a table instead a form?
How do i bind the countryIdVar with the table?
Thanks for all your help
Rowan

Andrejus Baranovskis said...

Hi,

You can use in table those LOV's defined in View object.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,
If i use the LOV defined in View object in table, what i get is a table with a LOV in each Row of the atribute defined as a LOV.
Probably i haven´t understood what you suggested.
What I want to do is the same example that you have explained in this post but instead a form in response of the LOV a Table with the same view object and sql query.

Thanks a lot

Rowan

Anonymous said...

Hi

I´m going to answer myself.
Using task flow.
Thanks for all your blog, full of intersting examples.

Rowan

Amr said...

hi
how to declare attribute variable in page definition?

Thanks


Amr

Andrejus Baranovskis said...

Hi,

Its implemented in my sample, you can download is and research page definition file.

Regards,
Andrejus

Anonymous said...

Hi, Andrejus
It´s time to say that, thanks to your help i almost finished my first desing.

The only thing that lack to finish it at all, is that i need the LOV with search form.

You explained twice how to do this, but i don´t find the options that you say.
In the viewobject´s definition yes have found the option of make an atribute be a List of values,
as a matter of fact, i have use this way to make my search lov, but this changes all the steps
that you explained in this post.
Cause in edit list binding dialog i must take the "model driven list" option.
Doing like this the Lov appears with the search option, but now I have an very extrange error,
because the LOV wants to update it´s view, thing that i dont need.
To avoid this i have made a little trick, making the postchanges void to do nothing.
But i know that this musn´t be definitive.
So,
aftyer telling you all my pitys,
I think that what I really need is make the LOV with your steps, that is how it works fine,
and find the way to make a search lov.


Thanks a lot for all your help,

Rowan

Anonymous said...

Hi, Andrejus
I need your confirmation, cause i can see the code but can´t run your sample.
In your sample, on the view objects that you have defined there isn´t any atribute defined as a LOV.
So, runing your sample the Lov is without search option, isn´t it?
please tell if i´m wrong.
Rowan

Andrejus Baranovskis said...

Hi Rowan,

Why you can't run it? For me it runs perfectly in TP3 and TP4. I'm using unbounded LOV in this sample, not declared on View object - "I have created this LOV component as unbounded and not related to Model. I achieved this, by declaring countryIdVar variable in Page Definition, and using this variable as Base Data Source for LOV component.".

When I was running it in TP3, there was Search option available. Running in TP4 there are no Search option available.

Regards,
Andrejus

Anonymous said...

Hi, Andrejus
I can´t run it cose i can´t install HR schema on my jobs computer and at home can´t run jdev11.
I´m going to try with TP3. I think that you have give me the key again.
will tell you.

Thanks
Rowan

Anonymous said...

Thanks, Andrejus
No search option on TP4, I have post in oracle forum, asking about this...
Rowan

Anonymous said...

Hi andrejus,

Seems that never going to end my questions about this kind of LOV, ;)

Is there any easy way to take another attribute of the LOV? I mean, in your example we use CountryId, but can see in the LOV, countryName and RegionID.

What i want is take the values of selected ContryId and RegionID.

I´ve implemented making another VO with bind variable CountryID and wich select only RegionID. And then in the LOV another executewithParams.

But I think that sure that there is another easiest way. Isn´t?

Thanks,

Rowan

Andrejus Baranovskis said...

Rowan,

You are right, there is another more simple way. And, exactly today I was implementing it.

So, if you will drop me email, I will send you updated sample.

Regards,
Andrejus

giangnn said...

Hi Andrejus,

Your sample is really cool. Thanks for your effort. This approach is a bit long but very intuitive.

However, the limitation of LOV in this sample is that RegionID will be displayed eventually, which is not so user-friendly. Is it possible that the displayed value is RegionName, yet the data behind is still RegionID, so that we don't have to change query?

If your updated sample is about this, would you mind send me through email (giangnn@gmail.com). Thanks a lot.

Andrejus Baranovskis said...

Hi,

Yes, you can just change mapping columns in LOV wizard.

But, to return ID for LOV is more common. Description is usually displayed as second element near LOV component.

Regards,
Andrej

giangnn said...

Thank you, I've found a way to get it. Basically, I created 2 variables, 1 for ID and 1 for name. In the list binding editor, I map these 2 variables with RegionID and RegionName.

Anonymous said...

Hello,
(In Fusion web application)TP4

when i drag my ViewObject(where it contains a drop down list full by another viewobject) on my page as a search form , i found my dropdown list full of data that i search with and if it doesn't retrive any rows,
next time in find mode i found dropdown list is empty??? where if there are a rows retrived from first execute ,it running well and i got data in dropdown list)

and got this in log "oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding getInputValue"

thanks
greenApple

Chris Muir said...

Hi Andrejus

Looks like this post is now out of date for the production build of JDev 11g (build 5188).

In the paragraph where you describe:

"You can create unbounded LOV component in JSPX page, by dropping empty af:inputListOfValues from ADF Faces Common Components palette. As next step, right-click on newly created component and select from menu - Bind to ADF Control. In Edit List Binding dialog you should choose variables as Base Data Source and in List Data Source choose View object that you want to use as list data provider. For example, in my application this dialog looks like this:"

....the right click doesn't show the Edit List Binding dialog, but rather the "Bind to ADF Control" dialog that only allows you to select controls from Data Control Palette, not preconfigured bindings in the pageDef.

Cheers,

CM.

Andrejus Baranovskis said...

Hi Chris,

Yes, it looks they have updated wizard. However, still its possible to create unbounded LOV, by defining LOV in Page Definition and assigning Value and Model property to LOV component on page.

Regards,
Andrejus

Ramkumar said...

Hi

I am new to ADF 11g. I am trying to create Input combobox LOV exposing EJB Toplink as a datacontrol.In List binding editor,i dont know what to give in list data source and base data source.It's really confusing..

can u provide steps for creating LOV using EJB Toplink?

Thanks in advance..

Andrejus Baranovskis said...

Hi,

LOV component is not available in EJB TopLink, it comes only with ADF BC.

Regards,
Andrejus

Ramkumar said...

Hi

Thank you.
I tried to use your unbounded flow for LOV creation from a Model created by EJB(TopLink).
I am able to see the search option with list of values. On selecting one value, it throws an error like below
SEVERE: Server Exception during PPR, #1
javax.servlet.ServletException
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
Caused by: java.lang.IllegalStateException
at oracle.jbo.uicli.binding.JUSearchBindingCustomizer.getViewCriteria(JUSearchBindingCustomizer.java:1948)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding$ListOfValuesModelImpl.getCriteria(FacesCtrlLOVBinding.java:1102)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding$ListOfValuesModelImpl.getSearchRegion(FacesCtrlLOVBinding.java:1014)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding$ListOfValuesModelImpl(FacesCtrlLOVBinding.java:703)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding.getListOfValuesModel(FacesCtrlLOVBinding.java:346)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlLOVBinding.internalGet(FacesCtrlLOVBinding.java:408)

I refered to your link:Hints for List-Of-Values (LOV) in JDeveloper 11g TP3
http://andrejusb.blogspot.com/2008/01/hints-for-list-of-values-lov-in.html
But coudnt find the solution. Kindly do help me

Anonymous said...

Hi,

Use case is -

I am creating LOV with a programmatic view object. The reason for using view object is I want to use webservice call for LOV search result.

I want to call a web service to populate table in LOV Popup page. I am unable to find any event where I could call my web service.

Help documentaion refers to implementation of ListOfValuesModel.

Tried with a sample based on - http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#93

Its with Array List.

Tried with Programmatic VO, but could not populate the table.
Can we get sample/refernce for populating LOV table using Programmatic VO?

Regards,
Prafull

Kiran said...

while running application giving me error "Null Pointer Exception"

Andrejus Baranovskis said...

Hi,

Probably you need to setup database connection correctly.

Regards,
Andrejus

Anonymous said...

Hi Andrejus,

I am using JDeveloper 11.1.1.1, and as Chris alluded to in an earlier post, the "Bind to ADF Control" dialog now only allows you to select controls from the Data Control Palette. As you suggested, I tried to define an LOV in the Page Definition and assign the Value and Model properties to the LOV component on the page. However, this does not seem to work. When I try to create an LOV in the Page Definition, it forces me to create a Model Driven List (and since I'm not using a VO attribute, I do not have a Server List Binding Name). I also tried to create the LOV directly through in the source (without the wizard), but got the following NullPointerException when selecting a value in the LOV:
java.lang.NullPointerException at oracle.adfinternal.view.faces.model.binding.RowDataManager.setRowKey(RowDataManager.java:134).

I am not sure that creating an unbounded LOV component is still possible with the new version of JDeveloper. Any ideas?

Thanks,
Brad

Andrejus Baranovskis said...

Hi Brad,

I will check this and will post an update.

Thanks,
Andrejus

Graham Lounder said...

Has anyone figured out Brad's issue about unbounded LOV in the latest version of JDeveloper?

Mon said...

Hi Andrejus,

Please update if you already checked that creating an unbounded LOV component is still possible with the new version of JDeveloper (11.1.1.2). Thanks.

Dipal said...

Hi Andrejus,

I have a requirement to build similar searchable LOV but my source is EJB data control. I have pagenumber or name to pass in to retrive data from EJB. I want to display name but want to store ID in view object.

Any pointers?

Thanks,

Dipal

Anonymous said...

Hi, I have jdev version 11.1.1.3.0.
I tried to use "Bind to ADF Control" or to add a ListOfValues in the PageDef, but in both cases only the option "Model Driven List" is available, no way to select "Dynamic List". What Can I do?
Thank you, Nina

Andrejus Baranovskis said...

May be you can try to add list definition directly in XML, copy from my sample?

Andrejus

Anonymous said...

Thank you, that what I did and it worked. Now I want to add an option to search in the list. You said to change something in the ViewCriteria optin, but I don't have a ViewCriteria in my View (I have only one view) so I don't understand how to do it. I downloaded you example but I also couldn't find it there .Please give a more detailed explanation how to add the search fields option to the lov.

Thank you,
Nina

Andrejus Baranovskis said...

I guess this sample is too old for your requirements.

You should check those sample apps:

http://andrejusb.blogspot.com/2008/11/adf-query-component-and-view-criteria.html

http://andrejusb.blogspot.com/2010/05/use-case-view-criteria-conditionally.html

http://andrejusb.blogspot.com/2009/06/working-with-view-criteria-items.html

http://andrejusb.blogspot.com/2010/03/applying-view-criteria-from-application.html

Andrejus

Anonymous said...

Hi!
Thank you for the examples.
It still not working for me.
I think what I need is pretty simple. I need a button to pressed to open the list of offices for the user ( based on a view with bind variables). i managed to do it manually in the page deg using your example, but I also need an option to search in the LOV by office number and name - I added a view criteria to the view. Does the search area on the lov compenent should be added automaticly - I don't understand the connection of thoses things.
I use jdev 11.1.1.3 and 11.1.1.5 is that a problem?
Thank you!
Nina

Andrejus Baranovskis said...

Why you are not using out of the box LOV component offered by ADF BC?

Andrejus

Anonymous said...

Hello, I am sorry, but I don't understand what you mean.
I have a control block where the user selects parameters for the main sql. One of the parameters is office number and name selected from the simple view (officesList). I want to use inputListOfValues (not a combo) with a simple search option of office number and name. like shown in http://docs.oracle.com/cd/E21764_01/web.1111/b31973/af_lov.htm
"Figure 11-2 The Search Popup Dialog for a List-of-Values Component". Is there a simple way to do it?
Thank you for all your help!
Nina

Andrejus Baranovskis said...

Yes, you need to define LOV in the model first, this is ADF BC part (another developer guide) - http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcquerying.htm#CHDHBDDE

Hope this helps.

Andrejus

Anonymous said...

Thank you, If I understood it correctly it must have the main query to be bc4j and then I add a list of values on an attribute of the main view?
My main query is based on EJB and my control parameters are now based on ejb too, but we are migrating from 10g to 11g and I want to use the abilities of the inputListOfValues, but to KEEP THE MAIN QUERY IN EJB. Is it still possible?

Thank you very much!
Nina

Andrejus Baranovskis said...

I would recommend to use ADF BC instead of EJB.

Andrejus

Anonymous said...

Is there a way to implement a lov that is not connected to an attribute of some main view. I mean an LOV based on a view that fills the office number only in the inputListOfValue item it belongs to? but with search options? Thank you....
Nina

Andrejus Baranovskis said...

May be this will help: http://andrejusb.blogspot.com/2008/08/custom-lov-type-functionality-in.html

Let me know.

Andrejus

Anonymous said...

Thank you! On our 10g version we have a dynamic custom lov page. I thought that instead of changing it I could use the new component inputListOfValues, in 11g. But as I understood my case is not compatable for this. I will try to combine our existing solution and the custom LOV example you gave me.
Thank you very much for all your help!!!
Nina

Anonymous said...

When I select a value from the Search popup, only the LOV field is getting updated. For example, I have empid,empname,deptid fields in the form. empname is the LOV. now when I select a value only empname is updated with the value. I have add the returnPopuplistener method to LOV field in a Managed Bean, and also added the line AdfFacesContext.getCurrentInstance().addPartialTarget(idval).
But still it is not refreshing..Maybe Im mising something.. Pls help

Anonymous said...

hi,
i want to create a choiceList with filter , it means that i have to write something in an inputText , then when i clik on a button ,a popup will appear showing all the names which begin or contain what i have written on the input text.
Can someone help me plz
I'm a beginner on adf and this is my first application.Thanks in advance

Andrejus Baranovskis said...

Hi,

You could use ADF Autosuggest functionality for LOV.

Andrejus

Anonymous said...

Hi Andrejus,
Is there a way 'Advanced' button is removed from the LOV search region. I just need Basic search.

vinay

Andrejus Baranovskis said...

Yes - its a property setting on Query Criteria ADF UI component.

Andrejus

Anonymous said...

Is there a way I supress 'Advanced' button which appears by default on InputComboListOfValues search popup.

Vinay

Andrejus Baranovskis said...

I dont think there is such property in the wizard. You only can disable showing Query operators in Advanced mode for LOV (set it on LOV View Criteria). But Advanced button will show up. Unless you will not render Search at all for LOV.

Andrejus

Dmitry Chernous said...

Hello, Andrejus.

I find your example very valuable in understanding the logic of LOVs.

Would you please be so kind to offer me an approach to do the same thing you described here but using a java class attribute of List type as the data source?

I have to display a list of users from my organizational model and I get this list with a method in Java class.

So, there are two particular moment I want to focus on:

1. I create undounded LOV and try to bind it to the data control created on this class, but selecting the 'element' attribute from the 'list' under the data control gives me an error that this is not a compatible type.

2. Trying to create listOfValues binding to either a variable or the 'element' from my Data Control allows me to create only model driven list and makes me to set Server List Binding Name.

So, I have no idea by far how settle this.

Can you advice any possible way to make it work or maybe give a link to an example?

Kind regards,
Dmitry

Santosh. said...

Hi Andrejus,
i have a LOV component on a pop up, the popup launches on an invokation of button click , which intrun is present in a a databound table(A Master Child laout). The Button is for child panel.

The issue is if the child table already has records, the LOV shows the values, otherwise i.e if there are no child rows , then the lov doesnt show the LOV values.







Can you help me with this.

Regards
Santosh.

Anonymous said...

Hi Andrejus :)

I can't folow these steps with the new version of JDeveloper .I can only choose Model Driven List and I get always this erros (server side list binding not selected)

any help please

Andrejus Baranovskis said...

In the new JDEV, you can simply define transient attribute in the VO with LOV, it will be the same.

Andrejus

ElGueuzifié said...

Hi,
I am getting a NullPointerExcepion when I click the loupe the second time after setting the country id.
I am using 11.1.2.3.0
Please help me.
Thaks.

Anonymous said...

Hi Andrejus,

This is Raja,i am your follower.I have to populate Input List of Values component values from managed bean.I mean i have get those search and Edit form values in popup from arraylist (arraylist values from from webservices dynamically).please let me know procedure.

Thanking you.

Ashish Pursani said...

I'm facing one issue with search & select dialog where the search text given in the popup for the field is retained the next time I open the popup. How We can avoid this problem?

Andrejus Baranovskis said...

Are you using standard LOV or custom Popup?

Andrejus

Veera Brahmam Adavi said...

Hi Andrejus,
I have a requirement of LOV with Contains criteria.
when a value(Val1) is entered in the inputtext of the LOV and click enter, then LOV popup will shown. this popup should show the result set which contains Val1.
Can we achieve this?