This document provides a general description of how to add support for a web framework in NetBeans IDE. The steps provided show how you can add support by installing a web framework plugin into the IDE using the Plugins manager. After you install the plugin you will be able to select the framework in the New Project wizard when you create a web project. The new web project that you create will contain the necessary infrastructure specific to the chosen framework.
The easiest way to add support for a particular web framework is by installing a NetBeans plugin using the IDE's Plugins manager if the plugin is available. This is convenient if you have Internet access while working in the IDE. Plugins for many web frameworks are also available via the NetBeans Plugin Portal. If you do not have regular Internet access, you can download the plugin modules (e.g., from the Plugin Portal) when you have the opportunity, then install them into the IDE at a later time.
In this tutorial you will add support for the Apache Struts 2 framework by downloading a plugin from the NetBeans Plugin Portal and installing the plugin using the Plugins manager.
Note: NetBeans IDE 7.2 bundles support for the JavaServer Faces 2.1 and Struts 1.3.10 and Spring 3.1.1 frameworks.
To complete this tutorial, you need the following software and resources.
|Software or Resource||Version Required|
|NetBeans IDE, Java EE bundle||7.0, 7.1, 7.2, 7.3|
|Java Development Kit (JDK)||version 6 or 7|
You can add support for a specific framework by installing the appropriate framework support plugin into the IDE. To do so, you can either download the plugin modules from an external site such as the NetBeans Plugin Portal then install the plugin via the Plugins Manager, or, if the plugin is maintained by an update center, you can register the update center with the IDE's Plugins Manager and then download and install the plugin directly through the Plugins Manager.
Some plugins are available for download from sites such as the NetBeans Plugin Portal or directly from the site of the plugin developer. The following table provides links to locations where you can download some plugins for frameworks.
|Framework||Plugin Location||Download Location|
|Apache Struts 2||http://java.net/projects/nbstruts2support/||http://plugins.netbeans.org/plugin/39218/struts2-support-repack-for-nb-7-0|
For the purpose of demonstration, this section will describe how to download and install the Apache Struts2 Support Repack for NB 7.0 plugin from the NetBeans Plugin Portal. This plugin installs the libraries and UI support for Apache Struts 2.
Note. The plugin repackages the NetBeans Struts2 Support plugin because the NetBeans Struts2 Support plugin has not been updated for NetBeans IDE 7.0. For additional information about each of the plugins, see the respective plugin details pages.
When you extract the contents, you will see that the archive contains three files.
NetBeans plugins can be identified by the .nbm extension.
Hold down the Ctrl key to select multiple items.
A description of the selected plugin is displayed in the right pane of the Plugins manager.
Note. If you receive a validation warning, click Continue to install the plugin. A validation warning occurs if you attempt to install a plugin that has not been signed. While you can generally trust all plugins, when you install a plugin that has not been signed, you are doing so at your own risk.
After you install the plugin and restart the IDE, you can confirm that the plugin was installed by opening the Plugins manager, clicking the Installed tab and locating the plugin in the list of installed plugins.
If the framework support plugin is maintained by an update center, you should consider installing the update center into the IDE. This enables you to then install the framework support plugin directly through the Plugins manager. The Plugins manager also logs any updates made to plugins maintained by update centers, providing you with a simple and effective means of keeping installed plugins up-to-date.
Various update centers are already registered with the IDE by default. To see a list of the update centers that are currently registered, open the Plugins manager (Tools > Plugins) and choose the Settings tab.
If you want to register a new update center, click the Add button in the Settings tab and supply the details in the Update Center Customizer.
The Plugin Portal update center that is registered with the IDE by default contains a subset of the plugins that are contributed by the community and that are known to be compatible with the version of the IDE that you installed. If you want to use the Plugins manager to browse all the plugins that are available from the NetBeans Plugin Portal, you can perform the following steps to install a plugin to add the NetBeans Plugin Portal Update Center to the list of registered updated centers.
After you install the plugin, the NetBeans Plugin Portal Update Center is added to the list of registered update centers in the Settings tab of the Plugins manager
Note. You can deactivate an update center by deselecting the checkbox for the update center in the Active column of the Settings tab.
If you click the Available Plugins tab you can see that all the plugins that have been contributed by the community to the NetBeans Plugin Portal have been added to the list of available plugins.
Click Reload Catalog to update the list of plugins.
You can sort the list by clicking on a column heading and you can filter the list by entering terms in the Search field.
The Plugin Portal Update Center lists all the plugins that are available from the NetBeans Plugin Portal. Many of the plugins will be for older versions of the IDE and will be incompatible with the version of the IDE that you are using. Installing plugins for other versions of the IDE might cause your IDE installation to behave unreliably. In many cases, but not all, there will be a message that informs you if a plugin cannot be installed. As with the installation of all software, you should exercise caution and carefully read the documentation before attempting to install a plugin.
Framework support in the IDE is generally specific to the framework you are working with. For example, the Struts2 support provides wizards that enable you to easily create commonly-used Struts classes, as well as code completion in Struts configuration files.
You can add framework support to a web application either through the New Project wizard at the time that you create the application, or you can integrate support into an existing application.
In this example, support for the Struts2 framework is selected in the Frameworks panel. You can see that the Frameworks panel now offers the option to choose either Struts 1.3.8 (bundled with the IDE) or Struts2 (added by installing a plugin). The Struts 2 support plugin adds the Struts2 option to the New Projects wizard and displays tabs with options for Configuration and Libraries. The Configuration tab provides the option to create an example page in the project. The Libraries tab enables you to select the version of the Struts2 libraries that you want to add to the classpath.
When you click Finish, the IDE creates the web application. The additional files that the wizard creates will vary according to the framework. In this example, the wizard created the struts.xml XML configuration file in the Source Packages folder and added the required Struts2 libraries to the classpath. The wizard also automatically added a Servlet filter class and a filter mapping to web.xml.
If you have an existing web project and you would like to add support for a framework to the project, you can use the Project Properties dialog box to add frameworks that are available in the IDE.
When you select Frameworks, the right panel displays a Used Frameworks text area, which is empty if the application does not use a framework.
For example, if you want to specify the ICEfaces component suite you can select ICEfaces in the Components tab of the Project Properties window and specify the ICEfaces library.
Notes. The libraries for JSF components are not included with the IDE. To use a component suite you need to download the required libraries and then create a NetBeans library that you can then add to the project classpath in the Project Properties window.
This document described how to add support for a web framework in NetBeans IDE. It demonstrated how to install framework support plugins by downloading manually as well as via an update center in the IDE's Plugin Manager. It also showed how to add an IDE-supported framework to both a new web application project and an existing project.
This tutorial focused on adding the Struts2 framework. If you would like to explore the other features offered by this framework, see Introduction to the Struts Web Framework.
For more information about using other web frameworks in NetBeans IDE, see the following resources: