Creating Struts portlet projects

Depending on whether you prefer to create Struts portlet resources based on the IBM® portlet API or the JSR 168 portlet API, you must choose the appropriate wizard to create the Struts portlet project.

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 a Struts portlet configuration file and the necessary updates to the web.xml file, the portlet.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 > Portlet Project from the menu bar to create a portlet project that contains an IBM API portlet. Select File > New > Portlet Project (JSR 168) from the menu bar to create a portlet project that contains a JSR 168 API portlet. The wizard for the appropriate portlet project type will open.
  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.
    WebSphere® Portal version
    Select the appropriate WebSphere Portal version for your portlet project. Your selection will set the appropriate servlet and corresponding target server for your development environment.
    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.
    Note: By selecting a WebSphere Portal version value above, both Servlet version and Target server are set to the appropriate values. Editing these two fields is not recommended.
    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.
    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.
    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.
    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

(C) Copyright IBM Corporation 2002, 2005. All Rights Reserved.