Wednesday, October 6, 2010

Calling Web Services using ADF 11.1.1.3

In this post I will explain you how to call a web service using ADF 11g, In my last post i explained how to create a java web service using jdeveloper 10g, i will use the same web service in this example which returns credit rating for the customers.

1) Create a new Fusion Web Application (ADF) Application and Provide an Application Name, GetCreditRating and click Next



2) From the Project Technologies move Web Services into the Selected box. Accept the defaults and click Finish.

3) Right-click the Model project and select New and In the Gallery select Web Services –> Web Service Data Control then click OK.

4) Provide a name GetCreditRatingDC and give the URL endpoint for the Web Service, then click Next.




5)
Select the web service operation you want to use for the ADF application. In my example my web service only has one operation.

6) Click Finish, Save your work, the Web service data control is now been created.



Next Step is to create the UI components.

1) Right-click the ViewController project and select New and In the Gallery select JSF --> JSF Page and Click OK



2) Provide a name for the jsp page, GetCreditRating, Also ensure that the ‘Create as XML Document (*.jspx) check box is checked. I have selected the page template, Oracle Three Column Layout but you can create a layout of your choice.


3) I only want 2 facets so I delete the last facet right-clicking the right had panel and selecting Delete


4) In this example I want to get the creditRating of the customer based on the customer ID. So I will enter a Customer ID and Submit it to get the response from web service.

5) Drag the fields you require from the web service data control to the left pannel. In my example I only require the Customer ID. When you drag to the panel select Text –>ADF Input Text w/Label.

6) In this example I want to get the Credit Rating of the customer based on the customer ID. So Once I enter the customerID I want to execute the request. To do this I need a button.
Drag the getCreditRating(Object) under the fields created in step 5. Select Methods –> ADF Button.



7) To Display the credit Rating i will use ADF Output w/Label. so drag the Object from web service data control and select Text –>ADF Output w/Label.


8) Now it is time to test, Right-click the GetCreditRating.jspx page and select Run


9) A browser should start, test for both valid and invalid values.




Tuesday, October 5, 2010

Internationalization of ADF 11.1.1.3 Applications

In this Post I will explain you how to internationalize ADF 11.1.1.3 applications. ADF supports multiple language support which will be demonstrated here.

1) Open JDeveloper 11.1.1.3 and Create an Application and View Controller Project name it as sample.jpr

2) Create a new JSPX page called sample.jspx as follows.
Right Click on sample.jpr, select new--> JSF--> JSF Page --> Click OK

3) In the Create JSF Page Step, Give File Name as Sample.jspx, Make sure the Create an XML Document (*.jspx) option is checked also Do not Automatically Expose UI components in a Managed Bean is Checked.

3) You will see an empty sample.jspx page. Lets add some of the components to jspx page. Drag and drop the PanelStrechLayout Component on the page,


4) You will see number of facets like start, end, center etc on the page

5) Drag an drop the PanelGroupLayout on the center facet of the PanelStrechLayout.

6) set the Layout property of PanelGroupLayout to scroll as shown below

7) Create Resource bundle sampleUI.properties for english langauge and sampleUI_de.properties german langauge.

a) Right click on Sample.jpr and Create new---> General--> File ---> OK


b) Give FileName as sampleUI.properties and Click OK


c) Edit the SampleUI.properties as follows:

d) Create the sampleUI_de.properties to support german language.

e) edit the sampleUI_de.properties as follows:

8) Load the ResourceBundle property files created above in the sample.jspx as follows




9) Add inputText component on the PanelGroupLayout, edit the Label property and choose the expression builder and select the JSP Objects--> res --> sample.name --> Click OK

10) Add the Button Component just below the inputText and follow the above steps to set the Label property of the button.

11) Open the faces.config.xml, Under locale-config, set default locale to en and supported locale to de and save

12) Rebuild the project and Run the sample.jspx you will see by default english locale will be loaded and the page looks as follows

13) If you are using firefox mozilla browser go to Tools-->Options-->select content-->languages--> choose--> select german (de) langauge--> ok --> move this langauge up and click OK, refresh the browser to see the change.