Sun. Oct 24th, 2021

Requirement: I have an af:selectOneChoice in which I want to populate the data programmatically from the Java class.

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create an Oracle ADF Fusion Web Application.

Step 2: Create a Managed Bean with the name as MyBean.java.

The complete code for the MyBean.java class is shown below:

package susantotech.com;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

public class MyBean {
    List<SelectItem> fruitNameList;

    public MyBean() {
    }

    public void setFruitNameList(List fruitNameList) {
        this.fruitNameList = fruitNameList;
    }

    public List getFruitNameList() {
        if (fruitNameList == null) {
            fruitNameList = new ArrayList<SelectItem>();
            fruitNameList.add(new SelectItem("i1", "Apple"));
            fruitNameList.add(new SelectItem("i2", "Banana"));
            fruitNameList.add(new SelectItem("i3", "Mango"));
            fruitNameList.add(new SelectItem("i3", "Orange"));
        }
        return fruitNameList;
    }
}

Step 3: Drag and drop Choice List from the Component Palette onto the demo.jspx.

Click on the Bind button

Select the Value binding as “#{pageFlowScope.MyBean.fruitNameList}”

Click OK

Click Next

Set Label as Fruits Name > Click Finish

Thus, the complete demo.jspx page is shown below:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="" version="2.1" xmlns:f=""
          xmlns:af="">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="demo.jspx" id="d1">
            <af:form id="f1">
                <af:selectOneChoice label="Fruits Name" id="soc1">
                    <f:selectItems value="#{pageFlowScope.MyBean.fruitNameList}" id="si1"/>
                </af:selectOneChoice>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

Save all and run the application. Thus, the ran application is shown below: Here we can see the Fruits Name are populated from the Managed Bean.

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 640 total views,  4 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *

satta king chart