conn, ife, sop & try


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";
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;
and the following imports:
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:

CodeTemplates:


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:

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 on June 26, 2006 at 06:00 AM CEST #

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 on September 05, 2006 at 06:22 AM CEST #

Post a Comment:
Comments are closed for this entry.
About

Didier Laurent - Sr Principal Support Engineer in the JDeveloper team

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today