September 3, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

JBoss Tools 3 Developer Guide

  • June 3, 2009
  • By Anghel Leonard
  • Send Email »
  • More Articles »

Creating a JSF Project Stub

In this section you will see how to create a JSF project stub with JSF Tools. This is a straightforward task that is based on the following steps:
  1. From the File menu, select New | Project option. In the New Project window, expand the JBoss Tools Web node and select the JSF Project option (as shown in Figure 3). After that, click the Next button.



    Click here for larger image

    Figure 3: Create a JSF Project

  2. In the next window, it is mandatory to specify a name for the new project (Project Name field), a location (Location field—only if you don't use the default path), a JSF implementation (JSF Environment field), and a template (Template field). As you can see, JSF Tools offers a set of predefined templates as follows:
    • JSFBlankWithLibs – This is a blank JSF project with complete JSF support.
    • JSFKickStartWithLibs – This is a demo JSF project with complete JSF support.
    • JSFKickStartWithoutLibs – This is a demo JSF project without JSF support. In this case, the JSF libraries are missing for avoiding the potential conflicts with the servers that already offer JSF support.
    • JSFBlankWithoutLibs – This is a blank JSF project without JSF support. In this case, the JSF libraries are missing for avoiding the potential conflicts with the servers that already offer JSF support (for example, JBoss AS includes JSF support).
    Figure 4 is an example of how to configure your JSF project at this step. At the end, just click the Next button:



    Click here for larger image

    Figure 4: Configure Your JSF Project

    This step allows you to set the servlet version (Servlet Version field), the runtime (Runtime field) used for building and compiling the application, and the server where the application will be deployed (Target Server field). Note that this server is in direct relationship with the selected runtime. Figure 5 shows an example of how to complete this step (click on the Finish button):



    Click here for larger image

    Figure 5: Set the Servlet Version, the Runtime, and the Server

After a few seconds, the new JSF project stub is created and ready to take shape! You can see the new project in the Package Explorer view.

JSF Project Verification

Before starting to develop a JSF application, you can take advantage of an important facility of JSF Tools: the ability to verify and report any dysfunction that may affect the application flow. This facility, known as the JSF Project Verification, will verify the application when it is saved and help you to easily identify errors. For this, you can follow these steps:
  1. From the Window main menu, select the Preferences option.
  2. In the Preferences window, expand the JBoss Tools | Web | Verification node from the left panel.
  3. Select the desired checkboxes and click on Apply and OK (it is recommended to select all of them).

JSF Application Configuration File

A very useful facility of JSF Tools is an editor especially designed for managing everything that is related to the JSF main configuration file (faces-config.xml). You can start this editor like this:
  1. Place the cursor in the Package Explorer view on your project node.
  2. Expand your JSF project node: registerJSF | WebContent| WEB-INF.
  3. Double-click on the faces-config.xml file.

When the editor is available, it will appear as in Figure 6.



Click here for larger image

Figure 6: JSF Tools Editor for Managing faces-config.xml

The Diagram View

From this view, you can easily manage pages and transitions between the application's pages (navigation rules). You can create, modify, or delete a page/transition in just a few seconds, and you will always have a clear image of the application flow, thanks to the graphical representation mode.

Creating Pages

As an example, let's create two pages named register.jsp and success.jsp. Usually, you would have had to edit these files by hand to describe the pages flow, but using Diagram view features, you can do it visually. For this, you have to apply the following steps:
  1. Right-click inside the Diagram view and select the New View... option from the contextual menu (see Figure 7):



    Click here for larger image

    Figure 7: The New View... Option from the Contextual Menu

    Another way to create a new page is selecting the View Template icon (fourth from the top) from the toolbar placed in the top-left corner of the Diagram view and, following that, clicking inside the Diagram view surface.

  2. The above step will open the New View window (as shown in Figure 8). In the From-View-ID field, enter the relative path and name of the new page. For example, you can type pages/register (without the .jsp extension). Leave everything else unchanged and click on the Finish button.



    Click here for larger image

    Figure 8: The New View Window

  3. Repeat step 2, but this time type pages/success in the From-View-ID field. Note that both pages are represented on the Diagram view surface as you can see in Figure 9. Also, they are present under the registerJSF/WebContent/pages directory in the Package Explorer view.



    Click here for larger image

    Figure 9: The Diagram View Surface

Adding Navigation Rules

Now, it is time to connect the two pages by creating a transition (navigation rule) from register.jsp to success.jsp. To do this, follow these steps:
  1. Select the Create New Connection icon (third from the top) from the toolbar placed in the top-left corner of the Diagram view. This will change the cursor into an arrow cursor with a two-pronged plug at the arrow's bottom.

  2. Click on register.jsp and after that click on success.jsp. You should see something resembling that shown in Figure 10:



    Click here for larger image

    Figure 10: Result of Clicking on register.jsp and then success.jsp

  3. Save the changes by selecting the Save option from the main File menu.





Page 3 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel