Hi All,
Our Requirement: In a page, we supposed to show a searchable combo box which loads all the names(non primary key attribute from a table) and based on user selection from this LOV, we should show all the corresponding details for that selection from the table in a ADF form.
But problem is, we need to show only "Name" attribute in Searchable LOV which is non primary key attribute and if we have primary key attribute it is easy to show all the corresponding details for that selection.
Solution: I have used the concept called Transient View object and Transient attribute to show searchable combo box instead of drag and droping actual 'Name' attribute from actual VO. And used Actual VO to show all the details for the corresponding user selection as ADF Form on a page.
- A Transient view object contains only transient attributes,whose values are populated programmatically.
How to Create Transient VO : In the Create View Object wizard provide all the necessary field values like package, name etc and while selecting data source type, choose the option "Rows populated programmatically,not based on query"
Step 1:
Step 2: Create two transient attributes. Say in my case i need one for name attribute(non primary key attribute) and one for id attribute (primary key attribute)
In the next wizard, click on 'New' button to add attribute and define two attributes and make sure you have checked the Always Updatable option.
Next is the important step, I need LOV for name attribute and data source for this is actual VO which is based on EO. Please follow below steps
Select the Name attribute in Transient VO and define LOV(Hope you know, how to create LOV for attribute) and in the LOV Wizard, use Actual VO(Which you created based on EO and you will going to drag and drop this VO as a form) for List Data source option. And for List Attribute select 'Name' (the attribute you want to display in LOV list).
After the above step, you need to create mapping between view attribute and list attribute as shown in below image
Here, first i have created mapping for Name attribute and then for Id attribute from Actual VO and Transient VO.
Under the UI hints tab, choose combo box with list of values option
that is it from defining transient VO.
Refresh your data control and you should see the new transient VO.
So, Once user selects the 'Name' from LOV, i need get Id attribute. This i what i have done in my page.
In my case, i have page fragment which is dropped as View activity on a bounded task flow.
1) I have drag and dropped 'Name' attribute from Transient VO on to a page as a "inputComboboxListOfValues" and set immediate to true
Before launching this page, i need to execute create insert operation from the transient VO to get the value of 'Id' attribute from actual VO into transient VO 'Id'.
So, i drag and dropped the "createInsert"operation from transient VO on to the bounded task flow and made it as a default activity. So, first create insert operation executes before the view activity(page fragment)
2)I have created attribute binding in my page for 'Id' attribute from Transient VO .
3)I have defined value change listener for my LOV component
and In the Value Change listener method
i have done this,
Number value = (Number)ADFUtil.evaluateEL("#{bindings.Id.inputValue}");
where "#{bindings.Id.inputValue}" is value of Transient 'Id' attribute and i have create attribute binding for the same on page.
if i , evaluate the expression "#{bindings.Id.inputValue}", I am able to get corresponding id attribute value when user selects the 'Name' attribute in the LOV.
I have used this 'Id' attribute to query data from the actual VO and able to display in a ADF form on the page.
Note: Suppose , when you select the value from Select One Choice, sometimes it gives index value instead of actual selected value
solution: in your output text change inputValue to attributeValue
Ex: #{bindings.Deptno.attributeValue} instead of #{bindings.Deptno.inputValue}
Note: Suppose , when you select the value from Select One Choice, sometimes it gives index value instead of actual selected value
solution: in your output text change inputValue to attributeValue
Ex: #{bindings.Deptno.attributeValue} instead of #{bindings.Deptno.inputValue}
Hope this helps for you!
No comments:
Post a Comment