Creating Custom JSP Templates
When creating a new JSP page, you can base the new page on a pre-existing template instead of a blank page. The template can contain common header/footer information for the page or really anything you want.
Separate sets of JSP page templates are associated with the different types of project you work on. The types of projects are:
- JSF
- Struts
Saving JSP Page as a Template
Switch to WebProjects view and right click any JSP page. Select Save as Template....
Using Preference Settings to Create a Template
Creating your own template based on a page that you have created within one of your projects in your Eclipse workspace is pretty easy.
- Open the Preferences panel by selecting Windows/Preferences from the menu bar.
- Navigate to the Exadel/JSF/JSF Pages or Exadel/Struts/Struts Pages section.
- Click on the Add button to the right of the template list.
- In the dialog box that appears, type in a name for the template and then use the Browse... button to select the location of the page you want to make into a template.
Creating a JSP Page with a Template
JSF
- In the Project Explorer view select the folder where you want to create JSP file.
- Right click>New>JSP File (or in the Web Projects view, right click>New>File>JSP File)
- Expand Template field and select the template.
JSFBasePage
JSPRedirect
Struts
StrutsForm
Using the File System to Create a Template
Alternatively, you can create the template outside of Eclipse. Just open this folder:
<eclipse>\plugins\com.exadel.project.templates_X.X.X\templatesCreate a text file with the coding you want for the template. Name the file exactly as you want the template name to appear. Then, place the file inside the appropriate folder for the project type (
jsf or struts). Or, place the file at the same level as the Blank file for the template to be available to either project type.
After you restart Eclipse, your template will be available.