Using Code Template for Reusable codes in Jdeveloper IDE

Sharing is Caring

JDeveloper IDE comes with lots of features and one of them is Code Template, Code Template means some saved code that can be used using a shortcut key anywhere in the editor.
There are many preconfigured templates for e.g.
Type sop in editor and press ctrl+enter and IDE will write

System.out.println();

Type main in editor and press ctrl+enter and IDE will write

    public static void main(String[] args) {
        ;
    }

In the same way we can create our own code templates (Reusable code), To define custom Code Templates in JDeveloper follow these steps

Click on Tools menu on top toolbar in JDeveloper IDE, Select Preferences from the drop down menu

Navigate to Code Editor–Code Templates
 
Click on green plus icon and Enter ShortCut, Context and Code, here I have added code to get Binding Container of the current page as it is needed often in ADF Application

Now open your java class, type code template shortcut and press ctrl+enter, template code will be added in your java class. So this is a great utility and saves extra efforts

and yes you can export code templates and share with your team members and they can import it to use
Code Template
Exported Code Template (XML Format) looks like this

Cheers 🙂 Happy Learning

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

0 thoughts on “Using Code Template for Reusable codes in Jdeveloper IDE”

  1. Ashish how are you ?
    I wish to know how to update the view instance on certain page if you insert rows in ViewObjectImpl

    Example
    i use employee table in page and there is a button that insert 5 rows once i have been wrote the method that insert those rows in EmployeeImpl and EmployeeRowImpl row inserted but i want to update the view instance and iterator to get those new rows that inserted

  2. You can simply call createRow and insertRow method to insert and update row in view instance

    ViewObjectImpl demo1 = am.getEmployeesDemo1();
    Row r2 = demo1.createRow(); // Creates a row in ViewObject

    r2.setAttribute("EmployeeId", 001); // you can set all values
    demo1.insertRow(r2); //Insert that row in ViewObject

    Ashish

Leave a Reply

Your email address will not be published. Required fields are marked *