Wednesday 24 December 2014

Hello World in Oracle ADF


This tutorial explain how to create a HelloWorld application
in Oracle ADF.
The JDeveloper 11g Release 1 (11.1.1.3.0) is the version
used for this example, you can download that from this link  

Launch the JDeveloper application select Default Role on the
select role screen.

1)      File --> New --> General --> Applications --> Fusion Web Application (ADF)



Click “Ok”

2)      Name the application “HelloWorld”




By default the application package prefix is set to oracle.adf. application_name your can rename as required.

3)    No other changes are required, just click Next --> Next --> Next --> Finish.




 


                           


Final result screen after creating the project, you should be able to see Model & View Controller in the Application Navigator

                         


4)      Right click the View Controller New --> Web Tier --> JSF --> JSF Page

                         


5)      Name the JSF page as HelloWorld.jspx, expands the Page Implementation section and select Automatically Expose UI Components in a New Managed Bean. Once you rename your JSF page the class, method name automatically gets updates.

                       


                       


6)      Now add a Decorative Box layout to our helloWorld.jspx and add an ADF Faces Input Text , Button item in the panel center section and Output Text item in panel top section from Components Pallet --> Common Components.

                    


Your screen will look like this after adding it.

7)      Now change the label of InputText to Enter Name and text of commandButton1 to Go

8)      Double Click the button it will open the Bind Action Property used to bind the action method when the button is clicked.

                                    


9)      Click Ok, and add the action that needs to happen on the button click which is need to display the entered name in the output text. Add the below code
   
 public String cb1_action() {       
        RichInputText inputText = getIt1();
        String name = "Hello " +
inputText.getValue();
        ot1.setValue(name);
        return null;
    }

10)   Now right click the helloWorld.jspx page and click on Run, this will run the page at http://127.0.0.1:7101/HelloWorld-ViewController-context-root/faces/helloWorld.jspx
Enter your name and click on the Go button which will display your name as below.






The Hello World application has been created finally.

No comments: