Sunday, 16 December 2012

Code Template in JDeveloper

Jdeveloper11g is having many interesting features, these features make our work easier and simpler. Most of the features may be known to you all but I came to know with the feature of "Code Template".

There are many predefined code templates in the JDev which can make our coding much faster and save lot of time. Code templates shortcuts can be used in the code by pressing the short-cut key CTRL+ENTER.

E.g : Type "main" in the source editor and press CTRL+ENTER, JDev will type the complete main method code for you.

You can define your own short-cuts in the JDev code template.

The example below will create a template which will help you to avoid writing the code as - System.out.println in Entry and Exit of the method.

Follow the below steps :

1. Goto tools->Prefrences

2. Select Code Template from the left panel.

3. Click on add  . A row will be created :
           a.  Define the shortcut key "sopenx".
           b.  Context as Java statement and provide the description

4. Write the code as below - 

5. Provide the values to the variable defined.

6. Click "OK".

The code template is defined and ready for use in your JDeveloper.

Type "sopenx" in the source editor and press CTRL+ENTER, JDeveloper will complete the code.

Note : We can export this template defined and share with other users.

1. Select the template shortcut defined and export selected.

Save in the desired location.

*Comments and feedback are most welcomed, Thanks.