Invoking Oracle ADF Application Module method from a Java httpServlet

This post is showing how we can invoke or call any ADF Application module method or simply it is showing how we can interact with ADF business component from a standard J2EE servlet. Here, we are creating a entity
object, view object and application module in as ADF business component. These business components just enters data in a table. Then we are calling these business componens from a j2ee/java servet and we are passing the parameters from this servlet to ADF BC and finally saving those parameters in the table.

Suppose we have a table like this ->

First, create the entity object [AddressEO], View object [AddressVO] and Application Module [AddressAM] for the “Address” table. Add this new view object in your application module.

Add the view object with the Application Module [AddressAM]. Don’t forget to extend the Application Module Interface class. See the following fig. for reference.

Now add the following method in the Application Module. The following method is only inserting one row in the database table "Address".

public void createAddress(String Name,String Phone){
           Row newRow = getAddressVO1().createRow();
           newRow.setAttribute("Name", Name);
           newRow.setAttribute("Phone", Phone);

Now add and files in your view layer application. You can get these two files from directly. Do a bit google search for this. Put these two files in the directory “\ViewController\src\util “. If the directory doesn’t exist create the directory, put the files in the directory, add the files and refresh the application.

Create a httpServlet "". In the post method write the code as follows ->

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

              AppModule bam = (AppModule)ADFUtils.getApplicationModule("AppModule");
             //AppModule is the Application Module Name
              String Name = request.getParameter("Name");
               String Phone = request.getParameter("Phone");


Now from any html/JSP/JSF page call the servlet to insert your "Name" and "Phone" in the database table Address. The code is as follows ->

 If you have query or any further information please leave a comment.

No comments :