Showing posts with label List Of Values. Show all posts
Showing posts with label List Of Values. Show all posts

Monday, 30 November 2015

how to populate Single or Multiple Selection Lov(List of Values) from Bean in ADF

Hello all,

This shows how we can populate the values of Single or Multiple Selection List of values from Bean.
For this simply create a simple ADF Application.

  1. Then create a Bean with a method public ArrayList<SelectionList> getSelectionListItems();
    package singleselectionlovfrombean.view.bean;
    
    import java.util.ArrayList;
    
    import javax.faces.event.ActionEvent;
    import javax.faces.model.SelectItem;
    
    import oracle.adf.view.rich.component.rich.input.RichSelectManyChoice;
    
    public class TestBean {
        private ArrayList<String> list = new ArrayList<String>();
        private RichSelectManyChoice multSelctBind;
    
        public TestBean() {
            list.add("Second Option");
            list.add("Third Option");
            list.add("Fourth Option");
            list.add("Fifth Option");
        }
    
        public void showSelectedValuesAL(ActionEvent actionEvent) {
            Object object = multSelctBind.getValue();
            System.out.println("Selected Values are : "+object);
        }
    
        public ArrayList<SelectItem> getSelectionListItems() {
            ArrayList<SelectItem> sslist = new ArrayList<SelectItem>();
            for (String s : list) {
                sslist.add(new SelectItem(s, s, s, false));
            }
            return sslist;
        }
    
        public void setMultSelctBind(RichSelectManyChoice multSelctBind) {
            this.multSelctBind = multSelctBind;
        }
    
        public RichSelectManyChoice getMultSelctBind() {
            return multSelctBind;
        }
    }
    
  2. Create a .jspx page and the drag a multiple selection list of Values form component pallet.
  3. This method returns an ArrayList of SelectionList type which we will use for the purpose of showing the values in the list box.

  4. Then select the method returning items by clicking on the Bind


Then press okey.


And Here I also have created a ActionEvent in a button that shows the selected values.

Then run the application.

The pages opens are follows


After the selection click on  Show Selected Values button.



Am attaching the sample application for reference : SingleSelectionLovFromBeanAPP
Please comment for any query or Confusion.

Wednesday, 23 April 2014

ADF : Working with LOV Switcher

Hello all,

This is a very basic post on LOV switcher implementation.
First , some background information about it.

First we need to understand what happens when a Lov is added to an attribute in ViewObject.

When we add a Lov to an attribute in a ViewObject, a property is added to the attribute

  LOVName="LOV_Name"

and a viewObject instance of the Lov is added to the viewObject. You can see it in the viewAccesors tab to ViewObject. And an entry of list binding is made in the viewObject to represent attribute mapping for the LOV viewObject.
So the question is how the Framework determines if which LOV is added to the attribute,  at runtime ?
At first Framework looks for the property LOVName of the attrribute of the ViewObject then looks for the List binding of the LOV name.

So inorder to switch the LOV on an attribute we just have to change the value of the LOVName in the attribute.Means we need to give it the name of the lov whichever we want to display. LOV switcher basically does the same thing.

So here is an example for the same.
Here I am creating a transient attribute in a Temporary viewObject made from dual and on this attribute we will switch Departments and Employees LOV. I have also created two viewObjects of Department and Employees to use them to make LOV.






First we have to create a Temporary ViewObject with a transient attribute.
Then we will create a transient attribute in which we will put the name of the LOV and then use it will as name of the LOV which needs to be selected.
Here I am naming it as 'LovNameTrans'.


Then we will create two lov on attribute 'LovAttributeTrans'.
Here I have used 'LOVDept' as the name of the LOV.


And again am creating second LOV on the same attribute and named it 'LOVEmp'.


Now the LOV part is over now we have make the switching arrangement.
So now in the 'List of Values Switcher' select the attribute 'LovNameTrans' which will provide the name of the LOV to be switched.

Now create a page and drop the attributes.For assigning values to the 'LovNameTrans' attribute i have created a radio group with static list containing the LOV names.


Make sure the attribute containing the name of teh LOv have the autosubmit property as true on the page as if the value is not submitted then LOV will not be shown. And also use proper partil triggers.

Now run the page. On selecting LOVDept


On selecting LOVDept

Here is the sample workspace used, you can download it from here :LovSwitcherApp

Friday, 4 April 2014

ADF : af:table or adf form or adf page taking too much time to load

During the development sometimes we come across this problem. In our case we had a table on a page and it was taking too much time to load, even though there were only one row in the database table but then also it was taking more than enough time to load. After the analysing the problem finally we were able to solved the problem.

The main problem was with the List of Values with SingleSelection which was inserted in the table. In a column we had to show the name in place of the id, so the developer created a List of Values in the viewObject and put it in the table on page. At first it was working fine but later as the number of rows grown in the List of values the list started taking time to load.

The main cause was the number of rows in the list of values. Single selection list of values matches the id with the value and shows values, so inorder to map it needs all the rows, so whenever the table was being load the ListOfValues started to fetch all the rows, and as the number of rows was too much so abviously it was taking too much time. So, we had to replace the list of values but we also had to show the name in place of id. 

So there are many ways to do that : 

1. We can include the name that we have to display in the query of the table itself, because of which we can simply display it in a column.

2. Otherwise we have to use a viewobject with query that returns a less number of rows and better if it returns one row with the id and DisplayName. 
Suppose we have to show Department Name in place of department id in Employees Table. The query will be something like this : SELECT DEPARTMENT_NAME FROM DEPARTMENTS WHERE DEPARTMENT_ID = :DeptIdBind

And then we need to show the display name so we created a transient attribute.
Then in the getter of the transient attribute, get the viewObject and pass the bindVariables and execute the query. The query will return a row and then we can fetch the name from the view object and show it by returning it.

There is a disadvantage of using this method, as the query is executed for all the rows fetched in the table. But page load problem will be solved. 

This may depend on the use case.  For us both worked well.

I will suggest never to use SingleSelection List of Values that contains large number of rows in the page. Not even on the adf form. Because due to that it will take too much time to load.

Thanks for reading. If you have any question, Please feel free to ask.