JBoss.orgCommunity Documentation

Chapter 5. Code Generation

JBoss Tools comes with a code generation feature which can be used to generate stub code for Struts Actions, FormBeans, Forwards and Exceptions.

The code generation that JBoss tooling provides is based on Velocity templates which can be modified for your use. The templates are located at {JBossStudioHome}templatescodegeneration.

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

Selecting Generate Java Code

Figure 5.1. Selecting Generate Java Code


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

Generate - Step 1

Figure 5.2. 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 5.3. Generation Finished


You don't always have to generate code for all elements at once. You can generate code for 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 5.4. 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 5.5. Generation in Struts Config Editor