15.3.1 Inspecting the Struts portlet project

Now that the Struts portlet has been created, let's take a look at what Rational Application Developer has generated for you.

All of the necessary *.tld files are included in the WEB-INF directory.

All of the necessary *.jar files are included in the WEB-INF/lib directory.

The struts-config file was created, and the <controller> element that defines the RequestProcessor subclass was automatically generated in the Struts configuration file. The struts-html-edit configuration file was also created.
<controller 
processorClass="com.ibm.portal.struts.portlet.WpRequestProcessor">

</controller>

The web.xml deployment descriptor was created.

- Struts portlet tag library definitions were included.

- Welcome-file list was supplied.

<welcome-file-list>

<welcome-file>index.html</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

<welcome-file>default.html</welcome-file>

<welcome-file>default.htm</welcome-file>

<welcome-file>default.jsp</welcome-file>

</welcome-file-list>

This list is not really necessary; as we will see, the Struts Portlet framework provides a mechanism to identify which page must be displayed first for each different mode and markup language.

The portlet.xml deployment descriptor was created.

- A portlet was created and the StrutsPortlet class was specified as the servlet class. The config init-param was created to specify the struts-config file to be used and the struts-servlet-mapping init-param was created to specify the struts mapping. Other init-params were also included but omitted in the sample below to simplify understanding.

- A preference pointing to the initial page to be used in View mode as well as a preference pointing to the initial page for Edit mode were also created by the wizard as shown in Figure 15-1.

For more information about other added elements, see the WebSphere Portal Infocenter.

Example 15-1 Generated portlet preferences in portlet descriptor (portlet.xml)

  <portlet-preferences>
   <preference>
    <name>com.ibm.struts.portal.page.view.html</name>
    <value>index.jsp</value>
   </preference>
   <preference>
    <name>com.ibm.struts.portal.page.edit.html</name>
    <value>html/edit/index.jsp</value>
   </preference>
  </portlet-preferences>

The definition of a config parameter and a com.ibm.struts.portal.page.<mode>.<markup> preference above is the standard way to define a Struts configuration file and modules and the first page to be displayed for each specific mode and markup language.

In the Struts portlet framework, each markup and mode is mapped to a specific Struts configuration file and module. If you want to add support for Edit mode in the wml markup language, for example, you should create a config/wml/edit parameter pointing to the Struts configuration file and a com.ibm.struts.portal.page.edit.wml preference pointing to the initial page for this mode/markup.

Figure 15-9 illustrates the generated modules for View mode (default module) and Edit mode (/html/edit).

Figure 15-9 Generated Struts portlet


Redbooks
ibm.com/redbooks