Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Jdeveloper 12c. Show all posts
Showing posts with label Jdeveloper 12c. Show all posts

Saturday, 28 September 2019

Oracle ADF and JDeveloper 12.2.1.4 Are Available

Finally some good news for Oracle ADF Community :)

Director of Product Management Shay Shmeltzer has posted a blog about new realse of Oracle ADF and Jdeveloper 12.2.1.4

Oracle JDeveloper and Oracle ADF 12.2.1.4 Now Available

List of new features - Oracle ADF 12.2.1.4 new features

List of fixed bugs - List of fixed bugs

Download and let us know about your experience



Monday, 21 January 2019

Unit testing of ADF Application using JUnit

 JUnit is a unit testing package for Java language and can be used to test Oracle ADF applications as ADF is built on top of the J2EE framework. Unit testing is basically is a process to verify the smallest testable module against some defined test criteria. Here I am going to illustrate how can we set up and use JUnit in JDeveloper 12.2.1.3 to test the ADF application.

JDeveloper 12.2.1.3 comes with a JUnit extension so no need to install it separately. Let's start by creating a Fusion Web Application in JDeveloper IDE. Here I am taking Departments table of default HR Schema to prepare the model for ADF Application.




The next step is to create a new project to hold unit tests so that the whole application doesn't look ambiguous. Right-click on the Application name and select New–> From Gallery–> General–> Projects --> Java Project 



Put a name for that project and click on the Finish button.



Now next step is to create a Test Suite for business components and before that, we should know some terminology that is used in unit testing.

Test Suite- A group of Test Cases

Test Fixture- A class to handle long-running test cases and keep the state of multiple test cases.

Assertation- To check the result of a test case against the expected result.

Now to open the test suite wizard, Right-click on new project and select New–> From Gallery–> General–> Unit Tests --> ADF Business Components Test Suite



Click on the OK button and configure the test suite. You can see that here I have selected the Model project and DeptAm application module to test. You need to select Configuration for database connection too and here I have selected DeptAMLocal.



Click on the Next button and see that this wizard will generate a Test Suite class and a Test Fixture class. This wizard will also generate separate unit test classes for each view object in the application.



Now click on Finish button and you can under new project all files are created.

DeptAmFixture.java- Test Fixture Class

AllDeptAMTests.java- Test Suite Class

DepartmentsVO1VOTest.java- Unit Test Class for Departments ViewObject



Now open DepartmentsVO1VOTest.java class and look at the default test case that checks that the Department View Object should not be null.

You can see here @Test annotation, this indicates that this java method is a unit test and after performing test assert is used to verify the test result.

  1. @Test
  2. public void testAccess() {
  3. ViewObject view = fixture1.getApplicationModule().findViewObject("DepartmentsVO1");
  4. assertNotNull(view);
  5. }
  6. @Before
  7. public void setUp() {
  8. }
  9. @After
  10. public void tearDown() {
  11. }

To check this default test case, Right-click on the test suite class and select run. You can see that the unit test execute successfully.



The next step is to create some of the own unit tests, I have created this unit test that checks that the Department Id should not be null in a newly created row.

  1. @Test
  2. public void checkDeptIdNotNull() {
  3. ViewObject deptVo = fixture1.getApplicationModule().findViewObject("DepartmentsVO1");
  4. Row newRow = deptVo.createRow();
  5. newRow.setAttribute("DepartmentId", 222);
  6. newRow.setAttribute("DepartmentName", "Testing");
  7. assertNotNull("DepartmentId should not be null", newRow.getAttribute("DepartmentId"));
  8. }

So in the above code, I have created a new row in Department's view object and set 222 in Department Id. Now run this test case.



You can see here that the test is passed successfully because Department Id is not null, That's great. Now comment this line in the code

//newRow.setAttribute("DepartmentId", 222);

and run the test again



See that test is failed with AssertionError as Department Id is null this time. This is how we can write our own unit tests to check.

Here I am writing one more test case to check whether the department is in the database or not. I am passing 1990 as department id that is not in the database.

  1. @Test
  2. public void findDepartment() {
  3. ViewObject deptVo = fixture1.getApplicationModule().findViewObject("DepartmentsVO1");
  4. int deptId = 1990;
  5. Row row[] = deptVo.findByKey(new Key(new Object[] { deptId }), 1);
  6. Integer count = row.length;
  7. //assertTrue fails when second parameter evaluates to "false"
  8. assertTrue("Department Not Found", count.compareTo(0) == 1);
  9. }

Let's see the result



This is how we configure and use JUnit in the Oracle ADF Application for Unit Testing.

Cheers 🙂 Happy Learning

Tuesday, 8 January 2019

Consuming JSON based REST Web Service in ADF 12.2.1.3

 Previously I have posted about consuming ADF BC based REST Web Service in ADF. Now, this post talks about consuming JSON based REST Web Service using generic data control.

You can also look at previous posts on Web Service for more information.

Create SOAP Web Service with Application Module quickly in ADF 12.2.1

Create REST Web Service with Application Module declaratively in ADF 12.2.1

Consuming a SOAP Web Service quickly using Web Service Data Control (WSDL) in ADF

Create POJO based JAX-WS WebService easily with JDeveloper 12.1.3

Populate data in ADF Table using Web Service Data Control

Populate select one choice using Web Service Data Control in ADF Application

Access JAX-WS web service from Java Class using Web Service Proxy in JDeveloper

In this post, I am using a free REST API Web Service to get all countries' names. Check the below link for detail of Web Service methods.

RESTful web-services to get and search Countries

Let's see how to implement this in JDeveloper 12.2.1.3

Create a Fusion Web Application with default Model and View Controller projects.



Right-click on the View Controller project and Select New–> From Gallery–> Business Tier–> Web Services and select Web Service Data Control SOAP/REST 



It opens Web Service Data Control creation wizard, Select REST as Web Service type and provide a meaningful name, Generic Data Control with manually described resources as the type of data control.



Click on the green plus icon to create new ADF Rest Connection, Enter connection name and URL of the web service.

Here URL of web service is http://services.groupkt.com/country/get/all and I am using http://services.groupkt.com/country/get, /all is left here as it'll be used later. Select authentication type none and test connection.



Click on OK and you can see that the REST connection is created. Click on the next button and skip OWSM policies and come to the Resources tab.

Now click on the green plus icon and add /all as the resource path, select GET method checkbox and put a name for the method and set JSON as Data Format.



Click on the Next button and set method payload, Select Parse from Sample Code and access web service from the browser and paste the code in Response Sample.

For this post click on this link to copy the sample response - http://services.groupkt.com/country/get/all



Click on Next and Test Rest Connection.



With the click of the finish button, a file DataControls.dcx is generated. This is a data control definition file and contains information about data collection nodes and built-in data collection operations.



Now consuming web service part is done and the next is to create a page and use WSDL to show a table on that page.

Right-click on the view controller and select New–> From Gallery–> Web Tier–> JSF/Facelets and create a new page



Expand Data Controls section of Fusion Web Application and you can see there a get() method and under it the message and result data collection.

Drop get() method as a button and both collections as the table on the page and run application.



All done :)

Sample ADF Application (Jdev 12.2.1.3) - Download

Cheers 🙂 Happy Learning

Wednesday, 26 December 2018

Consume ADF BC based REST Web Service using ADF REST Data Control

Creating and consuming web service is an important part of the development cycle in any technology. Here in this post, I am going to show that how can we consume ADF BC based REST web service in an ADF application. In ADF 12.2.1 release Oracle provides support for declaratively consuming REST Web Service, Before that it was only possible using java and that was a tedious task for fusion developers.

Suppose I have an ADF BC (Business Components) based REST web service that returns a list of Departments. Now to consume that web service we'll use ADF REST Data control. Here I am going to illustrate this step by step.

I am using JDeveloper 12.2.1.3, Let's start with Creating a Fusion Web Application with model and view controller project.



Right click on the Model project and Select New–> From Gallery–> Business Tier–> Web Services and select Web Service Data Control SOAP/REST 



It opens Web Service Data Control creation wizard, Select REST as Web Service type and provide a meaningful name, Select Describe-Based ADF Data Control as the type of data control.



Click on the green plus icon to create new ADF Rest Connection, Enter connection name and URL of the web service.
Here you should know that URL of ADF based REST web service typically has a host, port, context root path with version name, resource name. So URL of my web service is this

http://127.0.0.1:7101/RestWebServApp-RESTWebService-context-root/rest/Jdev12.2.1/Department

and to make it REST Describe URI just add describe after resource name and put that URL in URL Endpoint field

http://127.0.0.1:7101/RestWebServApp-RESTWebService-context-root/rest/Jdev12.2.1/Department/describe

Default authentication type is none so leave it and test the connection.



Click on OK and you can see that REST connection is created.



Click on next button and come to Select Resources tab and add resources to the selected side.



On the Finish tab test REST connection once again and you can see It is successful.



On the click of the finish button, a file DataControls.dcx is generated. This is a data control definition file and contains information about data collection nodes and built-in data collection operations.



Now consuming web service part is done and next is to create a page and use WSDL to show a table on that page.

Right click on the view controller and select New–> From Gallery–> Web Tier–> JSF/Facelets and create a new page



Expand Data Controls section of Fusion Web Application and you can see there Departments data collection node. On expanding it you can see the attributes of the Departments table and its operation.



Select Departments from data control and drop it on the page as ADF table, Also dropped Previous and Next operation as a button on the page.



Now run and check application, Data is populated from the web service using ADF REST data control



Click on Next button to navigate between rows



All done 🙂 

This is how you can consume an ADF BC based REST WebService in Fusion Application. 

Tuesday, 8 May 2018

Change Style of ADF TreeTable, Column, Data Cell, Selected Row using ADF Skin

Hello Everyone

In this tutorial, We'll learn to change look n feel of ADF tree table component using Oracle ADF Skin
Here I am using Departments and Employees table HR Schema to prepare the model and created tree Table using view link between Departments and Employees View Object

Wednesday, 28 June 2017

Hide values from ADF SelectOneChoice using EL expression on UI


This post is about a specific requirement that is to hide some values from adf based select one choice from UI
Previously I have posted about disabling some items from select one choice and this post uses same steps to hide values from lov

Saturday, 3 June 2017

oracle.jbo.domain.DataCreationException: JBO-25009 while using multiple selection component in ADF Faces


Previously I have posted about using multi-selection components (af:selectManyCheckbox, af:selectManyChoice, af:selectManyListbox, af:selectManyShuttle) of ADF Faces. These components make use of list binding and work on base attribute and display attribute concept

Access JAX-WS WebService from Java Class using Web Service Proxy in Jdeveloper


Web Service proxy class is a way to communicate with XML-based WebService using SOAP format,
In short, we can use service proxy class at client to access WebService

In JDeveloper IDE we can easily create client proxy class for WebService, Here in this post I am creating client proxy class to access a JAX-WS web service that I have created in previous blog post

Create POJO based JAX-WS WebService easily with Jdeveloper 12.1.3

Let's see how to implement this


Monday, 22 May 2017

Populate select one choice using Web Service Data Control in ADF Application


My previous post was about creating a JAX-WS Web Service from Java Bean and consuming web service and showing data in ADF table. Now In this post, I am going to elaborate about consuming that Web Service in ADF Application and show Employees data in selectOneChoice component


So for this requirement, We need to use Web Service Data Control and from that WSDL we can create ADF Faces components

Let's see how to implement this

Thursday, 18 May 2017

Populate data in ADF Table using Web Service Data Control


My previous post was about creating a JAX-WS Web Service from Java Bean. Now In this post, I am going to elaborate about consuming that Web Service in ADF Application and show Employees data in ADF Table

So for this requirement, We need to use Web Service Data Control and from that WSDL we can create ADF Faces components

Let's see how to implement this

Monday, 15 May 2017

Create POJO based JAX-WS WebService easily with Jdeveloper 12.1.3


Hello All

In this post, I am talking about creating a simple JAX-WS web service using Jdeveloper 12.1.3 .
JAX-WS is a Java API for XML Web Services and we can create a JAX-WS easily with Jdeveloper IDE
Idea is to create a web service that shows Employees list with their name, designation, salary and department name so for this, I am going to use POJO Java Class

Let's implement it

Thursday, 4 May 2017

Implement contains/endswith behavior in model based autoSuggest Lov (Input list and combo box)


Hello All

Hope Everyone knows about list of values and autoSuggest beahvior of ADF Framework,
For those who are new to framework can look at this post
ADF Basics : Implementing auto suggest behavior in ADF Faces lov (list of values)

Monday, 1 May 2017

Undo row selection of af:table in selection listener method conditionally


Recently I have seen a question on OTN Jdeveloper forum and It was about table selection listener
Requirement is like this suppose user has to check a condition after selecting a row and if that condition is true only then new row will be selected else selected row should be previous one

It means undo row selection on validation(condition) failure
So In this post I am implementing same scenario and here I am using Departments table of HR Schema to prepare model and condition is that user should be able to select new row only if ManagerId is not null

Monday, 17 April 2017

Show saved file (pdf/text/html/xml/image) content on page from database (BLOB) in ADF Application


Hello All

Previously I have posted about uploading and saving files in database blob column now this post is about showing saved file content on page using ADF Faces inline frame component

In this post I am extending same previous application, Now see how we can implement this
There are few more steps to go , See the additional steps to show file content on page-


Saturday, 8 April 2017

Uploading and downloading files from database (BLOB) in Oracle ADF (12.1.3)

Hello all

This post is about a very simple requirement -file handling (uploading and downloading various types of file) in ADF and it is needed very often to store file in absolute server path (actual path) and download from there and I have posted about that previously

Uploading and downloading files from absolute server path

Now this post is about uploading and saving file in database BLOB column and downloading from there
See step by step implementation -

Monday, 20 March 2017

ADF Basics: Tip for not showing record in dependent lov


Hello All

Recently I have seen a question on OTN forum - Question on cascading LOV

It was about cascading lovs in ADF
Suppose we have 2 dependent LOVs and requirement is that 2nd lov should not show any data until first one is selected , this is very simple and common use case but for beginners it's a tedious task

So I thought to write it here to help others

Wednesday, 15 March 2017

Fetch Tweets of a User using Twitter4J API and show in af:table in ADF & Java


In the previous blogs we learned about posting tweets on twitter timeline using Twitter4J API and sending direct meaages to followers using same API

This post is next in the series and about fetching a user tweets and showing in ADF Table , For this requirement we need to use same Consumer Key+ Secret and Access Token+Secret (Refer previous posts for this)

And In same way after authentication we can fetch a user tweets by using it's twitter handle. So for this requirement I have added a button to fetch tweets and a POJO based table to show fetched tweets in page

See the code to fetch tweets using user's twitter handle and it's retweets and favourites count, We can get tweets by passing page number as parameter and it returns a list of tweets


Thursday, 9 March 2017

Send Direct Message to followers using Twiter4J API in Oracle ADF and Java


My previous post was about tweeting using Twitter4J API from Oracle ADF Application . Twitter4J is a Java API that simplifies accessting twitter features in our application easily

In this I am going to show how to send DM (Direct Message) to anyone using their twitter handle and for this we need to use same consumer key, secret and access token, secret (How to access all these is described in previous post)

Thursday, 16 February 2017

Post to Facebook Page Wall using restfb Graph API in ADF & Java


This is next post working with Facebook Graph API series, Previously I have posted about gettting access token and use it to get Facebook Profile detail and Posting status on your Facebook Timeline using restfb Facebook Graph API

Go through previous posts for better understanding of this blog post

Saturday, 11 February 2017

Post Status on Facebook Timeline using restfb Graph API in ADF & Java

Hello All

Previous post was about generating temporary access token and using it get Facebook profile detail usinf restfb Graph API , Go through previous post before this as graph api basics are described in that post

Now In this post I am talking about posting facebook status update so for this I am extending same sample application