Pramati Technologies

Using File Templates

Studio allows the user to develop two basic types of enterprise Java components - EJB and Web. EJB components include plain Java files and Enterprise JavaBeans, while Web components include Servlets and JavaServer Pages and Taglibs. HTML files and images are some of the other "static" components that can be written in Studio.

Choosing a File Type to Create

Studio provides templates to generate files through the New File dialog.

Main Menu > File > New

This brings up the dialog box where the different type of files can be created using the templates provided. The different types of files that can be generated are Java, Servlet, JSP pages, HTML, JSP tags, JAR, WAR, EAR and Taglibs.

Select the type of file to be created and click OK. Clicking on OK brings up the specific dialog box to create a template for the file.

Java

Studio provides three templates for Java files. Key in the following data to create a Java file:

Class Name The complete qualified class name followed by the class name of the Java file to be created.

Source Root Choose from the active Desk's EJB Module, Desk Source Root or Web Module.

Template Choose from the templates available. The three templates that are provided are:

Servlet

Servlets extend the functionality of a Web server and receive HTTP requests from a client, dynamically generate the response (according to programmed instructions), and send the response in an HTML or XML format to the client. To create a Servlet file, type in the following details:

Class Name The package name followed by the class name of the Servlet file.

Source Root Choose from the active Desk's EJB Module, or Web Module.

Template Choose from the templates available. The three templates that are provided are:

JavaServer Pages

The JavaServer Pages (JSP) technology is an extensible technology that enables the generation of dynamic content for a Web client. A JSP page contains HTML and XML tags to format the Web document's content and JSP tags and scriptlets to generate the dynamic content in the Web document. To create a JavaServer Page file, key in the following information:

File Name The name of the JSP file to be created.

Web Module Choose from the active Desk's Web Modules.

Template Choose from the templates available. The three templates that are provided are:

Filters

Filters are components that dynamically filter intercepts requests and responses to transform or use the information contained in the requests or responses. Filters typically do not create responses themselves, but instead provide universal functions that can be attached to any type of servlet or JSP page.

To create a Filter, key in the following information in the Filters template:

Class Name Enter the fully qualified class name of the Filter in this field.

Source Root Choose from the Desk's EJB Module, or Web Module.

Template Choose from the templates available. The two templates that are provided are:

After the file is created, follow the given steps to deploy it as a part of the Web Module.

HTML

HTML files comprises tags used to design web pages. HTML files are also used by JavaServer Pages. Key in the following information to create HTML files:

File Name The name of the HTML file to be created.

Web Module Choose from the active Desk's Web Modules.

Template Choose from the default templates provided to create the HTML file. This creates an empty HTML file with the basic required tags.

JSP Tag

JSP Tag is a piece of text between a left angle bracket and a right angle bracket that has a name and can have attributes, and is a part of an element in a JSP Page. Key in the following information to generate a JSP tag files.

Tag Class This field is mandatory. The main class of the tag is added here. Defines the tag handler class implementing the javax.serlvet.jsp.tagext.Tag interface.

TEI Class The Tag Extra Info Class is added here. It is an optional subclass of javax.servlet.jsp.targetx.TagExtraInfo. This field is optional.

Source Root Choose from the active Desk's Source Roots - EJB Module, Web Module or Desk Source Root.

Body Content The Tag writers explicitly specify the nature of the content of its Body here. This is primarily intended for use by page composition tools. The three options provided are:

Tag Types Specify a type of the tag to be created. To understand how choosing the Tag Type helps in creating the Tag, understanding the Tag Handler is important.

A tag handler is a Java class that implements the Tag or BodyTag interfaces and that is the run-time representation of a custom action. This handler object is a Java object that implements the javax.servlet.jsp.tagext.Tag interface. The handler object is responsible for the interaction between the JSP page and additional server-side objects.

Choose from the following options provided under the Tag Types:

Clicking on OK creates a folder with the tagName and creates the tagClassFile inside that folder. This file has a predefined template depending on the options chosen for generating the template.

If a TEI ClassName is provided, then a template for TagExtraInfo is also created.

Creating a File Template

A Template is a basic framework used for writing a program with repetitive code. All template are stored under <install_dir>/templates/(java/jsp/servlet/htm) in Studio. Create and store the templates under the respective folders. All templates should have the extension - .template. To create new templates, use the following placeholders provided:

PlaceHolder Name
Replaced With
<_AUTHOR_NAME_>
The current user name of the system.
<_CLASS_NAME_>
The Class name of the Java file. Used in the Java and Servlet templates.
<_PACKAGE_NAME_>
The key-word package and the package name of the Java file. Used in the Java and Servlet templates.
<_FILE_NAME_>
The file name of the Java, jsp and html provided while creating the file.
<_DATE_>
The system date is inserted while creating the file.

Opening Existing Files

Main Menu > File > Open

Clicking on this displays a dialog box where an existing file to be opened can be chosen. Select the file and click Open. Opening a file when the Desk is not open, also opens the Desk.

Main Menu > File > (Select File)

Displays the ten recently opened files in the Editor, by default. To modify the number of recent files that can be opened, use the Preferences dialog. Opening a file when the Desk is not open, also opens the Desk.

Opening Files from the Explore Panel

Double clicking on a closed file in the Explore Panel opens the file in the Display Panel. To make an opened file active and viewing it in the Display Panel, single click on the file name in the Explore Panel.

All open files appear in black font with coloured icons, and all closed files in grey font with grey icons, in the Explore Panel. The active file always appears in black and bold font with the coloured icon in the Explore Panel, and can be easily distinguished from the others.

Importing Files

Right Click on Node > Import Files...

This brings up the dialog to import files and folders, as follows:

Base Directory The location from where the files and folders have to be imported.

Recurse Enabling this option imports all the files under the specific folder and its subfolders. This option is by default enabled.

Filter Type the filter to be implemented while searching for the files. Once the filter has been decided click on Search. This displays a list of all files available with the specific requirements.

Target Directory Choosing a Target Directory adds the specific path before the file that is added. This is optional. Not selecting a target directory adds the files directly under the folder where the right click was implemented.

Add Selecting all the files to be added and clicking on Add places the selected files in the Selected Files box.

Repeat the process as many times required. Clicking on OK adds all the files in the target directories.

Importing files into Web Modules

Importing very large number of files into a Web Module may increase the memory load on the system, causing Studio to become very slow. To reduce the memory load on the system, import only those files that are going to be edited in Studio Editor. The other files can be manually copied under the web-module directory but not imported into the desk.

The web-container serves all files present in the file system and will not be restricted to the files in the desk. Similarly Export as Archive will package all files from the file-system. Large files like image files (*.gif, *.bmp etc.), zip files and some other files that are just content need not be imported into Studio.

Saving Files

Main Menu > File > Save

Saves the active file open in the Editor.

Main Menu > File > Save As

Saves a copy of the file at the desired location.

Main Menu > File > Save All

Saves all the files currently open in the Editor.

Closing Files

Main Menu > File > Close

Closes the active file open in the Editor.

Main Menu > File > Close All

Closes all files open in the Editor.

Printing Files

Main Menu > File > Print

Prints the active file open in the Editor.

Recently Opened Files

Allows you to view the names of all the files open in the Editor. Clicking on the file name displays the same in the Display Panel.

Viewing Open Files

View > Show Open Files...

Clicking on this pops up a floating panel that displays all the names of the open files in the Display Panel. Single Click on the name of the file makes that file active and displays the file in the Display Panel.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX