Wednesday, 14 October 2015

Display Component Id say(Button Id), button Text, inputText Label and inputText Values inside bean in ADF

Requirement: This is one of the very common requirement that every fresher in Oracle ADF search for and this post will help them to get the solution. I have a demo.jspx page. On that page I have three an af:inputText and an af:button: The af:button names are: "Click Here" ,  and the af:inputText label="Enter Text"
Now when I click on the af:button, it should display the af:button id, af:button text, af:inputText  label, and af:inputText values in the bean.

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 demo.jspx page in the ViewController project of our application.

Step 3: Drag and Drop one af:button and one af:inputText from the component palette on the demo.jspx page. Name the af:button as "Click Here". Create an actionListener for all the af:button. Thus, the actionListener for the created af:button is actionListener = "#{pageFlowScope.MyBean.getValues}". Now create the binding for the af:button and the af:inputText as binding="#{pageFlowScope.MyBean.buttonIdBinding}" and binding= "#{pageFlowScope.MyBean.inputTextBinding}" respectively.
Thus, the complete demo.jspx page is shown below:

Step 4: Now go to the and write the codes for getValues method.Thus the complete code is shown below:
package com.susanto;

import javax.faces.event.ActionEvent;


public class MyBean {
    private RichButton buttonIdBinding;
    private RichInputText inputTextBinding;

    public MyBean() {

    public void getValues(ActionEvent actionEvent) {
        String buttonId = this.getButtonIdBinding().getId();
        System.out.println("Button Id is : " + buttonId);
        String buttonText = this.getButtonIdBinding().getText();
        System.out.println("Button Text is : " + buttonText);
        String inputTextLabel = this.getInputTextBinding().getLabel();
        System.out.println("Input Text Label is : " + inputTextLabel);
        String inputTextValue = this.getInputTextBinding().getValue().toString();
        System.out.println("Input Text Value is : " + inputTextValue);

    public void setButtonIdBinding(RichButton buttonIdBinding) {
        this.buttonIdBinding = buttonIdBinding;

    public RichButton getButtonIdBinding() {
        return buttonIdBinding;

    public void setInputTextBinding(RichInputText inputTextBinding) {
        this.inputTextBinding = inputTextBinding;

    public RichInputText getInputTextBinding() {
        return inputTextBinding;

Step 5: Save all and run the application. Thus, ran application is shown below:
Step 6: Now we will type some value say (Moumita Deb) in the af:inputText component that is inside Enter Text af:inputText as shown below:
Now when I will click the "Click Here" then button Id, button Text, inputText Label and the inputText Value get printed in as shown below:
Hence, the solution to our requirement.

If you really like the post please share and comment the post.

Thanks & Regards,
Susanto Paul