3.4 Portlet application wizard

 < Day Day Up > 

In this section, you will see how to build a portlet application project with the wizard and then test it in the Test Environment. Portlets are WAR (Web Archive) files so they need to be tested in a server.

Follow these steps to create a portlet application project:

  1. Start WebSphere Studio Site Developer by clicking Start-> Programs-> IBM WebSphere Studio-> Site Developer 5.0 .

  2. In the pop-up window, enter the Site Developer workspace directory. The workspace directory is the place where the projects and servers are stored. You can create different workspace directories for different projects.

    Figure 3-1. Workspace directory

    graphics/03fig01.jpg

  3. Once WebSphere Studio has started, switch to the Portlet Perspective by clicking Window-> Open Perspective-> Other and selecting the Portlet perspective.

  4. To start the Portlet Application wizard, from the menu bar select File-> New-> Portlet Application Project . The wizard can also be started by selecting File-> New-> Other and then Portlet Development on the left side and Portlet Application Project on the right side.

    When the wizard starts, you will be presented with the window shown in Figure 3-2 on page 130.

    Figure 3-2. Portlet project wizard initial window

    graphics/03fig02.jpg

    The fields in the first window are:

    - Project Name : this value will determine the name of the project created by this wizard. The value entered here will be used throughout the remainder of the wizard as the default value for other parameters.

    - Use default : this checkbox indicates that you would like the entire contents of the application stored in the workspace. If you would like the contents of the application stored somewhere else on the file system, deselect this box.

    - New project location : if you deselect the Use default check box, this field is enabled and allows you to specify where the application will be saved.

    - Create an empty portlet : this option will create a portlet entry in the portlet deployment description, but no portlet Java classes. If you choose this option, you will need to add portlet code.

    - Create a basic portlet : this is the default option and will create a basic portlet in the portlet application. The portlet will extend from PortletAdapter and contain meaningful implementations of all four do methods . The implementations will adhere to the MVC approach. A bean will also be created for you to encapsulate your business logic. The resulting folder structure will appear as in Figure 3-10 on page 137.

    - Web Project features

  5. When you select Finish in this window, a portlet application will be created with the default values. By selecting Next , you can modify the default values for the J2EE Settings Page, as illustrated in Figure 3-3.

    Figure 3-3. J2EE Settings Page

    graphics/03fig03.jpg

    The fields in this window are:

    - Enterprise Application project : although the Portal Server does not recognize EAR files, the portlet application in WebSphere Studio must be contained in an Enterprise Application. When using the Portal Server debugging environment, all portlet applications contained in an EAR file are deployed together. You may choose an existing EAR file or enter a new one to be created. If you enter a new one then you can choose the location where your application will be stored.

    - Context Root : this value will be used in the application.xml and Web settings files. It will not be the context root of the portlet application when deployed. Since the EAR is not used to deploy the portlet application into a full server, this value is only used when the EAR is published to debug Portal Server connected to WebSphere Studio Application Developer.

    - J2EE level : the portlet application designed for WebSphere Portal V5.0 should be compliant with J2EE level 1.3 specification.

  6. If you click Next , you can select dependent JARs existing within the Enterprise Application project selected in the second window.

    Figure 3-4. Module dependencies window

    graphics/03fig04.jpg

  7. By selecting Next again, you can see the general settings of the portlet.

    Figure 3-5. Portlet settings

    graphics/03fig05.jpg

    The fields in this window are:

    - Application name : this name is used in the portlet.xml to specify the abstract application name. This value will never be seen by the administrator of the portlet or the end user . Generally, there is no need to change this value.

    - Portlet name : this value is used to identify the abstract portlet. This name will never been seen by the administrator or the end user. There is typically no need to alter this value.

    - Default locale : this value adds the default locale and the language block to the portlet.xml.

    - Portlet title : this will complete the language block with the title. The description, short title and keyword elements are included in the language block but left empty.

    - Code generation options : this check box allows you to change the default prefix names given to the Java package which will be created in the Java Source folder and the class name of the default source created by the wizard.

  8. The next window of the wizard allows you to define event handling options, for example action event and message event handling. Checking the Add action listener check box or add message listener check box will cause the portlet code generated by the wizard to implement the ActionListener or MessageListener interface, respectively. Form samples for those events are also provided by the wizard.

    Figure 3-6. Fifth screen of the Portlet application project wizard

    graphics/03fig06.jpg

  9. In the next window of the wizard, you can add Credential Vault handling to the portlet. For more information about the different options of Credential Vault, see Chapter 10, "Using the Credential Vault" on page 319.

    Figure 3-7. Credential Vault window

    graphics/03fig07.jpg

  10. This next window allows you to add more miscellaneous options of the portlet. By default, the html markup and portlet View mode are created.

    Figure 3-8. Miscellaneous options

    graphics/03fig08.jpg

    The fields in this window are:

    - Additional markups : these check boxes indicate which markup languages you intend to support. By selecting a value, a new folder will be created under the JSP folder containing JSPs specifically for the markup. A basic portlet specifying all three markups will produce the folder structure shown in Figure 3-9.

    Figure 3-9. Supporting additional markups

    graphics/03fig09.gif

    - Additional modes : these check boxes allow you to enable fragment for Help and Configure mode for the html markup. Two new JSPs files will be created as you can see in Figure 3-9.

  11. Select Finish and the wizard will create the necessary folder structure, classes, JSPs and deployment descriptors.

 < Day Day Up > 


IBM WebSphere Portal V5 A Guide for Portlet Application Development
IBM Websphere Portal V5: A Guide for Portlet Application Development
ISBN: 0738498513
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net