Visual Web Tools Reference Guide

Version: 2.0.0.GA


1. Visual Web Tools
2. Key Features of Visual Web Tools
+3. Java Server Faces Support
3.1. Support for JSF Environments: JSF-RI, MyFaces, Facelets or any Custom
3.2. Facelets Support
+3.3. Working with Projects
3.3.1. Creating a New JSF Project
3.3.2. Importing Existing JSF Projects with Any Structure
3.3.3. Adding JSF Capability to Any Existing Eclipse Project
3.3.4. Adding Your Own Project Templates
+3.4. Graphical Editor and Viewing for JSF Configuration Files
3.4.1. Diagram
3.4.2. Creating New View (Page)
3.4.3. Tree View
3.4.4. Source View
3.4.5. Content Assist
3.4.6. Error Reporting
+3.5. Managed Beans
3.5.1. Code Generation for Managed Beans
3.5.2. Add Existing Java Beans to a JSF Configuration File
3.6. Create and Register a Custom Converter
3.7. Create and Register a Custom Validator
3.8. Create and Register Referenced Beans
+4. Struts
4.1. Support for Struts 1.1, 1.2.x
+4.2. Working with Projects
4.2.1. Creating a New Struts Project
4.2.2. Importing an Existing Struts Project with Any Structure
4.2.3. Adding Struts Capability to an Existing Web Application
+4.3. Graphical Editor for Struts Configuration Files
4.3.1. Diagram Mode
4.3.2. Tree Mode
4.3.3. Source Mode
+4.4. Graphical Editor for Tiles Files
4.4.1. Create New Tiles File
4.4.2. Tree View
4.4.3. Diagram View
4.4.4. Source
4.5. Graphical Editor for Struts Validation Files
+4.6. Support for Multiple Struts Modules
4.6.1. Struts Modules
4.6.2. When Importing a Struts Project
4.6.3. Editing Modules in an Existing Project
4.6.4. Adding New Modules
4.7. Code Generation for Action, FormBean, Forward and Exception Classes
4.8. Struts Configuration File Debugger
4.9. Customizable Page Links Recognizer
+5. JBoss Tools Palette
+5.1. Using the Palette
5.1.1. JBoss Tools Palette
5.1.2. Inserting Tags into a JSP File
5.1.3. Adding Custom JSF Tags to the JBoss Tools Palette
5.1.4. Drag-and-Drop
5.1.5. Import Button
+5.2. Palette Options
5.2.1. Palette Editor
5.2.2. Show/Hide
5.2.3. Import
5.3. Rich Faces Support
+6. Web Projects View
6.1. Web Projects View
6.2. Project Organization
+6.3. Drag and Drop
6.3.1. For a Property
6.3.2. For Managed Bean Attributes
6.3.3. Navigation Rules
6.3.4. For a Tag Library File Declaration
6.3.5. For JSP Pages
6.4. Developing the Application
6.5. Expanding Tag Library Files
6.6. Drag and Drop Tag Libraries on to JBoss Tools Palette
6.7. Create and Import JSF and Struts Projects
+7. Verification and Validation
+7.1. JBoss Developer Studio Verification
7.1.1. JSF Project Verification
7.1.2. Struts Project Verification
+8. Editors
+8.1. Editors Features
+8.1.1. OpenOn
8.1.1.1. XML Files
8.1.1.2. JSP Pages
+8.1.2. Code Assist and Dynamic Code Assist (based on project data)
+8.1.2.1. Content Assist Features
8.1.2.1.1. Content Assist
+8.1.2.1.2. JSF Project Files
8.1.2.1.2.1. Content Assist for XML, JSP and JSF configuration files
8.1.2.1.2.2. Content Assist Based on Project Data
8.1.2.1.2.3. Content Assist within Tree JSF Editor
+8.1.2.1.3. Struts Project Files
8.1.2.1.3.1. Content Assist for Struts Configuration File
8.1.2.1.3.2. Content Assist for Struts JSP File
+8.1.2.1.4. JSP Pages
8.1.2.1.4.1. Content Assist for JSF Tags
8.1.2.1.4.2. Content Assist for JSTL Tags
8.1.2.1.4.3. Content Assist for HTML Tags
8.1.2.1.4.4. Content Assist for JavaScript Tags
8.1.2.1.4.5. Content Assist within JSF Configuration Editor
8.1.2.1.5. Content Assist for Rich Faces components
8.1.2.2. Adding dynamic code assist to custom components that were added to JBoss Tools Palette
8.1.3. Full Control over Source Files - Synchronized Source and Visual Editing
+8.2. Visual Page Editor
+8.2.1.
8.2.1.1. Advanced Settings
+8.2.2. Setup notes for Linux
8.2.2.1. How to Start the Visual Page Editor under Linux
8.2.3. JSP syntax validation
8.2.4. JSP Page Preview
+8.3. More Editors
8.3.1. Graphical Properties Editor
+8.3.2. Graphical TLD Editor
8.3.2.1. Tree view
8.3.2.2. Source view
+8.3.3. Graphical Web Application File (web.xml) Editor
8.3.3.1. Tree View
8.3.3.2. Source View
8.3.3.3. Content Assist
8.3.3.4. Errors Checking and Validation
+8.3.4. Graphical Tiles Files Editor
8.3.4.1. Graphical Editor For Tiles Files
8.3.4.2. Create New Tiles File
8.3.4.3. Tree View
8.3.4.4. Diagram View
8.3.4.5. Source
8.3.5. Graphical Editor for Struts Validation Files
8.3.6. Spring IDE
8.3.7. CSS Editor
8.3.8. JavaScript Editor
8.3.9. XSD Editor
8.3.10. Support for XML Schema
+9. JBoss Tools Preferences
9.1. CodeAssist
9.2. Editors
9.3. JBoss Servers
9.4. JSF
9.5. JSF Flow Diagram
9.6. JSF Page
9.7. JSF Propject
9.8. Packaging Archives
9.9. Plug-in Insets
9.10. Resource Insets
9.11. Seam
9.12. Seam Validator
9.13. Struts
9.14. Struts Automatic
9.15. Struts Customization
9.16. Struts Flow Diagram
9.17. Struts Pages
9.18. Struts Project
9.19. Struts Support
9.20. Title Diagram
9.21. Verification
9.22. View
9.23. Visual Page Editor
9.24. XDoclet
9.25. XDoclet Templates
9.26. XDoclets Variables
9.27. Changing Default Environment During Project Creation
9.28. Changing Default Project Template During Project Creation

Chapter 1. Visual Web Tools

In JBoss Tools there is an extensive collection of specialized wizards, editors and views that can be used in various scenerios. The following chapters walksthrough these features.

Chapter 2. Key Features of Visual Web Tools

Here is the table of main features of Visual Web Tools:

Table 2.1. Key Functionality for Visual Web Tools

FeatureBenefitChapter
Visual Page EditorPowerful and customizable visual page editor. Possibility to develop an application using any web technology: jsf, seam, struts, jsp, html and others. Developing using four tabs: visual/source, visual, source and preview.Fast and easy switching between these tabs. Split screen design of visual and source views. Full and instant synchronization between source and visual views. Integration with properties and outline views. Graphical toolbar to add inline styling to any tag.visual page editor
JBoss Tools PaletteOrganizing various tags by groups, inserting tags into a jsp or xhtml page with one click, adding custom or 3rd party tag libraries into the palette, easy controling the number of tag groups shown on the palette.jboss tools palette
Web Projects ViewVisualizing and displaying projects by function. Easy selecting of different kinds of items and dropping them into jsp pages. Using context menus to develop the application. Using icon shortcuts to create and import JSF and Struts projects. Expanding and inspecting tag library files. Selecting custom and third-party tag libraries to drag and drop onto the JBoss Tools Palette.web projects view
JSF and Facelets supportStep-by-step wizards for creating new JSF and Facelets projects with a number of predefined templates, importing existing ones and adding JSF capabilities to non-jsf web projects.jsf support
Flexible and customizable project template managementJump-start development with out-of-the-box templates or easily customized templates for re-use.working with projects
Support for Managed BeansAdding new managed beans, generating code for attributes, properties and getter/setter methods.managed beans
OpenOnEasy navigation between views and other parts of your projects.facelets support
Content AssistCode completion proposals while working in java, xml, jsp, xhtml, xhtml, seam project and jsf configuration files. Content assist based on project data (dynamic code assist); with graphical editor. Code completion for values from property files, beans attributes and methods, navigation rule outcomes and jsf variables.content assist
Support for Custom Converters and ValidatorsFast creating of custom converters and validators with tree view of faces-config.xml file.converters and validators
Verification and ValidationAll occuring errors will be immediately reported by verification feature, no matter in what view you are working. Constant validation and errors checking allows to catch many of the errors during development process that significantly reduces development time.verification and validation
Drag-and-DropPossibility of inserting any tag onto the page you are editing by just drag-and-droping it from the palette to this page. Adding any properties, managed bean attributes, navigation rules, tag library file declarations, jsp files from web projects view by clicking them and draging to source code.visual page editor drag-and-drop
Struts SupportStep-by-step wizards for creating a new struts project with a number of predefined templates, importing existing ones and adding struts capabilities to non-struts web projects.struts support
Support for JSF and JSF Configuration FilesWorking on files using three modes: diagram, tree and source. Synchronization between the modes and full control over the code. Easy moving around the diagram using the Diagram Navigator. Working with struts projects that have multiple modules. Possibility to use Struts configuration file debugger allowing to set break points on struts diagram and then launch the server in debug mode.graphical editor for jsf graphical editor for struts
Rich Faces SupportTight integration between JBDS and RichFaces frameworks. Easy managing RichFaces components in any web application.rich faces support

Chapter 3. Java Server Faces Support

JBoss Developer Studio is especially designed for supporting JSF and JSF-related technologies. JBDS provides extensible and exemplary tools for building JSF-based applications as well as adding JSF capabilities to existing web projects, importing JSF projects (created outside JBDS) and choosing any JSF implementation while developing JSF application.

JBoss Developer Studio allows you to develop JSF applications much faster and with far fewer errors so sparing your time.

3.1. Support for JSF Environments: JSF-RI, MyFaces, Facelets or any Custom

With JBoss Developer Studio, we don't lock you into any one JavaServer Faces implementation. Select the one you want to use for your project.

When you:

  • Create a new JSF project

  • Add JSF capability to any existing Eclipse project

  • Add JSF capability to any existing project (created outside JBDS)

You can always select which JSF implementation to use.

You can also create your own custom JSF environments.

Choosing JSF Environment

Figure 3.1. Choosing JSF Environment


JBoss Developer Studio will add all the required libraries for the selected version to your project.

3.2. Facelets Support

Facelets extends JavaServer Faces by providing a lightweight framework that radically simplifies the design of presentation pages for JSF. JBoss Developer Studio provides support for Facelets in a variety of ways.

The Create New JSF Project wizard contains templates for creating Faceletsprojects based on version 1.2 of the JSF Reference Implementation:

Choosing Facelets Environment

Figure 3.2. Choosing Facelets Environment


Once you select the environment, you can select one of the six available templates:

Choosing Facelets Template

Figure 3.3. Choosing Facelets Template


The JBoss Tools Palette comes with the Facelets components ready to use. A useful tip appears when you hover the mouse cursor over the tag:

Facelets Components

Figure 3.4. Facelets Components


Code assist for Facelets tags is available when editing xhtml files:

XHTML File Code Assist

Figure 3.5. XHTML File Code Assist


  • In any HTML tag you also get the code assist for "jsfc" attribute

Code Assist for Jsfc Attribute

Figure 3.6. Code Assist for Jsfc Attribute


  • Then you get the code assist for JSF components are available on the page

Code Assist for JSF Components

Figure 3.7. Code Assist for JSF Components


  • Then you will see all available attributes for the component.

Figure 3.8. 


Using JBoss Developer Studio OpenOn feature, you can easily navigate between the Facelets templates and other parts of your projects. Just by holding down the Control key while hovering the mouse cursor over a reference to a template, the reference becomes a hyperlink to open that template.

Template Hyperlink

Figure 3.9. Template Hyperlink


3.3. Working with Projects

3.3.1. Creating a New JSF Project

JBoss Developer Studio provides the following when working with JSF:

  • Create new JSF projects

  • Import (open) existing JSF projects

  • Add JSF capability to any existing Eclipse project

  • Import and add JSF capability to any existing project created outside Eclipse

JBoss Developer Studio allows you to create brand new JSF projects . A new JSF project will have all JSF libraries, tag libraries and a JSF configuration file.

JBoss Developer Studio comes with a number of predefined project templates. These templates are flexible and easily customizable.

To create a brand new JSF project, select File > New > Project > JBoos Tools Web > JSF > JSF Project and click Next :

Choosing a JSF Project

Figure 3.10. Choosing a JSF Project


On this form enter Project Name. You can also select where to create the project.

JSF Version allows you to select which JSF implementation to use:

Creating a New JSF Project

Figure 3.11. Creating a New JSF Project


You can also pick a different template on which to base the project. Almost all templates come in two variations: with jsf libraries and without ones. Some servers already provide jsf libs and you take risk of getting conflicting libraries while deploying your project. So the idea here is to avoid such conflicts. Select a template without libs if you use a server with its own jsf libraries.

JSF Templates

Figure 3.12. JSF Templates


The JSFBlank template will create a standard Web project structure with all JSF capabilities.

The JSFKickStart template will create the same standard structure but will also include a sample application that is ready to run.

Choosing JSF Template

Figure 3.13. Choosing JSF Template


On the next screen select what Servlet version to use and whether to register this application with JBoss AS (or other server) for running and testing of your application.

Context Path is the name under which the application will be deployed.

The Runtime value tells Eclipse where to find Web libraries in order to build (compile) the project. It is not possible to finish project creation without selecting Runtime. If you don't have any values, select New... to add new Runtime.

Target Server allows you specify whether to deploy the application. The Target Server corresponds to the Runtime value selected above.

If you don't want to deploy the application, uncheck this value:

Registering the Project on Server

Figure 3.14. Registering the Project on Server


When you are all done, you should have the project that has been created in the Package Explorer view:

A New Project in the Package Explorer

Figure 3.15. A New Project in the Package Explorer


At this point you can open faces-config.xml and start working on your application.

3.3.2. Importing Existing JSF Projects with Any Structure

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

3.3.3. Adding JSF Capability to Any Existing Eclipse Project

With JBoss Developer Studio you can add JSF capability (JSF libraries, tag libraries) to any existing Eclipse project in your workspace.

By adding JSF capability to your project, you can now edit any file using JBoss Developer Studio editors, such as JSF configuration editor, JBoss Tools JSP editor and any others.

Right click the project and select JBoss Tools > Add JSF Capabilities . This will start the process of adding all necessary libraries, files to make this a Web JSF project:

Adding JSF Capabilities

Figure 3.16. Adding JSF Capabilities


The wizard will first show you the web.xml file location and the project name:

Project Location

Figure 3.17. Project Location


On the last form you can set the different folders for your project as well as register this application with a servlet container.

Make sure to select Add JSF Libraries for JBoss Developer Studio to add all required JSF related libraries to this project.

Context Path is the name under which the application will be deployed.

The Runtime value tells Eclipse where to find Web libraries in order to build (compile) the project. It is not possible to finish project import without selecting Runtime. If you don't have any values, select New... to add new Runtime.

Target Server allows you specify whether to deploy the application. The Target Server corresponds to the Runtime value selected above.

If you don't want to deploy the application, uncheck this value:

Project Folders

Figure 3.18. Project Folders


Once your project is imported you can see that JSF related libraries have been added to your project jsf-api.jar and jsf-impl.jar.

You are now ready to work with JSF by creating a new JSF configuration file:

Creating a New JSF Configuration File

Figure 3.19. Creating a New JSF Configuration File


3.3.4. Adding Your Own Project Templates

JBoss Developer Studio has a powerful templating capability for creating new and importing existing Struts and JSF projects. This templating facility has a variety of aspects to consider. But, let's start with the most straightforward case.

Let's say you have a project that you want to use as the basis for a new template. Follow these steps to make a template out of it:

  • In the Web Projects view, right-click the project and select JBoss Tools JSF > Save As Template as template

Saving Your Project as Template

Figure 3.20. Saving Your Project as Template


  • In the first dialog box, you can choose a name for the template (defaults to the project name) and confirm what run-time implementation of the project's technology will be used

  • Select Next and you will be sent to a dialog box with your project structure displayed with check boxes. Here you can check only those parts and files in your project directory that should be part of the template

  • At this point, unless you want to designate some extra files as having Velocity template coding inside them, you should select Finish

That's it. Now, you can use this template with any new or imported project that uses the same run-time implementation as the project you turned into a template.

3.4. Graphical Editor and Viewing for JSF Configuration Files

The JSF configuration file editor has three main viewers (modes):

  • Diagram

  • Tree

  • Source

The modes can be selected via the tabs at the bottom of the editor.

The JSF configuration editor also comes with a very useful OpenOn selection feature.

3.4.1. Diagram

The Diagram view displays the navigation rules in the JSF configuration file:

Diagram View

Figure 3.21. Diagram View


3.4.2. Creating New View (Page)

To create a new page (view), you can click the page icon on this toolbar and then click anywhere on the diagram. A New Page Wizard will appear.

To create a transition (rule) connecting pages:

  • Select the transition icon from the toolbar (2nd from the bottom).

  • Click the source page.

  • Click the target page.

A transition will appear between the two pages:

Transition Between JSP Pages

Figure 3.22. Transition Between JSP Pages


It is also possible to create a new page by right-clicking anywhere on the diagram and selecting New View .

Creating a New View

Figure 3.23. Creating a New View


To edit an existing transition, first select the transition line. Then, place the mouse cursor over the last black dot (on the target page). The mouse cursor will change to a big +. At this point, drag the line to a new target page:

Editing Transition Between Views

Figure 3.24. Editing Transition Between Views


3.4.3. Tree View

The Tree mode for the editor displays all JSF application artifacts referenced in the configuration file in a tree format. Select any node and its properties will appear in the right-hand area:

Tree View

Figure 3.25. Tree View


To edit, right-click any node and select one of the available actions in the context menu. You can also edit in the properties window to the right:

Editing in Tree View

Figure 3.26. Editing in Tree View


3.4.4. Source View

The Source mode for the editor displays a text view of the JSF configuration file. All three viewers are always synchronized, so any changes made in one of the viewers will immediately appear in the others:

Source View

Figure 3.27. Source View


3.4.5. Content Assist

Content assist is always available in the Source viewer:

Content Assist in Source View

Figure 3.28. Content Assist in Source View


3.4.6. Error Reporting

Errors will be reported by JBoss Developer Studio's verification facility:

Error Reporting in Source View

Figure 3.29. Error Reporting in Source View


Other errors are also reported.

Others Errors Reporting

Figure 3.30. Others Errors Reporting


You can also work in the Source viewer with the help of the Outline view . The Outline views show a tree structure of the JSF configuration file. Simply select any element in the Outline view, and it will jump to the same place in the Source viewer.

Outline View

Figure 3.31. Outline View


If your diagram is large, within Outline view you can switch to a Diagram Navigator mode by selecting the middle icon at the top of the view window. It allows you to easily move around the diagram. Just move the blue area in any direction, and the diagram on the left will also move:

Outline View for Diagram

Figure 3.32. Outline View for Diagram


You can also edit in the Tree viewer with the help of the Properties view as shown below:

Properties View

Figure 3.33. Properties View


3.5. Managed Beans

3.5.1. Code Generation for Managed Beans

JBoss Developer Studio gives you lots of power to work with managed beans.

  • Add and generate code for new managed beans

    • Generate code for attributes and getter/setter methods

  • Add existing managed beans to JSF configuration file

To start, create a new managed bean in JSF configuration file editor, in the Tree view.

Creation of New Managed Bean

Figure 3.34. Creation of New Managed Bean


When you define a new managed bean, make sure that Generate Source Code is checked as shown in the figure below:

New Managed Bean

Figure 3.35. New Managed Bean


After the "Java" class has been generated you can open it for additional editing. There are two ways to open the "Java" class:

  • Click on Managed-Bean-Class link in the editor -or-

  • Right click the managed bean and select Open Source

Opening of Created Managed Bean

Figure 3.36. Opening of Created Managed Bean


The generated Java source:

Java Source Code

Figure 3.37. Java Source Code


You can also generate source code for properties - this also includes "getter" and "setter" methods:

Generation of Source Code for Properties

Figure 3.38. Generation of Source Code for Properties


Make sure that all the check boxes are selected:

  • Add Java property
  • Generate Getter
  • Generate Setter

"Add Property" Form

Figure 3.39. "Add Property" Form


Once the generation is complete, you can open the file and see the added property with "getter" and "setter" methods:

Generated Java Source Code for Property

Figure 3.40. Generated Java Source Code for Property


3.5.2. Add Existing Java Beans to a JSF Configuration File

If you already have a Java bean you can easily add it to a JSF configuration file.

You should start the same way you create a new managed bean. Use Browse... to add your existing Java class.

New Managed Bean Form

Figure 3.41. New Managed Bean Form


Once the class is set, it's Name will be set as well. But you can easily substitute it for the other one. Notice that Generate Source Code option is not available as the "Java" class already exists.

After adding your class Next button will be activated. Pressing it you'll get Managed Properties dialog where all corresponding properties are displayed. Check the necessary ones to add them into your JSF Configuration File.

If you don't want to add any, just click Finish .

Selection of Bean's Properties.

Figure 3.42. Selection of Bean's Properties.


3.6. Create and Register a Custom Converter

  1. In the Project Explorer view open faces-config.xml and select Tree tab.

Converters

Figure 3.43. Converters


  1. Select Converters and click on Add button.

  2. Type the name of your converter in the Converter-id field and name of the class for converters. After clicking Finish button your custom converter is registered under entered name.

Add Converter Form

Figure 3.44. Add Converter Form


  1. Let's create "converter" class. In the Converter section you should see your Converter-id and Converter-class. Click on Converter-class to generate the source code.

Generation of Source Code for Converter Class

Figure 3.45. Generation of Source Code for Converter Class


  1. Java class will be created automatically. Leave everything without changes and click Finish .

New Java Class Form

Figure 3.46. New Java Class Form


  1. To open converter class click again on Converter-class link in the Converter section. Now you are able to write business logic of converter.

Converter Class

Figure 3.47. Converter Class


3.7. Create and Register a Custom Validator

  1. In the Project Explorer view open faces-config.xml and select Tree tab.

Validator in Faces Config Editor

Figure 3.48. Validator in Faces Config Editor


  1. Select Validators , and click on Add button.

  2. Type the name of your validator in the Valifator-id field an d name of the class for validators. After clicking Finish button your custom validator is registered under entered name.

Adding Validator

Figure 3.49. Adding Validator


  1. Let's create "validator" class. In the Validator section you should see your Validator-id and Validator-class. Click on Validator-class to generate the source code.

Creating Validator Class

Figure 3.50. Creating Validator Class


  1. Java class will be created automatically. Leave everything without changes and click Finish .

New Java Class Form

Figure 3.51. New Java Class Form


  1. To open validator class click again on Validator-class in the Validator section. Now you are able to write business logic of validator.

Converter Class Editing

Figure 3.52. Converter Class Editing


3.8. Create and Register Referenced Beans

  1. In the Project Explorer view open faces-config.xml and select Tree tab.

Validator in Faces Config Editor

Figure 3.53. Validator in Faces Config Editor


  1. Select Referenced Beans and click on Add button.

  2. Type in the name of your Referenced Bean and type in or select Referenced-Bean-Class by using Browse button.

Add Validator Form

Figure 3.54. Add Validator Form


  1. In the Referenced Bean section you should see your Referenced-Bean-Name and Referenced-Bean-Class. Click on the link to open the Java creation wizard.

Create Validator Class

Figure 3.55. Create Validator Class


  1. Java class will be created automatically. Leave everything without changes and click Finish .

New Java Class Form

Figure 3.56. New Java Class Form


  1. To open Referenced Bean class click again on Referenced-Bean-Class in the Referenced Bean section. Now you are able to write business logic of Referenced Bean.

Referenced Bean Class Editing

Figure 3.57. Referenced Bean Class Editing


Chapter 4. Struts

If you prefer develop web applications using Struts technology JBoss Developer Studio also meets your needs.

JBDS supports the Struts 1.1, 1.2.x versions.

4.1. Support for Struts 1.1, 1.2.x

When you create a brand new or import an existing project you can set which Struts version to use:

Choosing Struts Environment

Figure 4.1. Choosing Struts Environment


4.2. Working with Projects

4.2.1. Creating a New Struts Project

JBoss Developer Studio provides the following when working with Struts.

  • Create new Struts projects

  • Import (open) existing Struts projects

    You can import any project structure

  • Add Struts capabilities to any existing Eclipse project

  • Import and add Struts capabilities to any existing project created outside Eclipse

JBoss Developer Studio includes a New Struts Project Wizard that radically simplifies the process for getting started with a new Struts project. You just need to follow these 4 steps:

  1. Select File > New > Project... from the menu bar. Then, select JBoss Tools Web > Struts > Struts Project in this dialog box. Click Next:

Selecting Struts Wizard

Figure 4.2. Selecting Struts Wizard


  1. On this screen, provide the project name. You can leave all other values as they are:

Creating Struts Project

Figure 4.3. Creating Struts Project


Tip:

Don't put spaces in project names.

Note:

If you select the KickStart template, then the project created will include a simple Hello World type application that is ready-to-run.

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

Registering The Project at Server

Figure 4.4. Registering The Project at Server


  1. On the next screen, you can select the TLD files to include in this project:

Selecting Tag Libraries

Figure 4.5. Selecting Tag Libraries


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

Project Structure

Figure 4.6. Project Structure


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 OK.

4.2.2. Importing an Existing Struts Project with Any Structure

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

4.2.3. Adding Struts Capability to an Existing Web Application

With JBoss Developer Studio you can add Struts capabilities (including 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 Developer Studio editors, such as the Struts configuration editor and the JBoss Tools JSP editor.

Right-click the project and select JBoss Tools > Add Struts Capabilities from the context menu. This will start the process of adding all necessary libraries and files to make this a Web JSF project.

Adding Struts Capabilities

Figure 4.7. Adding Struts Capabilities


The wizard will first show you the web.xml file location and the project name.

Choosing Project Location

Figure 4.8. Choosing Project Location


After hitting Next, you will see the following screen. This screen simply means 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, select the Add Struts Support button.

Project Modules

Figure 4.9. Project Modules


Here you can select what Struts version, Servlet class, URL pattern and TLDs to add to this project.

Selecting Struts Support Options

Figure 4.10. Selecting Struts Support Options


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

Project Configuration Information

Figure 4.11. Project Configuration Information


On the last screen you can set the different folders for your project as well as register this application with a servlet container.

Registering the Project at Server

Figure 4.12. Registering the Project at Server


When done, you can open the struts-config.xml file. (The Struts configuration is shown below in the Tree viewer).

Struts-config.xml File

Figure 4.13. Struts-config.xml File


4.3. Graphical Editor for Struts Configuration Files

The Struts configuration file editor has three main viewers (modes): Diagram (shown), Tree and Source. The modes can be selected via the tabs at the bottom of the editor. Any changes made in one mode are immediately visible when you switch to any other mode.

When working in Source view, you always have all the following features available:

  • Content Assist

  • Open On Selection

  • File Folding

4.3.1. Diagram Mode

The Diagram mode graphically displays the Web flow of the application defined in the Struts configuration file.

Diagram Mode

Figure 4.14. Diagram Mode


Just by right-clicking anywhere on the diagram, you can use a context menu to create the building blocks of a Struts application:

  • Actions

  • Global forwards

  • Global exceptions

  • JSP Pages

Diagram Context Menu

Figure 4.15. Diagram Context Menu


Along the upper-left side of the editor is a stack of seven icons for changing the behavior of the cursor in the diagram. The first icon switches to the default regular selection cursor, the second to the marquee selection cursor and the third to the new connection cursor. The last four icons switch the cursor to an insert cursor for each type of Struts build block listed above (and in the order listed).

For instance, clicking on the first of these four icons (the one with the gears) will switch the cursor to insert actions. Clicking anywhere in the diagram with this cursor has the same effect as right-click and selecting Add > Action... from the context menu with the regular cursor active. It's just more efficient to use this cursor if you're adding more than one action at once.

Insert Actions Cursor

Figure 4.16. Insert Actions Cursor


4.3.2. Tree Mode

In the Tree mode, the different elements of the Struts application are organized into functional categories on the left-hand side and a form for editing the properties of currently selected items on the right-hand side.

Tree Mode

Figure 4.17. Tree Mode


You can also right-click on any node in the category tree and perform appropriate operations through a context menu. For instance, by right-clicking on the action-mappings category node, you can add new actions to the application.

Tree Context Menu

Figure 4.18. Tree Context Menu


4.3.3. Source Mode

In the Source mode, you have complete editing control of the underlying XML coding:

Source Mode

Figure 4.19. Source Mode


You can take advantage of code assist:

Code Assist

Figure 4.20. Code Assist


The editor will also immediately flag any errors:

Errors in Source Mode

Figure 4.21. Errors in Source Mode


Finally, you can use the Outline view with the editor to easily navigate through the file:

Outline View

Figure 4.22. Outline View


4.4. Graphical Editor for Tiles Files

The Tiles configuration file editor has three main viewers (modes): Tree (shown), Diagram and Source. The modes can be selected via the tabs at the bottom of the editor. Any changes made in one mode are immediately visible when you switch to any other mode.

When working in Source view, you always have all following features available:

  • Content Assist

  • Open On Selection

4.4.1. Create New Tiles File

To create a new Tiles files, right click any folder and select New > Tiles File.

Creating a New Tiles File

Figure 4.23. Creating a New Tiles File


4.4.2. Tree View

In the Tree mode, the different elements of the Tiles file are organized into functional categories on the left-hand side and a form for editing the properties of currently selected items on the right-hand side.

Tree View

Figure 4.24. Tree View


To edit the file, simply right click any node and select among the available actions:

Editing in Tiles Editor

Figure 4.25. Editing in Tiles Editor


4.4.3. Diagram View

The Diagram mode is shown below:

Diagram Mode

Figure 4.26. Diagram Mode


To create new definitions, simply right click anywhere in the diagram:

Creating New Definition

Figure 4.27. Creating New Definition


You can also use the Diagram toolbar to make editing easier:

Diagram Toolbar

Figure 4.28. Diagram Toolbar


4.4.4. Source

The Tiles editor also comes with a Source view that gives you full control over the source. Any changes here will immediately appear in other viewers when you switch to them.

Source View

Figure 4.29. Source View


Content assist is available in the Source mode:

Content Assist in Source Mode

Figure 4.30. Content Assist in Source Mode


Any errors are immediately reported as shown below:

Errors Reporting

Figure 4.31. Errors Reporting


You can also use the Outline view together with the editor's Source mode. Selecting any node in the Outline view will jump to that place in the source.

Outline View

Figure 4.32. Outline View


4.5. Graphical Editor for Struts Validation Files

JBoss Developer Studio comes with a visual validation editor. To create a new validation file, right click any folder and select File > Validation File from the context menu.

Creating New Validation File

Figure 4.33. Creating New Validation File


The validation editor works through a number of viewers.

The Formsets viewer shows forms and their elements for which to define validation rules.

Formsets Viewer

Figure 4.34. Formsets Viewer


The Constants viewer lets you set constant values for your validation rules.

Constansts Viewer

Figure 4.35. Constansts Viewer


The validation file also can be viewed in a Tree viewer.

Tree Viewer

Figure 4.36. Tree Viewer


At any point you have full control over the source by switching to the Source viewer. Any editing in this viewer will immediately be available in other viewers of this editor.

Source Viewer

Figure 4.37. Source Viewer


You can also open your own custom or Struts-standard validation-rules.xml file.

The Validators viewer shows the validation rules for a selected validator. You can of course add your own rules.

Validators Viewer

Figure 4.38. Validators Viewer


Here are the validation rules shown in the Source viewer.

Validation Rules

Figure 4.39. Validation Rules


4.6. Support for Multiple Struts Modules

4.6.1. Struts Modules

JBoss Developer Studio supports working with Struts projects that have multiple modules. You can easily do the following:

  • Add new modules

  • Edit modules for an existing project or during Struts project import

4.6.2. When Importing a Struts Project

During Struts project import, if the project has multiple modules, you will see a screen with all existing modules. You can select each module and edit its details.

Configuring Project Modules

Figure 4.40. Configuring Project Modules


4.6.3. Editing Modules in an Existing Project

To edit modules in an existing project, right click the project and select JBoss Tools > Modules Configuration.

Choosing Modules Configuration

Figure 4.41. Choosing Modules Configuration


You will see the same screen as above where you will be able to select a module and edit its details:

Modules Configuration

Figure 4.42. Modules Configuration


4.6.4. Adding New Modules

Adding a new module is very simple. First switch to Web Project view. Expand your project to the Configuration folder. Under that folder you should see the current modules. Right click on Configuration and select New > Struts Config.

Adding New Modules

Figure 4.43. Adding New Modules


You will see the screen below. You can specify a new module name and also add the new Struts configuration file to web.xml file.

Adding New Modules

Figure 4.44. Adding New Modules


4.7. Code Generation for Action, FormBean, Forward and Exception Classes

JBoss Developer Studio comes with a code generation feature. You can generate stub code for Struts Actions, FormBeans, Forwards and Exceptions.

The code generation in JBoss Developer Studio is based on Velocity templates which can be modified for your use. The templates are located at {RedHatDeveloperStudioHome} > templates > codegeneration .

There are a number of ways to invoke code generation. One is simply right-clicking the Struts diagram and selecting Generate Java Code....

Selecting Generate Java Code

Figure 4.45. Selecting Generate Java Code


On this screen you can select for which elements to generate code. If you select Next you will be able to specify more options for each of the categories you selected.

Generate - Step 1

Figure 4.46. Generate - Step 1


Tip:

please be careful not to override your existing files.

When generation is complete, a result window will appear letting you know how many classes were generated:

Generation Finished

Figure 4.47. Generation Finished


You don't always have to generate code for all elements at once. You can invoke generation for just an individual Struts artifact as well. Right-click an element on the diagram of the Struts configuration file and select Generate Java Code... from the context menu.

Generation For Individual Struts Artifact

Figure 4.48. Generation For Individual Struts Artifact


The same can be done from within the Tree viewer for the editor of the Struts configuration file.

Generation in Struts Config Editor

Figure 4.49. Generation in Struts Config Editor


4.8. Struts Configuration File Debugger

JBoss Developer Studio comes with Struts configuration file debugger. It allows you to set break points on Struts diagram and then simply launch the server in debug mode.

Simply right click an Action or a page and select Add Breakpoint.

Adding Breakpoint

Figure 4.50. Adding Breakpoint


4.9. Customizable Page Links Recognizer

Custom page links allow you to define custom Struts page links that will be recognizable in the Struts application diagram. You can define these links by selecting Window > Preferences from the menu bar and then selecting JBoss Tools > Web > Struts > Customization from the Preferences dialog box.

Customization Panel

Figure 4.51. Customization Panel


Chapter 5. JBoss Tools Palette

The JBoss Tools Palette allows you to:

  • Insert tags into a JSP page with one click

  • Add custom and 3rd party tags.

The JBoss Tools Palette provides possibility to add any tag libraries to it. Or you can choose a necessary one from the list of already existent tag libraries:

  • HTML

  • JBoss

  • JSF

  • JSTL

  • MyFaces

  • Oracle ADF Faces

  • Struts

  • XHTML

Pallete Editor

Figure 5.1. Pallete Editor


5.1. Using the Palette

5.1.1. JBoss Tools Palette

In the Palette Editor window(Figure 5.1. "Palette Editor") we can see that every group contains its own subgroups. For example, JSF includes Core, Facelets, HTML. So, in the Palette every group has the next view: <Group name> <Subgroup name>.

JBoss Tools Palette

Figure 5.2. JBoss Tools Palette


By default the Palette is represented in Web Development Perspective with four groups(Figure 5.2. "JBoss Tools Palette"). If you can't see it, select Window > Show View Other... > JBoos Tools Web > JBoss Tools Palette from the menu bar.

By using Show/Hide button you can add any predefined group of tag libraries. It's also possible to create your own group.

5.1.2. Inserting Tags into a JSP File

A new tag can be added into any text file including jsp, xhtml и htm(l).

It's very simple to do this. Place the cursor in the JSP page where you want to add a tag and then click the tag in the palette. In the example below, the commandButton tag has been inserted. Notice also that if you place the