Friday, 6 January 2017

Configuring logging for ADF application

In this post i will show you how to configure ADF logger that logs your messages/errors to a specific log file.  Here are the steps needed to do the configuration.

1. In JDeveloper right click IntegratedWeblogicServer instance, and choose Configure Oracle Diagnostic logging for "IntegratedWeblogicServer".



2. Choose the root logger, and in structure window expand log_handlers, copy log_handler named "old-handler".

3. Paste the copied log_handler and name it XX-custom-handler, from property window change .



4. Choose the path property and change its default value.



5. In the overview tab of logging.xml file, click the add symbol to add a persistent logger. In the logger name select the class file or package for which you want to use this logger. example : xx.oracle.app select a level based on the severity you need.
 




6. Expand the Root logger and choose the newly created logger, and in the handler declarations window press the add icon, and choose the custom handler.



7. Now select your project in the application window, and double click it to change the run configuration java options -> Choose the default run configuration -> Edit -> Java options and add the following option "-Djbo.debugoutput=adflogger".







8. Now you can use the ADFLogger util to create a logger instance that logs to you log file.


Done.

Sample ADF CRUD web application

In this post i will show you how to use ADF to create a simple CRUD application in just few minutes.

To know more about ADF "Application development framework" please go to this link.

1. Create an ADF web application.


2. Set application name "Sample Crud" and click finish.


3. Choose "Connect to a Database" and press "Create a Database Connection".


4. Put connection details, and connect to the Oracle Sample HR database, and make sure to test the connection.

Note: Make sure that the hr user is not locked, and if its locked you may need to unlock it.


5. Mark the "Connect to a database" step as Done.


6. Expand the "Build Business Services" step and click "Go to Substeps".


7. Expand "Create Entity Objects and Associations", Press "Create Entity Objects and Associations".



8. Choose the model project.


9. Choose the database connection created in step 3.


10. Press the Query button, and move the Jobs table to the right column.


11. For the updatable views, chose JobsView and move it to the right column, then press finish.


12. Mark the "Build Business Services" step as Done.


13. Open the "adf-config" unbounded task flow.


14. From the "Component Palette" panel drag the view icon to the task flow.


15. Rename it to "jobsView" and double click on it, and then click Ok.


16. Drag a button from "Component Palette" panel into the page, and rename it from the property panel.



17. Do the same for the Edit, Delete, View buttons.



18. From the "Data Control" panel, drag the JobsView1 into the page, and insert it as a read only table.


19. Choose "Single Row" for selection, and click Ok.

20. Back to the "adf-config" unbounded task flow, and drag a new view for the job form.


21. Double click the new page, and drag the JobsView1 into it from the "Data Control" panel as a form.



22. Check the "Include submit button" checkbox, and click Ok.



23. Back to the "adf-config" unbounded task flow, and drag a new view for the job details.


24. Double click the new view, and add the JobsView1 into it as a read only form, and click Ok.


25. Back to the "adf-config" unbounded task flow, In the "Data Control" panel, expand the JobsView1 -> Operations and drag the "CreateInsert" operation into the task flow.



26. Do the same for "Delete" operation.

27. From "Data Control" -> Operations, drag "Commit" and "Rollback" operations into the task flow page.


28. From the "Component Palette" panel click the "Control Flow Case" icon and drag from "jobsView" page to the "viewJobDetails" page, and name it "view".


29. Do the following to complete navigation flow for our business case:

A. "create" flow from "jobsView" to "createInsert" operation.
B. "edit" flow from "jobsView" to "jobForm" page.
C. "delete" flow from "jobsView" to "delete" operation.
D. "CreateInsert" flow from "CreateInsert" operation to "jobForm" page.
E. "Delete" flow from "Delete" operation to "Commit" operation.
F. "save" flow from "jobForm" page to "Commit" operation.
G. "cancel" flow from "jobForm" page to "Rollback" operation.
H. "Commit" flow from "Commit" operation to "jobsView" page.
I. "Rollback" flow from "Rollback" operation to "jobsView" page.
J. "back" flow from "viewJobDetails" page to "jobsView" page.


30. Go to the "jobsView" page, and double click it, and from the property panel, change the action for each button to be as follow:

A. "View" button action = "view"
B. "Create" button action = "create"
C. "Delete" button action = "delete"
D. "Edit" button action = "edit"


31. In the "jobForm" page, add a new button and name it cancel, and the action = cancel, imediate=true.


32. In the "viewJobDetails" page add a new button and name it back, and the action = back.


33. Right click the adf-config unbounded task flow and click run, if prompted to choose the run configuration choose "jobsView" page to be the start page.

34. Screen shots for the application:



Done.

Wednesday, 4 January 2017

How to enforce package naming standards and object naming standard for ADF Business Components

It is indeed a pain to work in an Oracle ADF project where there are multiple developers and everyone names their objects according to their wish.We had the same kind of issue in my previous Oracle ADF  Development project.This has to be the first priority before even starting the coding.If not, you are in for a big shock when you look at the object names in future :)
Oracle JDeveloper comes with a great feature to tackle this scenario and does a wonderful job.Let us look at the steps to implement the same.


Use the Tools –> Preferences –> ADF Business Components –> Packages for Package Naming standards
wfpteusp
Use the Tools –> Preferences –> ADF Business Components –> Object Naming standards
xmyxu5ff
Thats it !! Now when you generate the Business components from table, it will automagically names the Objects and packages based on your settings in JDeveloper.Though I would like this to be an export and import feature because this needs to be done at every developer’s jdev.

JDeveloper - Some common useful shortcut (Ctrl + Enter)

1. Call up code template by "Ctrl + Enter"
Eg 1.. Input "for" in the editor and get the code template of "for loop" syntax block
Steps:

  1. Input "for"
  2. Press "Ctrl + Enter"
  3. Code will become to:
      for (init; condition; next) { 
             
        }
Eg 2. Input "trycf" in the editor and get the code template "try / catch / final" syntax block
Steps:

  1. Input "trycf"
  2. Press "Ctrl + Enter"
  3. Code will become to:
      try {
          
        } catch (Exception e) {
            // TODO: Add catch code
            e.printStackTrace();
        } finally {
        }

Eg 3. Input "sop" in the editor and get the code template "system output's print line" syntax block
Steps:

  1. Input "sop"
  2. Press "Ctrl + Enter"
  3. Code will become to:
      System.out.println();

Framework chosen

Nowadays, many IT organizations have applied different combinations of Java technologies to write new applications in and migrating existing applications in Java environment. However, one major aspect of Java is its enormous variety and breadth. There is no one way to create a system. In fact, there are many options we can choose between probably hundreds of combinations of Java technologies in JEE environment: JSP, Servlet, Spring Framework, JSF, Oracle ADF, Tapestry, etc. Nobody can state exactly which one is the best for the application development. I would like to state that vendors like Oracle (Oracle ADF technologies) and Spring Source (Spring Framework) create Java EE–compliant products by implementing the Java EE specifications.

Java Enterprise Edition (Java EE) is a set of standards and specifications (called a platform) that defines the environment for running software written using the Java language. Java EE (formerly called "J2EE") is created and maintained by Sun Micro-systems, but anyone may suggest and work on enhancements using the Java Community Process.

Glossary:
Java EE - Java Enterprise Edition
JEE - Java Enterprise Edition
JSP - JavaServer Pages
JSF - JavaServer Faces
Oracle ADF technologies - Oracle Application Development Framework technologies
ADF BC - ADF Business Components
EIS - Enterprise Information System
EJBs - Enterprise JavaBeans
WLS - Oracle WebLogic Server (WLS, formerly from BEA Systems)
OC4J - Oracle Containers for Java EE

My understanding of Framework


Over the years, I have been working on Spring MVC Framework and recognize that a MVC framework is a suitable model for agile development and easy for maintenance. But I have read a book "Oracle JDeveloper 11g Handbook - A Guide to Oracle Fusion Web Development" (This book focuses on the key ADF technologies used by Fusion (ADF Faces, ADF Controller, and ADF Business Components)) recently. It told me the definition of Framework and Meta-Framework. Here is the part of definition described in the book:

Framework
Frameworks evolve as concrete implementations of such patterns, factoring out the repeated portion of task, and leaving programmers with a more limited exercise of configuring the parameters of the framework to theirs needs and much less coding overall although coding is never completely eliminated. 

Configured, not coded By definition, a framework performs most boilerplate and plumbing tasks for you. In order for that to happen, the framework must offer a way to define configuration data that provides the information it needs. This configuration data, or metadata, is sometimes injected through code or code annotations, but more often through some sort of configuration file. XML is typically used for such metadata files in modern frameworks, although this does not have to be the case.

Meta-Framework
We've just started to define a framework, and already we've introduced a twist in the form of meta-frameworks. What's this all about? A meta-framework is an end-to-end application development framework that encompasses a wide range of functionality. The meta-framework not only provides functionality, but it may also encapsulate or subsume multiple single-solution frameworks. If a single-solution framework is a screwdriver, a meta-framework is the whole toolbox.
Furthermore, the definition of meta-frameworks includes the idea that they offer choice and pluggability for particular tasks. For the O/R mapping example, meta-frameworks, such as Oracle ADF or Spring, allow the developer to choose one out of a whole range of O/R mapping solutions to implementation will not have an effect on the rest of the application. The user interface, for instance, will be unaware of the actual O/R mapping mechanism being used. This allows for much more flexibility in the development of the application as well as ease in changing the underlying technologies later should the need arise.

After I read the definition of framework from this book, I think that I should state this and tell all of you the main concept of a framework should be:

Framework is a boilerplate, not coded, configured by XML files or injected by code or code annotations, multiple choice for developer to choose solution for the implementation of application (Such as O/R mapping solution).

Glossary:
Oracle ADF technologies - Oracle Application Development Framework technologies
O/R mapping - Object-relational mapping
Oracle WebLogic - A Java Enerprise container engine