In this lesson we are going to learn how to use Radio Button items in the OAF page.
We can create individual Radio Button items in the page as a named set with mutually exclusive values. It means we can place radio Buttons where ever we require in a page but if we provided a mutually exclusive name to all those radio button items then only any one will be checked.
Let us see one small example how to create a Radio Button Items in the page:
Step 1: Create a page and create one Message Component Layout region in a page. Under the region create four items and select the Item Style as “messageRadioButton” . Example see the below figure:
Step 2: Now after creating Radio Button items give Id values to each items created and assign Prompt name which ever you wish to display for the radio button.
Step 3: Set the checked value and unchecked value to each radio button in the Property Inspector.
Step 4: If we want radio buttons to behave as a group then we must programmatically assign them all the same name by calling setName() for each radio button.
First create one controller and write the program in the processRequest().
Remove one webui from the package name and give controller name and note that every controller ends with CO (general standard).
Write the program in the processRequest(), here I am not providing any access to the code to copy and paste it in the JDeveloper because whenever we write the code we need to import the package in the program which we can get automatically from R12 series on wards.
For example whenever we are typing “OAMessageRadioButtonBean” then JDeveloper prompts us to use “Alt-Enter” to import the required package. So as of now it is better practice to type the code rather than copy and paste.
We already explained the concept of programming in previous Chapter (Displaying User Name, User ID, Responsibility Name, Responsibility ID).
The below figure shows the written code in the processRequest():
Now after righting the code rebuild the code by giving Right click on the program select option called Rebuild.
After successful compilation of program run the page and see the output, if we test the output radio buttons we can select any one out of four available items because we set a unique names to all the items in the program using variable Name . (dot) setName() method. See the code in above picture for confirmation.
The below figure shows output of the program which shows additionally other items too rather than radio buttons: