JBoss.orgCommunity Documentation

Chapter 2. Projects

2.1. Creating a New Struts Project
2.2. Importing an Existing Struts Project with Any Structure
2.3. Adding Struts Capability to an Existing Web Application
2.4. Relevant Resources Links

JBoss Tools provides the following functionality when working with Struts:

Now, we'll focus on all these points more fully.

JBoss Tools provides a New Struts Project Wizard that significantly simplifies the process of creating a new Struts project. You just need to follow these steps:


  • On this form, provide the Project Name. You can also select where to create the project, or use the default path.

    The Struts Environment sets the Struts version that will be used.


Tip:

Don't put spaces in project names since some operating systems may experience problems processing and searching for these files.

You can select the KickStart template, which results in a project that includes a simple Hello World type application that is ready to run.


  • Next, you register this application with the current servlet container defined for your workspace (JBoss AS, by default) in order to allow you to easily test your application while still developing it. A new entry will be added in the servlet container configuration file to enable the application to be run in-place (called null deployment or link deployment). Uncheck the "Target Server" check box if you prefer not to register your application at this point.


  • On the next form, you can select the TLD files to include in this project:


After the project is created, you should have the following project structure (if you used the KickStart template):


Tip:

If you want to hide the JAR files from Web App Libraries in view, select the down-pointing arrow in the upper right corner, select Filters..., check the box next to Name filter patterns (matching names will be hidden), and type *.jar into the field. Then, click the OK button.

For detailed information on migration projects to JBoss Developer Studio see the Migration Guide.

This section will describe how to add Struts functionality (Struts libraries, tag libraries and a Struts configuration file) to any existing Web application project in your Eclipse workspace.

By adding a Struts Nature to your project, you can now edit files using JBoss Tools editors, such as the Struts configuration editor and the JBoss Tools JSP editor. To take advantage of this just right-click the project and select JBoss ToolsAdd Struts Capabilities from the context menu. This will start the process of adding all the necessary Struts libraries and files to your existing project.


In the wizard you should point to the location of your deployment descriptor file web.xml and name of the project.


After clicking the Next button you will see the following screen. This screen simply indicates that you need to add at least one Struts module to your project to make this project a Struts project. Adding a Struts module means that a new struts-config.xml will be added to your project and registered in the web.xml file. In addition, all required Struts libraries will be added. To add a Struts module, click the Add Struts Support button.


Here you can select which Struts Version, Servlet Class, URL Pattern and TLDs to add to this project.


When done, you will see the default Struts module configuration information. See how to Edit Struts modules.


On the last screen you can set the different folders for your project as well as register this application with a servlet container. If you want the libraries (.jar files) to be automatically added to your project, tick the Add Libraries checkbox.


When done, you can open and edit the struts-config.xml file using useful Struts configuration file editor provided by JBDS. (The Struts configuration is shown below in the Tree viewer).


You can find more in-depth explanation on how to work with special wizards, editors and views that can be used in various scenarios while developing Struts applications in our Visual Web Tools Guide.