Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:18:15 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

October 2005
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Sep   Nov

Get Firefox!

Thursday, October 27, 2005

I often find myself writing code like this:

EmployeesRow empRow = (EmployeesRow)iter.next();

It's a pain that I need to type in the EmployeesRow part twice, and a pain that I need to invent a name for this local variable. So, I tried out our new Smart Code Templates feature today to make my life easier. Using JDeveloper 10.1.3 Early Access 1 release from OTN, here's what I did...

  1. Selected Tools | Preferences... menu and selected the Code Templates category under the Code Editor group.
  2. Clicked (Add) to add a new code template
  3. Typed a Shortcut name of "cast" in the table in the new row
  4. Click into the Code area and typed the following:
    $type$ $name$ = ($type$)$end$
  5. Selected the Variables tab, and picked the suggestNameFromType() function from the dropdown for the type of the name code template variable.
  6. I typed $type$ inside the parenthesis to leave the type of the name variable looking like suggestNameFromType($type$)
  7. Then I clicked (Ok).
I then went back to my code editor, and now whenver I want to type this kind of cast statement, I can just type:

cast + [Ctrl][Enter]

And it will expand to let me fill in the smart variables by typing and tabbing between them. If I type EmpViewRow as the value for the first smart variable, and press [Tab] twice, my cursor will be placed where the $end$ token was in the code template, where I can finish the job, having saved some typing. The name of the variable gets automatically suggested from the type that I've entered for the first smart variable. Pretty powerful stuff.

2:44:29 PM    



© Copyright 2008 Steve Muench.