I've been developing ADF projects at client sites for over 4 years now (wow, that went fast!). The purpose of this blog is to point out the first things I do on every project to make it run smoothly.  Two of these are JDeveloper configurations, but I sometimes miss them after I've installed a new version of JDeveloper or have a new laptop to work with.  The other are project level setups to customize projects specifically.  These recommendations are based on the 12c version of ADF, however these are applicable to 11g (although the instructions may vary).

Configure JDeveloper to Package Business Components

This is a JDeveloper configuration that automatically organizes business components into packages.  When business components are initially imported into a project it is nice to have them automatically organized.  The configuration only needs to be done once, and it will be used every time business components are created.

  1. In JDeveloper, select 'Tools' -> 'Preferences'
  2. Expand 'ADF Business Components' and select Packages
  3. Create default package names for each component type

Additionally you can set defaults for Object Naming, which will provide suffix's for the different types of business components.  Make sure you consult Oracle's ADF naming standards.

Same Code Reformat Settings

This setting ensures that every time the 'Reformat' functionality is run, that it will be consistent (especially in a multi-developer situation).  The reformat functionality should be used frequently to keep code clean and organized.  When using a version control system, when users use the reformat with different settings it appears that many lines have changed, when in reality it could have been no change at all.  Keeping these settings consistent makes it easier to track changes while customizing the coding style.

One of the critical settings is the 'Line Width' property.  This will change long lines into multi lines so that its viewable on the screen.  This is used in all files, including Java and XML.   In 11g the default was set at 80 characters which is an inherited length from back in the day when code was on punch cards (ref. http://en.wikipedia.org/wiki/Characters_per_line).  JDeveloper 12c has defaulted this to 120, but if all developers have large monitors you may want it to be even larger.

  1. In JDeveloper, select 'Tools' -> 'Preferences'
  2. Expand 'Code Editor' and select 'Code Style'
  3. Click the 'Edit' button
  4. Expand 'Line Wrapping' and change the 'Line Width' property as desired

Other settings can be modified here to personalize a coding style, including indent sizes, tab sizes, blank lines, spaces and more.  Just be sure to keep all of these settings the same among developers so that reformatting a file is consistent for all developers.

Create an ADF Skin and Add Font-Awesome

Having an ADF skin defined from the beginning makes it very easy for developers to add style classes.  As a best practice these should be used instead of inline styles.  

To provide stylish UIs, icons are often used instead of text.  Many icons are standard and I end up wasting time manually to find a single nice looking icon.  Adding font-awesome provides a great way to add hundreds of icons easily to your ADF application.  No more searching for an image of a trashcan to replace 'Delete' text, or a plus sign to replace 'Add' text, or even a pencil for 'Edit'.  Check out all the icons at: http://fortawesome.github.io/Font-Awesome/

To create an ADF Skin (12c):

  1. Once your application is created, right click on the view project and select 'New' -> 'From Gallery'
  2. Expand out 'Web Tier' then select 'JSF/Facelets'
  3. Select 'ADF Skin' and hit 'Ok'

  4. Go through the rest of the wizard to assign a name, directory, family, and base skin.  Then hit 'Finish'

To add font-awesome:

  1. Download the skin from: http://fortawesome.github.io/Font-Awesome/
  2. Unzip the contents into <ViewProject>/public_html/skins directory (technically you only need the font-awesome.css or minimized version and the fonts directory)
  3. In your custom css class created above, add the css similar to:

    @import url('../font-awesome-4.3.0/css/font-awesome.min.css');
  4. Check out all of the icons and how to use them here: http://fortawesome.github.io/Font-Awesome/icons/ 

Define the Context root

The context root of an application defines what the base url will look like when accessing the contained pages.  By default, JDeveloper uses '<ApplicationName>-<ProjectName>-context-root'.  In most cases a shorter more detailed context root should be used ie. salesdashboard

  1. Right click on the View project, and select 'Project Properties'
  2. Select 'Java EE Application'
  3. Enter in the new Java EE Web Context Root

By default, the deployment profile will use the Java EE Web Context Root, however it can also be changed in the deployment profile configuration.  Now accessing a page URL is as easy as:

With these suggestions in place, business components will be automatically organized, reformatting will keep your code clean looking and consistent.  Adding in a custom skin with font-awesome makes it very easy to style and add icons for a better look and feel.  Finally the context root is just a clean way to provide end users with a better URL when accessing the application.  Feel free to comment and add any other project setup must-do's!