Get the value from SelectOneChoice or LOV not the index in bean -Oracle ADF

Another approach i am sharing with you.Normally we want to get selectOneChoice value and we normally get the index.
We will creating an attribute in the selectOneChoice items and the selected value lable.

                        <af:selectOneChoice value="#{bindings.reportType.inputValue}"
                                          required="#{bindings.reportType.hints.mandatory}"
                                          shortDesc="#{bindings.reportType.hints.tooltip}"
                                          id="soc1" partialTriggers="cb2"
                                          autoSubmit="true"
                                          styleClass="hrt_reporting"
                                          valueChangeListener="#{pageFlowScope.ReportFilterBean.reportTypeVC}"
                                          binding="#{pageFlowScope.ReportFilterBean.reportTypeChoice}">
                        <f:selectItems value="#{bindings.reportType.items}"
                                       id="si2"/>
                        <f:attribute name="rowIndexVal" value="#{bindings.reportType.items[bindings.reportType.inputValue].label}"/>
                      </af:selectOneChoice>

and in the bean you can write as

        valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
        Map map = ((UIComponent)valueChangeEvent.getSource()).getAttributes();
        String reportTypeValue = (String)map.get("rowIndexVal");

that’s it, you are done.

Happy coding with Vinay Kumar in techartifact,,

Get value of LOV/choiceList programmaticaly in bean instead of index in Oracle ADF

Requirment-Get value of LOV/choiceList programmaticaly in bean instead of index in Oracle ADF

When you wrote like In backing bean we get the index, not the value. most of the developer did this mistake.

JSFUtils.resolveExpression(“#{bindings.EmployeeId.inputValue}”); —- We got the index

Instead of use attributeValue to get the value in bean.use this code in the bean or as the EL

JSFUtils.resolveExpression(“#{bindings.EmployeeId.attributeValue}”);

How to create LOV in ADF 11g

Hi,

This week we will be learning how to create LOVs in Oracle ADF application.

Pre-requisites:
– HR Schema in Oracle database.
– I am using Jdeveloper 11.1.3

Objective:
On this post we will create LOV for Department Id in Simple Employee based form.

Steps to follow:

Adding Department Entity:

– Add Departments Entity by Right clicking on Vinay.model package in Model project and choose New Entity Object
Enter Name as ” Department ” and Choose Schema object as ” Department ” by pressing Browse button you can select from the list of objects as well.

Right click on Vinay.model.view package and Choose New View Object name Departments as below


Now we will be creating view object for Department

Uncheck the updatable checkbox.

Select department name and department id.in the order by clause use department ID.
Click next and finish it.Repeat the same step for Employee ViewObject.

Now we will be creating the lov . Double click Departmet view object.
– Select DepartmentId attribute in the attribute page and Click “+” green button at the bottom under List of Values section.

– Click the green + button with List Data Source.
A create List of value wizard will open.In the configuration tab click the + sign if there is no default value is there

On clicking of the ‘+’ sign a view accessor pop up will open.Select Department View Object and shuttle to right side.

In the list attribute select department ID.Click ok.Now your department View object would like as below

Now we will link Lov to the JSPX page.Click new on view controller project.And select jsf page.Give
File name LovPage.In

In the data control palette.Select department view which we created and drag drop on the page

A wizard will open.As you can see department Id is coming as select one choice

Now your jspx page look like this.

Click run on the page. In browser you can see department Id is coming as LOV.It is easy to create.If you want to create lov from another entity object then you need to have accessor on that referring entity object.And you will use that accessor in List Data source in configuration tab.