conn, ife, sop & try
Oh, weird
language, isn't it.
These are the code templates I use
most often.
A code template is a nice feature of
JDeveloper.
You type a shortcut, eg try, followed by the
CTRL+Enter key combination and the equivalent template code
is added in the source editor,
at the point where your cursor was.
It
will also bring any associated imports.
For example,
typing conn in the source editor followed by the
CTRL+Enter key combination will add the following code:
String username = "scott";and the following imports:
String password = "tiger";
String thinConn = "jdbc:oracle:thin:@localhost:1521:ORCL";
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(thinConn,username,password);
conn.setAutoCommit(false);
return conn;
import java.sql.*;
import oracle.jdbc.OracleDriver;
I think it's worth you have a look at all the avalable shortcuts:
select menu Tools --> Preferences..., expand Code Editor and click Code Templates.
You can see there the shortcuts with a small description.
Selecting any shortcut displays the code as shown in the followin picture:

I had never defined my own template before, but I'll certainly do, after having read Frank's post in his blog:
How to automatically add the class name and creation date to a Java file
Frank explains there how you can create your own template, and take advantage of variables (new in JDeveloper 10.1.3).
In his example, a variable $file$ will automatically get assigned the name of the Class and $date$ the current date.
By googling, I see that Steve also explained How to Create a Code Template for JSTL Choose.
Great !
Comments (2)
Sandra from the JHeadstart group shows an example of a code template usage in her post "JDeveloper Code Template for log4j"
Posted by Didier Laurent | June 26, 2006 1:00 PM
Posted on June 26, 2006 13:00
Nice tips. I've had some major problems with templates with a new blog - http://www.datingsite-review.com/ - thanks for your tips!
Posted by Dave | September 5, 2006 1:22 PM
Posted on September 5, 2006 13:22