Chapter 6. Web Projects View

Web Projects is a special view that comes with JBoss Developer Studio.

If the Web Projects view's tab is not visible next to the Package Explorer tab, select Window > Show View > Web Projects from the menu bar.

6.1. Web Projects View

With the Web Projects view, you can:

  • Visualize the project better because the project artifacts for JSF and Struts projects are organized and displayed by function.

  • Select these kinds of items to drag and drop into JSP pages:
    • JSF managed bean attributes

    • JSF navigation rules outcomes

    • Property file values

    • Tag library files

    • Tags from tag libraries

    • JSP page links

  • Use context menus to develop the application (all create and edit functions are available)

  • Use icon shortcuts to create and import JSF and Struts projects

  • Expand and inspect tag library files

  • Select custom and third-party tag libraries to drag and drop onto the JBoss Tools Palette

6.2. Project Organization

The Web Projects view organizes your project in a different way. The physical structure of course stays the same. The new organization combines common project artifacts together which makes it simpler to locate what you are looking for and develop.

The screen shot below shows a JSF project and a Struts project in Web Projects view.

Web Projects View

Figure 6.1. Web Projects View


6.3. Drag and Drop

6.3.1. For a Property

Expand the Resources Bundles folder that holds all the Property files in your project. Select the file from which you want to add the property and then select the property.

We will be dragging and dropping a property file value inside the outputText tag for the "value" attribute.

OutputText Tag

Figure 6.2. OutputText Tag


Select the property:

Selecting Property

Figure 6.3. Selecting Property


Drag the property and drop it between the quotes for the value attribute in the JSP file. Notice that JBoss Developer Studio added the correctly formatted expression for referring to the property value: #{Message.header} automatically.

Inserted Property

Figure 6.4. Inserted Property


You can actually place the tag anywhere in the page, not just inside an existing tag. In this case, JBoss Developer Studio will place the complete tag <h:outputText value="#{Message.header}"/> in the page.

6.3.2. For Managed Bean Attributes

Select a "managed bean" attribute and then drag and drop it onto the JSP page. We are going to place it inside the "value" attribute of the inputText tag.

Selecting Managed Bean Attrubute

Figure 6.5. Selecting Managed Bean Attrubute


Once again, JBoss Developer Studio adds the correct expression, #{user.name}.

Added Expression

Figure 6.6. Added Expression


6.3.3. Navigation Rules

Select the navigation rule under Configuration > faces-config.xml > Navigation Rules:

Selecting Navigation Rule

Figure 6.7. Selecting Navigation Rule


Drag and drop it inside the commandButton tag:

Naviagation Rule in CommandButton Tag

Figure 6.8. Naviagation Rule in CommandButton Tag


You could do the same if the navigation rule was defined inside an action method:

Navigation Rule in Action Method

Figure 6.9. Navigation Rule in Action Method


Here is how it would look after drag and drop:

Inserted Navigation Rule

Figure 6.10. Inserted Navigation Rule


6.3.4. For a Tag Library File Declaration

Select a TLD file:

Selecting TLD File

Figure 6.11. Selecting TLD File


Then drag and drop it onto the JSP page to add a declaration at the top of the page:

Inserted TLD File

Figure 6.12. Inserted TLD File


6.3.5. For JSP Pages

You can also drag and drop a JSP page path to a JSP page to create a forward as shown:

Creating JSP Forward

Figure 6.13. Creating JSP Forward


6.4. Developing the Application

It is also possible to develop your application right from the Web Projects view. Simply right-click any node in the tree and select an appropriate action from the context menu. For instance, this screen capture shows creating a new navigation rule.

Creating New Navigation Rule

Figure 6.14. Creating New Navigation Rule


6.5. Expanding Tag Library Files

You can easily expand any TLD file in the project. Browse to the Tag Libraries folder. Right-click a TLD file and select Expand. The TLD file will now be expanded.

You can then select any tag and drag it onto a JSP page.

Expanding Tag Library File

Figure 6.15. Expanding Tag Library File


6.6. Drag and Drop Tag Libraries on to JBoss Tools Palette

Read Adding Tag Libraries to learn about this.

6.7. Create and Import JSF and Struts Projects

You can also create and import JSF and Struts project from Web Projects view by selecting the buttons below.

From left to right:

  1. Create New JSF Project

  2. Import JSF Project

  3. Create New Struts Project

  4. Import Struts Project

Web Projects View Buttons

Figure 6.16. Web Projects View Buttons