Creating Struts portlet projects

Struts portlet projects are created using the New Portlet Project wizard. A default Struts-enabled portlet and, optionally, a Web diagram file, will be added in the process of creating the project. The wizard automatically generates Struts portlet configuration files and the necessary updates to the web.xml file, and adds all of the SPF tag libraries and JAR files to the project, in the directory structure that is required.

To create a Struts portlet project:

  1. Select File > New > Project. Then, select the Portlet Project option on the right, and then click the Next button. The New Portlet Project wizard opens.

  2. Provide values, as appropriate, for the following fields:

    Project name

    Name for the new portlet project.

    Project location

    The location in the file system where the project will be created. You can change the file system location by using Browse.

    Create a portlet

    If you do not want to create the initial portlet definitions in the project, clear this check box. Typically, you do not need to create a portlet when you import a portlet WAR file into the project.

    To set the project's J2EE settings, or to specify the target run-time server for the project, click the Show Advanced >> button, and supply any of the following values:

    Add module to an EAR project

    Deselect this check box only if you do not intend to deploy the portlet. It is recommended that you leave this selected, or you will be unable to deploy the portlet.

    Servlet version

    Specifies the version of the Servlet and JSP specifications to be included in your portlet application. Version 2.3, the default, includes a Servlet Specification level of 2.3 and a JSP Specification level of 1.2. This default should be used to create portlet projects targeted for WebSphere Portal 5.0 or 5.1 servers.

    Note that the servlet version will determine the choice of target servers that appear in the drop-down list.

    Target server

    Select the version of WebSphere Portal that your portlet application will be installed to (either WebSphere Portal v5.0 or v5.1).

    Note: Ensure that you do not accidentally select one of the WebSphere Application Server options.

    EAR project

    Name of an enterprise application project (EAR project) that the portlet project should be associated with for purposes of deployment. The information used to deploy the portlet project to WebSphere Portal in the test environment will be added in this project. All portlet applications associated with a single EAR project will run on a single session at the test environment. You may separate portlet applications into multiple EAR projects. You should use the same EAR project for other projects that are related.

    Context root

    A context root for the portlet project. It is used as the top-level directory of your portlet application when it is deployed to WebSphere Portal in the test environment. It must not be same as the ones used by other projects.

    Add support for annotated Java classes

    Ensure that this check box is selected if you plan on using model annotations to generate code in your project.

  3. Click Next.

  4. Click the Struts portlet radio button. If you want accept the defaults associated with a Struts-enabled portlet project, click Finish. If you prefer to customize the project options, click Next.

  5. Web Diagram from the Web Project features list is selected by default. This will create a Web diagram (.gph) file for the project. A Web diagram file allows you to visually design the application flow of a Struts-based application or a Faces application. After you have designed the application by adding Web pages, actions, connections, and other application elements, you can realize the elements, and generate the files modeled by the Web diagram.

  6. To create a portlet project that uses the JSP Standard Tag Library tags, select JSP Standard Tag Library from the Web Project features list. For more information about how WebSphere Portal supports the use of tags from the JSP Standard Tag Library (JSTL), refer to "Using JSTL tags in the portal JSPs" in the WebSphere Portal Information Center.

  7. Click Next.

  8. Supply the appropriate general settings in the Portlet Settings page. Click Next.

  9. Update any Struts portlet-specific settings in the Struts Portlet Settings page. By default, the wizard will create resource bundles. The Java package name default is built using the project name that you specified.

  10. Click Next.

  11. In the Miscellaneous page, specify any additional markups and modes that you want to enable for the portlet in the project.

    1. Struts portlets always support html markup. You can add Compact HTML (chtml) or WML 1.3 (wml) markup support to the project. These markups are not currently supported by Rational Developer, but you can manually add the related tag libraries to use the tags available for the specified markups.

    2. Select the appropriate check boxes for any additional modes that you want to enable for the portlet. View mode is always provided by default.

  12. Click Finish. A new portlet project is created with a Struts portlet definition in web.xml and portlet.xml.

 

Related concepts

Struts portlet applications
Creating Struts portlets and projects
Struts-based Web applications - overview
Struts tools for application development
Web diagrams and the Web diagram editor

 

Related tasks

Creating Struts portlets
Creating Struts portlet JSP files
Creating well-architected Web applications using Struts
Creating Web diagrams for new applications

Related reference
Differences between Struts 1.1 and SPF tag library classes