I was blogging previously about multiple LOV's per attribute functionality. I was using RowImpl class for View object in order to calculate value for LOV switcher attribute. However, this approach is not perfect, since it requires to create Java implementation class with getter method. Even more, getter method in RowImpl class is not invoked, when LOV component is triggered in ADF Query Criteria component. I have described this cool component in my previous post - ADF Query Component and View Criteria Functionality with Custom Query Listener in 11g.
So, as you probably already understood, I will show better approach for LOV switcher attribute implementation with Groovy language expression, defined as a Value for transient LOV switcher attribute.
You can download developed sample application - ADFSearchApp2.zip. This sample as all my samples is based on standard HR schema available in Oracle XE. This application is based on previous sample. Only one addition here is LOV switcher attribute with Groovy expression, that allows to render different LOV components on runtime, based on data values.
I have defined two LOV components for DepartmentId attribute. One LOV component will show two columns and second will show three columns with data:
As you can see, there is transient lovSwitcher attribute defined. This attribute will switch LOV's for DepartmentId attribute. This time, I'm using Groovy language expression as a value for transient attribute. This allows me to have multiple LOV's functionality even in ADF Query Criteria component. With switcher implementation in RowImpl class getter method, its not working. So, here is my transient attribute with Expression defined as a Value Type:
And here is actual expression, it checks Salary attribute value and returns first or second LOV component name to be used:
On runtime, if I will provide value 8500 for Salary criteria, for DepartmentId I will get second LOV with three columns in ADF Query Criteria and same in results table - correct logic:
If in ADF Query Criteria I will provide 4000 for Salary criteria, for DepartmentId I will get first LOV with only two columns:
Same functionality works in results table, based on Salary value contained in current row. So, I would recommend you to use Groovy for multiple LOV's implementation instead of Java getter methods in RowImpl.
Spanish Summary:
Titulo: Uso del lenguaje Groovy para la creación de Lista de Valores en JDeveloper 11g.
Resumen: Andrejus muestra como crear listas de valores en JDeveloper 11g haciendo uso del lenguaje Groovy.
18 comments:
You are a Java programmer or a Javaman??
Do you try to fight against C++?
Hi,
I'm Oracle fun. But, I was working with C++ as well, liked it.
Regards,
Andrejus
I am currently in
Studio Edition Version 11.1.1.1.0
Build JDEVADF_MAIN_GENERIC_090115.1207.5261
And for a LOV enabled attribute Iam not able to see the lov switcher property under the List of Values tab.
Can you please share your comment?
My requirement is to toggle two different LOVs for the same attribute for two different task flows.
Groovy do not support page flow scope parameters...any idea how to solve this issue will be very helpful
Thanks,
Janaki.
Hi,
You should use:
Studio Edition Version 11.1.1.0.1
Build JDEVADF_MAIN.BOXER_GENERIC_081203.1854.5188
Its latest build, you will find there LOV Switcher functionality.
Regards,
Andrej
Hi Andrejus,
I am using
Studio Edition Version 11.1.1.3.0
Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
I am not able to see the lov switcher functionality.
Is it only applicable to Studio Edition Version 11.1.1.0.1
Build JDEVADF_MAIN.BOXER_GENERIC_081203.1854.5188
Thanks,
Shiva.
Hi,
No, its available in all builds since 11.1.1.0.1
You should find it under LOV declaration.
Regards,
Andrejus
Hi Andrejus. I have a question for you about groovy. I have a form inside a popup. The first field is called BANK NAME, and the second field is called ID.
I want the id field appears to me turned on only if the bank name field is entered
HOW CAN I DO THIS ?
Regards,
RICARDO
I have situation where there is no condition and i have to display
one LOV in af:query component and other in af:form without any condition.
What are requirements to display one LOV in Query and another in Form? This is condition on its own.
Andrejus
let say , i have department id attribute.
af:query lov for dep id will pull all the department.but when user create new user , department id will render lov based on some business criteria in where clause.
I dont know what condition should i give at BC level to diff between form and query component. However , from GUI perspective i have condition of af:query , af:form.
Hasim
I see, you should check if current row is in insert state and this will be condition for you.
Andrejus
Hi Andre,
This Looks fine. But, tell me one thing here you are giving the salary value and based on that LOV switcher is working. Consider a scenario, I have few records in the table and i am displaying all the records on page load. with salary's as textbox and LOV's. so even in this case can this LOV_SWITCHER works or not?? I mean to say can it dsiplay sal1(somevalue) LOV2 dropdown??? is this possible?? how can we achieve this please let me know??
Hi,
I guess yes, but there is always if.
Regards,
Andrejus
Thanks man. it worked like a charm..
Hi Andrejus,
My current situation:
I have two LOVs' which has to be toggled depending upon a transient attribute LOVSwitcher.
For tjis i created two different view acessors on top of that, different view criterions have been applied as well.
When i use LOV switcher, LOV is changed accordingly but the respective view criterions are not getting applied.
Any help would be appreciated!!
Thanks.
What about if you try to execute view criterias programmatically, from transient getter method?
Andrejus
Hi ,
I have a scenario where i have added a transient attr LOV_SWITCHER and depending on its value i am switching between 2 LOVs that are applied on a transient view attribute 'name'. In the List Return Values section, i have added the following mappings :
name <- LOVname
code <- LOVcode
I am using the transient variable 'name' to just display the name of the 'code' which i am storing. But actually i am storing just the code in the DB.
Now the problem is, when i select the name from the LOV , the code isn't getting updated.
Can you help me with this ?
Thanks,
Sumanth
Post a Comment