Saturday 27 July 2013

18. Using Code Templates in JDeveloper

While coding in JDev, we often use code templates. For example, for writing 'System.out.println();', we can write 'sop' then press ctrl+Enter.
We can also create our own code templates and then when required, instead of writing the complete code, we can simply use custom shortcuts for our code.

Here I have shown how to create and use these custom code templates.

Mostly we face a requirement to navigate from one page to another on button click and also passing some parameters along with that. Below are steps for creating template for this:

1) Go to 'Tools --> Preferences...'


2) On Preferences window, expand 'Code Editor --> Code Templates'.


3) Click on Add, enter shortcut and description. In the code tab, write the code which you want on that shortcut as shown below:


4) Also, if we want to import some classes for that code, we can write those in 'Imports' tab.


5) Now we only need to write this shortcut 'navOnBtn' then press ctrl+Enter. This will automatically replace that shortcut name with the complete code.








1 comment:

  1. Hi Prashant,
    Can you provide custom templates to use in oaf.

    thx
    amey

    ReplyDelete