Tutorial – Creating a Web Application Project

 

+

Search Tips   |   Advanced Search

 

Overview

Use this tutorial to learn how to create a web application project.

After installing IBM WebSphere Portlet Factory, the first step in creating a portlet is to create a WPF project using WPF Designer. The project serves as the foundation for your portlet or application and contains all the artifacts required to build your portlet or application.

In this tutorial, you create a WPF project, configure it for use with a IBM WebSphere Portal environment, and run a sample to ensure that the setup is correct. After completing these tasks, you are ready to complete other tutorials to learn the basics of developing web applications and portlets with WPF.

 

Setup Requirements

The following setup is required to run the tutorial.

  • To test portlets you need access to a local or networked installation of WebSphere Portal.

    To deploy your project, WebSphere Portal server must be running. The instructions in this tutorial assume that you have the WebSphere Portal server installed locally, though other configurations are possible, as described below. If you do not have a portal you can test the applications standalone from an application server but cannot complete the portal specific steps.

  • WPF Designer must be installed locally.

    WPF Designer is the development environment for creating web applications and portlets. It is installed into an IDE such as Eclipse or Rational Application Developer (RAD). If you do not have Eclipse or RAD installed already, you can install Eclipse as part of the WPF installation procedure.

  • You need access to an application server for running your applications from the Designer while they are under development.

    WebSphere Portal runs on top of WAS, so if you have installed WebSphere Portal, you can use its instance of the WAS as your test environment. You can also use WAS Community Edition (WAS CE), or Tomcat.

 

Creating the Project

  1. Launch the Eclipse or RAD client into which you installed WPF Designer. If you are presented with a welcome page, close it.

    When using RAD, you should locate the workspace close to the top level of your file system, for example...

    C:\IBM\my_projects\

    ...to prevent path/file names from exceeding the Windows 256-character limit.

  2. Switch to the WPF perspective by choosing...

    Window | Open Perspective | Other... | WebSphere Portlet Factory

  3. Create a WPF Web Application project:

    1. From the menu, choose...

      File | New | WebSphere Portlet Factory Project

      You will be guided through a wizard that assists you in creating the project.

    2. For the Project Name step, enter MyFirstProject without any spaces. Click Next.

    3. Add the Tutorials and Samples feature set.

      All available feature sets are listed. Choose Tutorials and Samples to select all components within that feature set.

    4. Click Next to continue.

  4. Create two deployment configurations.

    • WAS deployment configuration

      Used to test your models when you run them from within WPF Designer.

    • Portal Server Deployment Configuration

      Used to configure your application for deployment to a portal.

    Common types of configuration include...

    Configuration Type Description
    Locally installed Portal and Application servers You have installed WebSphere Portal Server and the embedded WAS locally. When you create new deployment configurations, references to critical folders such as the application server's installedApps folder will point to your local hard drive.

    This configuration is requires a powerful development machine with a minimum of 2 GB of RAM in order to achieve acceptable levels of performance.

    Remotely installed Portal and Application Servers WebSphere Portal server and the embedded WAS are installed on another machine accessible across the network. Your local machine will need to have mapped drive(s) or UNCs pointing at certain folders on the remote server. When you create new deployment configurations, references to these mapped drives or UNCs will cause the application EARs and portlet WARs to be copied to the correct locations on the remote servers.

  5. Create the WebSphere Application Server deployment configuration. If you have an existing deployment configuration that works you can use it. Otherwise you will need to create a new configuration.

    1. Click Add in the WebSphere Application Server deployment configuration pane of the deployment configuration window.

    2. Enter a name for the WebSphere Application Server deployment configuration.

    3. Optionally, enter a description of the configuration.

    4. Choose the version of WebSphere Application Server from the Server Type box.

      When you have finished entering these values, the dialog box expands to display additional input fields. Use this table as a guide to understand the inputs required in the WebSphere Application Server deployment configuration pane of the deployment configuration window.

      Input Name Description
      Installed Applications Dir Choose the path to the installedApps folder for your application server, for example...

      c:\IBM\AppServer\installedApps\CELL_NAME

      ...for a local WAS installation or...

      v:\wp_profile\installedApps\CELL_NAME

      ...for a remote WAS installation mapped to v: The wizard will display an error message at the top you choose an invalid folder or enter an invalid CELL_NAME.

      Server Host Provide the host name of the application server. If the WebSphere Application Server/WebSphere Portal server installation is local, enter localhost, otherwise enter the hostname of the machine where the Application Server is installed.
      Server Port Provide the port number for the application server instance you have designated. The default ports differ between WebSphere Application Server/WebSphere Portal server versions.

      On a WAS/WebSphere Portal server 6.0 server installation, the default port for the server1 instance is 10000 and the WebSphere_Portal instance is 10038. Since you will probably be deploying to the WebSphere_Portal you will probably use 10038. See the product Help topic "Working with Projects" for detailed information on configuring your server port.

      Specify Deployment Credentials This option allows WPF to automatically deploy your application, without requiring you or an administrator to manually deploy your application from the administration console on the server. This option is only available when the WAS/WebSphere Portalserver servers are locally installed. Automatic deployment of the development WAR file is very convenient. For this reason, many developers prefer using locally installed servers when their hardware supports doing so. If this option is available, you should enable it.
      WAS Server for Deployment From the list, choose the server to which this project's applications should be deployed. If you are using WebSphere Portal server IBM recommends that you use the WebSphere Portal server for your WebSphere Application Server server.
      Admin User Enter the user name of the WebSphere Application Server administrator. This name will probably be different than the WebSphere Portal server administrator's user name.
      Admin Password Enter the password for the WebSphere Application Server administrator.

    5. Click Test Server Connection to verify the connection to the WebSphere Application Server. If you receive an error then make sure your server is running and then click Test Server Connection again.

    6. Click OK to continue.

  6. Create the WebSphere Portal deployment configuration.

    If you have an existing deployment configuration that works you can use it. Otherwise you will need to create a new configuration.

    1. Click Add in the Portal Server Deployment Configuration pane of the Deployment Configuration window.

    2. Enter a name for the WebSphere Portal deployment configuration.

    3. Optionally, enter a description of the configuration.

    4. Choose the version of the WebSphere Portal server from the Server Type box. Make the most appropriate choice for the environment where this project's applications will get deployed. When you have finished entering these values, the dialog box expands to display additional input fields.

      Use this table as a guide to understand the inputs required in the Portal Server Deployment Configuration pane of the Deployment Configuration window.

      Table 3. WebSphere Portal server configuration fields
      Input Name Description
      Portlet API: Java Standard Portlet API Portlets can be created using Java Standard 2.0 ( JSR 286) supported in WebSphere Portal 6.1 , Java Standard 1.0 (JSR 168) API supported in WebSphere Portal 6.x or the WebSphere Native API supported in WebSphere Portal 6.x. Since the WebSphere Native API has been deprecated, you should use the Java Standard API if you will be deploying your portlets to Portal 6.x.

      WebSphere Native (deprecated)

      WP Root Specify the path to the WebSphere\PortalServer folder whether it is local or available via a mapped drive or UNC. The installableApps and installedApps folders for the portal server are beneath this folder and are used by the automatic deployment process for portlet WAR files.
      pbportlet.jar location Path to the location of the pbportlet.jar file.

      (WebSphere Native only)

      Auto deploy This option allows WPF to automatically deploy your application to the WebSphere Portal server. Automatic deployment of the development WAR file is very convenient. You will still need to log in to your WebSphere Portal and place the portlets you have created onto pages in your WebSphere Portal

      WebSphere Portal 6.1 only

      Specify Deployment Credentials

      WebSphere Portal 6.0 only

      Automatically deploy your application to the WebSphere Portal server. You will still need to log in to your WebSphere Portal and place the portlets you have created onto pages in your WebSphere Portal.
      JRE Home Choose a path to the desired JRE location.
      Admin URL Enter the path to the WebSphere Portal server config console, that is, http://localhost:10038/wps/config
      Admin User Enter the user name of the WebSphere Portal server administrator. This name will probably be different than the WAS administrator's user name.
      Admin Password Enter the password for the WebSphere Portal administrator.

    5. Click Test Server Connection to verify the connection to the WAS.

      If you receive an error then make sure your server is running and then click Test Server Connection again.

    6. Click OK to continue.

    7. Click Finish to create the project.

  7. When you click Finish, your project will be created according to the details and features you have specified.

    WPF will also generate two WAR files for you. The WPF Application Server WAR file will be used when running your application standalone on a WAS. The WebSphere Portal Server WAR file will be used when running your application as a portlet within a portal.

    If you have not chosen automatic deployment, you will need to deploy the WAR files manually after this process completes. (See the product Help topic "Deploying WAR files for production" for information about manual deployment.) If you have chosen automatic deployment the WAR files will be deployed to the servers for you. There is a large amount work being done here, so the deployment could take 2 - 3 minutes to complete.

    If you are using a local installation of WPF 6.x, security for WAS is enabled by default. As a result, you may be prompted for credentials during the creation of the WAR files. Use the WAS administrator credentials and not the WebSphere Portal administrator credentials. Also, be sure to wait for this prompt before leaving the deployment unattended. The prompt will time out if you ignore it and your WAR file will not be automatically deployed. In this case, you can still install and configure the WAR file manually via the WebSphere Administrative Console.

  8. When the Deployment Request dialog displays, click Yes to complete the auto deployment process.

  9. When the process completes, notice that the two installed feature sets have opened README editors. These files are the "read me" files for the Tutorials and Samples feature set you installed with this project. Read through these files and close them when you are finished. You should be left with an empty (gray) work area.

  10. If the deployment servers are remote or if you have chosen not to auto deploy your application, you will see an error message in the Problems view. This message will state that the WPF Dev WAR location does not exist. You will also see this message if automatic deployment failed for some reason, such as if your server was not running. If you receive this error you will need to deploy the Portlet WAR file manually via the WebSphere Portal Administrative console.

 

Testing the Setup

Now that you have created the WPF project you will run a sample application on the server to test that everything is properly configured.

Double-click...

Project Explorer | models | tutorials | solutions | basics | MyFirstPortlet_Solution

  • Create a run configuration

    1. From the menu, choose Run > Run... or click above the workspace. Select the default run configuration that was created when the WPF Model project was created. This is the current active model.

    2. If everything has been configured correctly, you should see a web application in the browser. It is not necessary to do anything with this application. Simply seeing it in the browser confirms that the setup is correct and that WAS is running the application.

  • Clean up Java compiler messages and warnings (Optional)

    1. Switch back to WPF WebSphere Portlet Factory Designer. In the Problems tab at the bottom of the workspace, you may see several warnings about and unused local variables. These messages are about unnecessary code in the sample Java files in the Tutorials and Samples - Builders feature set. These variables will get used if you complete the tutorial called Creating a Custom Builder. If you prefer to suppress these warnings for now, continue with this step. Otherwise, skip to step 5.

    2. Follow these steps to suppress unnecessary code warnings.

      1. From the menu, choose Window > Preferences to bring up the Preferences dialog box.

      2. On the left side of this dialog box, select Java > Compiler > Errors/Warnings .

      3. On the right side, there should be several collapsed sections. Expand the section labeled Unnecessary code.

      4. There are a few fields in this section whose values are set to Warning such as Local variable is never read. Set all of the fields in this section to Ignore.

      5. Click OK to save these changes.

      6. Eclipse will now need to rebuild all of the currently open projects. When prompted to do a full build to apply these changes, click Yes. After the rebuild process has completed, the warnings will be gone.

  • Test a portlet model in WebSphere Portal to ensure the portlet deployed properly.

    1. Log into WebSphere Portal as an administrator or a user with rights to create pages and add portlets to pages.

    2. Add the portlet whose title is Tutorial Basics portlet - Solution to a new or existing page. If you did everything correctly while creating the project, you should see this portlet easily. Close out of page management when finished.

    3. Open the WebSphere Portal to the page containing this new portlet and examine the portlet. It should look like the MyFirstPortlet_Solution model you tested at the beginning of this section.

    4. Close WebSphere Portal when you are satisfied that the portlet deployed properly.

  • Close all open models and files in WPF Designer by choosing from the menu File > Close All.

    Now you are ready to move forward to learn how to develop web applications and portlets with WPF Designer. Start with the tutorial for Creating a Simple Portlet.

    Parent topic: Learning about WebSphere Portlet Factory